mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-07-30 03:14:40 +00:00
k8s: fix get_api_client usage in inventory plugin (#395)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
2
changelogs/fragments/k8s_inventory.yml
Normal file
2
changelogs/fragments/k8s_inventory.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- k8s - fix get_api_client API in k8s inventory plugin (https://github.com/ansible-collections/community.kubernetes/pull/395).
|
||||||
@@ -23,7 +23,7 @@ DOCUMENTATION = '''
|
|||||||
plugin:
|
plugin:
|
||||||
description: token that ensures this is a source file for the 'k8s' plugin.
|
description: token that ensures this is a source file for the 'k8s' plugin.
|
||||||
required: True
|
required: True
|
||||||
choices: ['k8s']
|
choices: ['community.kubernetes.k8s', 'k8s']
|
||||||
connections:
|
connections:
|
||||||
description:
|
description:
|
||||||
- Optional list of cluster connection settings. If no connections are provided, the default
|
- Optional list of cluster connection settings. If no connections are provided, the default
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ def configuration_digest(configuration):
|
|||||||
return digest
|
return digest
|
||||||
|
|
||||||
|
|
||||||
def get_api_client(module=None):
|
def get_api_client(module=None, **kwargs):
|
||||||
auth = {}
|
auth = {}
|
||||||
|
|
||||||
def _raise_or_fail(exc, msg):
|
def _raise_or_fail(exc, msg):
|
||||||
@@ -131,6 +131,8 @@ def get_api_client(module=None):
|
|||||||
for true_name, arg_name in AUTH_ARG_MAP.items():
|
for true_name, arg_name in AUTH_ARG_MAP.items():
|
||||||
if module and module.params.get(arg_name):
|
if module and module.params.get(arg_name):
|
||||||
auth[true_name] = module.params.get(arg_name)
|
auth[true_name] = module.params.get(arg_name)
|
||||||
|
elif arg_name in kwargs and kwargs.get(arg_name) is not None:
|
||||||
|
auth[true_name] = kwargs.get(arg_name)
|
||||||
else:
|
else:
|
||||||
env_value = os.getenv('K8S_AUTH_{0}'.format(arg_name.upper()), None) or os.getenv('K8S_AUTH_{0}'.format(true_name.upper()), None)
|
env_value = os.getenv('K8S_AUTH_{0}'.format(arg_name.upper()), None) or os.getenv('K8S_AUTH_{0}'.format(true_name.upper()), None)
|
||||||
if env_value is not None:
|
if env_value is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user