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:
- Either parse my string selector to
LabelSelector just so that build_selector parses it back to a string
- 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.
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:
LabelSelectorjust so thatbuild_selectorparses it back to a stringA simple fix for this would be to change the
build_selectorfunction to just return the passed selector (and not parse it) in case the passed selector is already a string.