[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
pull/51517/head
Fabian von Feilitzsch 6 years ago committed by ansibot
parent abb964a5a0
commit 0be66113d4

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

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

Loading…
Cancel
Save