Skip to content

Commit eaa0495

Browse files
authored
feat: add debug logs to KubeConfigLoader (#45)
1 parent c86bd42 commit eaa0495

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

kubernetes_asyncio/config/kube_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import base64
1818
import datetime
1919
import json
20+
import logging
2021
import os
2122
import tempfile
2223

@@ -161,6 +162,12 @@ def set_active_context(self, context_name=None):
161162
if self._user is not None and 'auth-provider' in self._user and 'name' in self._user['auth-provider']:
162163
self.provider = self._user['auth-provider']['name']
163164

165+
logging.debug('kubeconfig loader - current-context %s, cluster %s, user %s, provider %s',
166+
context_name,
167+
self._current_context['context']['cluster'],
168+
self._current_context['context'].safe_get('user'),
169+
self.provider)
170+
164171
async def _load_authentication(self):
165172
"""Read authentication from kube-config user section if exists.
166173
@@ -176,6 +183,7 @@ async def _load_authentication(self):
176183
"""
177184

178185
if not self._user:
186+
logging.debug('No user section in current context.')
179187
return
180188

181189
if self.provider == 'gcp':
@@ -187,13 +195,16 @@ async def _load_authentication(self):
187195
return
188196

189197
if 'exec' in self._user:
198+
logging.debug('Try to use exec provider')
190199
res_exec_plugin = await self._load_from_exec_plugin()
191200
if res_exec_plugin:
192201
return
193202

203+
logging.debug('Try to load user token')
194204
if self._load_user_token():
195205
return
196206

207+
logging.debug('Try to use username and password')
197208
self._load_user_pass_token()
198209

199210
async def load_gcp_token(self):

0 commit comments

Comments
 (0)