K8sConfig: guard against None elements
@@ -74,6 +74,7 @@ class K8sConfig(object):
self.users = dotconf['users']
self.version = dotconf['apiVersion']
+ if self.clusters:
for cluster in self.clusters:
if cluster['name'] == self.current_context_dict['cluster']:
if 'server' in cluster['cluster']:
@@ -83,6 +84,7 @@ class K8sConfig(object):
if 'certificate-authority-data' in cluster['cluster']:
self.ca_cert_data = cluster['cluster']['certificate-authority-data']
+ if self.users:
for user in self.users:
if user['name'] == self.current_context_dict['user']:
if 'username' in user['user'] and 'password' in user['user']:
@@ -94,6 +96,7 @@ class K8sConfig(object):
self.client_key = user['user']['client-key']
self.cert = (self.client_certificate, self.client_key)
+ if self.contexts:
for context in self.contexts:
if context['name'] == self.current_context:
if 'namespace' in context['context']:
