Closed addyess closed 2 years ago
Workaround ?
# Quick hack to set `trust_env=False` on the httpx client,
# so that it ignores env *_proxy settings.
from lightkube.core.generic_client import GenericClient
from lightkube.config.client_adapter import httpx_parameters
from lightkube.config.kubeconfig import SingleConfig
import httpx
def CustomClient(config: SingleConfig, timeout: httpx.Timeout) -> httpx.Client:
return httpx.Client(trust_env=False, **httpx_parameters(config, timeout))
GenericClient.AdapterClient = staticmethod(CustomClient)
# -------------------------------------------------------------------------------------------
I don't have specific concerns to support the trust_env
parameter (and you can create a PR for that), but I would like to avoid the generic kwargs
: lightkube
like httpx
attempts to offer a clear and typed interface to end users, so that it's easier to use and more errors can be caught before runtime. Furthermore not all httpx.Client
parameters make sense for a k8s client nor we can allow to override parameters that are generated from kubeconfig and needed for proper authentication.
i can agree with this style. I will adjust my https://github.com/gtsystem/lightkube/pull/20 tomorrow to meet this request. Thanks for the great library.
Updated. thanks for the review @gtsystem
Released as part of v0.10.0
httpx client created here doesn't allow override of the
trust_env
keyword option.Please consider some generic
**kwargs
for configuration of the client.httpx.Client
will probably continue to expand its constructor here