From 134ed2447458dbe09a937eab97ae9043a1c813b8 Mon Sep 17 00:00:00 2001 From: Fabian von Feilitzsch Date: Fri, 13 Jul 2018 16:31:22 -0400 Subject: [PATCH] Properly format API key when set in an enviroment variable (#42202) (cherry picked from commit 0421305254e5a02345f37f0c7fec991661dbfb44) --- lib/ansible/module_utils/k8s/common.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/k8s/common.py b/lib/ansible/module_utils/k8s/common.py index 0cbba3f69f7..1f33bafc10e 100644 --- a/lib/ansible/module_utils/k8s/common.py +++ b/lib/ansible/module_utils/k8s/common.py @@ -138,8 +138,11 @@ class K8sAnsibleMixin(object): elif key in auth_args and value is None: env_value = os.getenv('K8S_AUTH_{0}'.format(key.upper()), None) if env_value is not None: - setattr(configuration, key, env_value) - auth[key] = env_value + if key == 'api_key': + setattr(configuration, key, {'authorization': "Bearer {0}".format(env_value)}) + else: + setattr(configuration, key, env_value) + auth[key] = env_value kubernetes.client.Configuration.set_default(configuration)