common: import k8sdynamicclient directly (#163)

This commit is contained in:
Abhijeet Kasurde
2021-07-09 10:02:35 +05:30
committed by GitHub
parent eab3aa29bf
commit 5fb3ecbb50
2 changed files with 5 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
---
bugfixes:
- common - import k8sdynamicclient directly to workaround Ansible upstream bug (https://github.com/ansible-collections/kubernetes.core/issues/162).

View File

@@ -53,7 +53,7 @@ except ImportError as e:
IMP_K8S_CLIENT = None IMP_K8S_CLIENT = None
try: try:
from ansible_collections.kubernetes.core.plugins.module_utils.k8sdynamicclient import K8SDynamicClient from ansible_collections.kubernetes.core.plugins.module_utils import k8sdynamicclient
from ansible_collections.kubernetes.core.plugins.module_utils.client.discovery import LazyDiscoverer from ansible_collections.kubernetes.core.plugins.module_utils.client.discovery import LazyDiscoverer
IMP_K8S_CLIENT = True IMP_K8S_CLIENT = True
except ImportError as e: except ImportError as e:
@@ -195,7 +195,7 @@ def get_api_client(module=None, **kwargs):
return client return client
try: try:
client = K8SDynamicClient(kubernetes.client.ApiClient(configuration), discoverer=LazyDiscoverer) client = k8sdynamicclient.K8SDynamicClient(kubernetes.client.ApiClient(configuration), discoverer=LazyDiscoverer)
except Exception as err: except Exception as err:
_raise_or_fail(err, 'Failed to get client due to %s') _raise_or_fail(err, 'Failed to get client due to %s')