kubernetes: handle situation where the configuration is empty

This change is a follow-up to I5bdd369f6c9a78e5f79a926d8690f285fda94af9
where it missed the case where the configuration could be None.

Change-Id: I613cbf82932e14a8048e4dcfbf539fe1d83bf9e3
changes/96/800096/4 4.2.1
Tristan Cacqueray 2 years ago committed by Clark Boylan
parent 9757e3f1ce
commit 39ff609835

@ -41,10 +41,11 @@ def get_client(log, context, extra_client_constructor=None):
token, ca, client, extra_client = None, None, None, None
try:
conf = _get_conf(log, context)
auth = conf.configuration.api_key.get('authorization')
if auth:
token = auth.split()[-1]
if conf.configuration.ssl_ca_cert:
if conf:
auth = conf.configuration.api_key.get('authorization')
if auth:
token = auth.split()[-1]
if conf and conf.configuration.ssl_ca_cert:
with open(conf.configuration.ssl_ca_cert) as ca_file:
ca = ca_file.read()
ca = base64.b64encode(ca.encode('utf-8')).decode('utf-8')

@ -0,0 +1,6 @@
---
fixes:
- |
Fix Kubernetes in-cluster configuration loading if no local config
is present. The previous release missed a fallback case which has
been corrected.
Loading…
Cancel
Save