Skip to content

Commit 8985fc5

Browse files
committed
common: Handle aliases correctly
Fixed get_api_client API to handle `aliases` that are passed via inventory configuration or module parameters. Signed-off-by: Abhijeet Kasurde <[email protected]>
1 parent b68bf7c commit 8985fc5

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- common - handle ``aliases`` passed from inventory or module params.

molecule/default/tasks/full.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010
debug:
1111
var: output
1212

13+
- name: Use aliases and check if those values are picked up
14+
k8s:
15+
name: testing
16+
kind: Namespace
17+
validate_certs: yes
18+
ssl_ca_cert: /dev/null # invalid CA certificate
19+
ignore_errors: yes
20+
register: output
21+
22+
- name: assert that ssl_ca_cert caused a failure (and therefore was correctly translated to ssl_ca_cert)
23+
assert:
24+
that:
25+
- output is failed
26+
1327
- name: Setting validate_certs to true causes a failure
1428
k8s:
1529
name: testing

plugins/module_utils/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ def _raise_or_fail(exc, msg):
131131
for true_name, arg_name in AUTH_ARG_MAP.items():
132132
if module and module.params.get(arg_name):
133133
auth[true_name] = module.params.get(arg_name)
134+
elif module and true_name in module.params and module.params.get(true_name) is not None:
135+
# Aliases
136+
auth[true_name] = module.params.get(true_name)
137+
elif true_name in kwargs and kwargs.get(true_name) is not None:
138+
# Aliases
139+
auth[true_name] = kwargs.get(true_name)
134140
elif arg_name in kwargs and kwargs.get(arg_name) is not None:
135141
auth[true_name] = kwargs.get(arg_name)
136142
else:

0 commit comments

Comments
 (0)