Skip to content

Add option pass selectors as string #69

@wochinge

Description

@wochinge

Problem

First of all, I really like syntax to create selectors. Very clean and pythonic 💯

In our case we'd like to pass in the selector via environment variable. This is quite convenient as we can dynamically change the selector in quite advanced ways. Lightkube doesn't support an already rendered string selector. That leaves me with the following options:

  1. Either parse my string selector to LabelSelector just so that build_selector parses it back to a string
  2. Directly use the client under the hood. Example
    request = self._kubernetes_client._client.prepare_request(
            'list', res=Namespace,
            params={
                'limit': None,
                'labelSelector': string_selector,
                'fieldSelector': None
            }
        )
    namespaces = self._kubernetes_client.list(request)

A simple fix for this would be to change the build_selector function to just return the passed selector (and not parse it) in case the passed selector is already a string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions