4343 google_auth_available = False
4444
4545
46-
4746EXPIRY_SKEW_PREVENTION_DELAY = datetime .timedelta (minutes = 5 )
4847KUBE_CONFIG_DEFAULT_LOCATION = os .environ .get ('KUBECONFIG' , '~/.kube/config' )
4948ENV_KUBECONFIG_PATH_SEPARATOR = ';' if platform .system () == 'Windows' else ':'
@@ -60,7 +59,10 @@ def _cleanup_temp_files():
6059 _temp_files = {}
6160
6261
63- def _create_temp_file_with_content (content , temp_file_path = None , force_recreate = False ):
62+ def _create_temp_file_with_content (
63+ content ,
64+ temp_file_path = None ,
65+ force_recreate = False ):
6466 if len (_temp_files ) == 0 :
6567 atexit .register (_cleanup_temp_files )
6668 # Because we may change context several times, try to remember files we
@@ -143,7 +145,9 @@ def _write_file(self, force_rewrite=False):
143145 else :
144146 content = self ._data
145147 self ._file = _create_temp_file_with_content (
146- base64 .standard_b64decode (content ), self ._temp_file_path , force_recreate = force_rewrite )
148+ base64 .standard_b64decode (content ),
149+ self ._temp_file_path ,
150+ force_recreate = force_rewrite )
147151 else :
148152 self ._file = _create_temp_file_with_content (
149153 self ._data , self ._temp_file_path , force_recreate = force_rewrite )
@@ -245,7 +249,7 @@ def _refresh_credentials():
245249 'config' in self ._user ['auth-provider' ] and
246250 'cmd-path' in self ._user ['auth-provider' ]['config' ]):
247251 return _refresh_credentials_with_cmd_path ()
248-
252+
249253 # Make the Google auth block optional.
250254 if google_auth_available :
251255 credentials , project_id = google .auth .default (scopes = [
@@ -257,7 +261,7 @@ def _refresh_credentials():
257261 return credentials
258262 else :
259263 return None
260-
264+
261265 if get_google_credentials :
262266 self ._get_google_credentials = get_google_credentials
263267 else :
@@ -314,8 +318,6 @@ def _load_auth_provider_token(self):
314318 if provider ['name' ] == 'oidc' :
315319 return self ._load_oid_token (provider )
316320
317-
318-
319321 def _load_gcp_token (self , provider ):
320322 if (('config' not in provider ) or
321323 ('access-token' not in provider ['config' ]) or
@@ -442,7 +444,10 @@ def _load_from_exec_plugin(self):
442444 return
443445 try :
444446 base_path = self ._get_base_path (self ._cluster .path )
445- status = ExecProvider (self ._user ['exec' ], base_path , self ._cluster ).run ()
447+ status = ExecProvider (
448+ self ._user ['exec' ],
449+ base_path ,
450+ self ._cluster ).run ()
446451 if 'token' in status :
447452 self .token = "Bearer %s" % status ['token' ]
448453 elif 'clientCertificateData' in status :
@@ -535,7 +540,13 @@ def _refresh_api_key(client_configuration):
535540 self ._set_config (client_configuration )
536541 client_configuration .refresh_api_key_hook = _refresh_api_key
537542 # copy these keys directly from self to configuration object
538- keys = ['host' , 'ssl_ca_cert' , 'cert_file' , 'key_file' , 'verify_ssl' ,'tls_server_name' ]
543+ keys = [
544+ 'host' ,
545+ 'ssl_ca_cert' ,
546+ 'cert_file' ,
547+ 'key_file' ,
548+ 'verify_ssl' ,
549+ 'tls_server_name' ]
539550 for key in keys :
540551 if key in self .__dict__ :
541552 setattr (client_configuration , key , getattr (self , key ))
0 commit comments