mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-13 13:02:01 +00:00
common: import k8sdynamicclient directly (#163)
This commit is contained in:
3
changelogs/fragments/162_import_error.yml
Normal file
3
changelogs/fragments/162_import_error.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- common - import k8sdynamicclient directly to workaround Ansible upstream bug (https://github.com/ansible-collections/kubernetes.core/issues/162).
|
||||||
@@ -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')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user