Skip to content

Commit

Permalink
Backport ansible-collections#272 to refactor branch
Browse files Browse the repository at this point in the history
This incorporates the changes from 9e2d784 into the refactored code.
  • Loading branch information
gravesm committed Jun 2, 2022
1 parent 25777d1 commit ee752a2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions plugins/module_utils/k8s/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
AUTH_ARG_SPEC,
AUTH_PROXY_HEADERS_SPEC,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import requires
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
requires as _requires,
)

try:
from ansible_collections.kubernetes.core.plugins.module_utils import (
Expand Down Expand Up @@ -252,11 +254,15 @@ def patch(self, resource, definition, **params):

def get_api_client(module=None, **kwargs: Optional[Any]) -> K8SClient:
auth_spec = _create_auth_spec(module, **kwargs)
if module:
requires = module.requires
else:
requires = _requires
if isinstance(auth_spec.get("kubeconfig"), dict):
if module:
module.requires("kubernetes", "17.17.0", "to use in-memory config")
else:
requires("kubernetes", "17.17.0", "to use in-memory config")
requires("kubernetes", "17.17.0", "to use in-memory config")
if auth_spec.get("no_proxy"):
requires("kubernetes", "19.15.0", "to use the no_proxy feature")

configuration = _create_configuration(auth_spec)
client = create_api_client(configuration)

Expand Down

0 comments on commit ee752a2

Please sign in to comment.