Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
k8s: fix get_api_client usage in inventory plugin (#395)
Browse files Browse the repository at this point in the history
Signed-off-by: Abhijeet Kasurde <[email protected]>
  • Loading branch information
Akasurde authored Mar 26, 2021
1 parent 34e6e09 commit c9157ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/k8s_inventory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- k8s - fix get_api_client API in k8s inventory plugin (https://github.com/ansible-collections/community.kubernetes/pull/395).
2 changes: 1 addition & 1 deletion plugins/inventory/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
plugin:
description: token that ensures this is a source file for the 'k8s' plugin.
required: True
choices: ['k8s']
choices: ['community.kubernetes.k8s', 'k8s']
connections:
description:
- Optional list of cluster connection settings. If no connections are provided, the default
Expand Down
4 changes: 3 additions & 1 deletion plugins/module_utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def configuration_digest(configuration):
return digest


def get_api_client(module=None):
def get_api_client(module=None, **kwargs):
auth = {}

def _raise_or_fail(exc, msg):
Expand All @@ -131,6 +131,8 @@ def _raise_or_fail(exc, msg):
for true_name, arg_name in AUTH_ARG_MAP.items():
if module and 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:
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:
Expand Down

0 comments on commit c9157ce

Please sign in to comment.