2222import platform
2323import subprocess
2424import tempfile
25- import time
2625from collections import namedtuple
2726
2827import oauthlib .oauth2
2928import urllib3
3029import yaml
3130from requests_oauthlib import OAuth2Session
32- from six import PY3
3331
3432from kubernetes .client import ApiClient , Configuration
3533from kubernetes .config .exec_provider import ExecProvider
@@ -85,7 +83,7 @@ def _is_expired(expiry):
8583 datetime .datetime .now (tz = UTC ))
8684
8785
88- class FileOrData ( object ) :
86+ class FileOrData :
8987 """Utility class to read content of obj[%data_key_name] or file's
9088 content of obj[%file_key_name] and represent it as file or data.
9189 Note that the data is preferred. The obj[%file_key_name] will be used iff
@@ -151,7 +149,7 @@ def _write_file(self, force_rewrite=False):
151149 self ._data , self ._temp_file_path , force_recreate = force_rewrite )
152150
153151
154- class CommandTokenSource ( object ) :
152+ class CommandTokenSource :
155153 def __init__ (self , cmd , args , tokenKey , expiryKey ):
156154 self ._cmd = cmd
157155 self ._args = args
@@ -191,7 +189,7 @@ def token(self):
191189 expiry = parse_rfc3339 (data ['credential' ]['token_expiry' ]))
192190
193191
194- class KubeConfigLoader ( object ) :
192+ class KubeConfigLoader :
195193
196194 def __init__ (self , config_dict , active_context = None ,
197195 get_google_credentials = None ,
@@ -363,14 +361,9 @@ def _load_oid_token(self, provider):
363361 # https://tools.ietf.org/html/rfc7515#appendix-C
364362 return
365363
366- if PY3 :
367- jwt_attributes = json .loads (
368- base64 .urlsafe_b64decode (parts [1 ] + padding ).decode ('utf-8' )
369- )
370- else :
371- jwt_attributes = json .loads (
372- base64 .b64decode (parts [1 ] + padding )
373- )
364+ jwt_attributes = json .loads (
365+ base64 .urlsafe_b64decode (parts [1 ] + padding ).decode ('utf-8' )
366+ )
374367
375368 expire = jwt_attributes .get ('exp' )
376369
@@ -392,14 +385,9 @@ def _refresh_oidc(self, provider):
392385 if 'idp-certificate-authority-data' in provider ['config' ]:
393386 ca_cert = tempfile .NamedTemporaryFile (delete = True )
394387
395- if PY3 :
396- cert = base64 .b64decode (
397- provider ['config' ]['idp-certificate-authority-data' ]
398- ).decode ('utf-8' )
399- else :
400- cert = base64 .b64decode (
401- provider ['config' ]['idp-certificate-authority-data' ] + "=="
402- )
388+ cert = base64 .b64decode (
389+ provider ['config' ]['idp-certificate-authority-data' ]
390+ ).decode ('utf-8' )
403391
404392 with open (ca_cert .name , 'w' ) as fh :
405393 fh .write (cert )
@@ -565,7 +553,7 @@ def current_context(self):
565553 return self ._current_context .value
566554
567555
568- class ConfigNode ( object ) :
556+ class ConfigNode :
569557 """Remembers each config key's path and construct a relevant exception
570558 message in case of missing keys. The assumption is all access keys are
571559 present in a well-formed kube-config."""
0 commit comments