1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[k8s] Always check envvars when auth parameter is not provided (#51495)

* Always check envvars when auth parameter is not provided

This will make it so that all code using the get_api_client
method will make use of the environment variables, instead of
silently ignoring them if default values haven't been set. This
affects at least the k8s lookup plugin.

* Add changelog
This commit is contained in:
Fabian von Feilitzsch 2019-01-30 16:52:12 -05:00 committed by ansibot
parent abb964a5a0
commit 0be66113d4
2 changed files with 7 additions and 4 deletions

View file

@ -0,0 +1,3 @@
---
bugfixes:
- All K8S_AUTH_* environment variables are now properly loaded by the k8s lookup plugin

View file

@ -138,11 +138,11 @@ class K8sAnsibleMixin(object):
auth = copy.deepcopy(auth_params)
# If authorization variables aren't defined, look for them in environment variables
for key, value in iteritems(auth_params):
if key in auth_args and value is None:
env_value = os.getenv('K8S_AUTH_{0}'.format(key.upper()), None)
for arg in auth_args:
if auth_params.get(arg) is None:
env_value = os.getenv('K8S_AUTH_{0}'.format(arg.upper()), None)
if env_value is not None:
auth[key] = env_value
auth[arg] = env_value
def auth_set(*names):
return all([auth.get(name) for name in names])