
    [jj                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlmZmZ ddlmZ ddlmZmZ ddlmZ ddlmZ ddlmZ  ej        d	
          Zej                            dej                                        dz                                             Z! e	j"                    dk    rdndZ#dZ$i a% ej&        e'          Z(d Z)d Z* G d de+          Z, G d de+          Z- G d de+          Z. G d d          Z/	 d%dZ0d&dZ1	 	 	 	 d'dZ2	 	 	 d(d Z3d)d"Z4	 	 d*d#Z5	 	 d(d$Z6dS )+    N)	ApiClientConfiguration   )ConfigException)UTCparse_rfc3339)ExecProvider)google_auth_credentials)OpenIDRequestor   )minutes
KUBECONFIGz.kube/configWindows;:oidcc                      t                                           D ]'} 	 t          j        |            # t          $ r Y $w xY wi a d S N)_temp_filesvaluesosremoveOSError)	temp_files    b/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/kubernetes_asyncio/config/kube_config.py_cleanup_temp_filesr   -   s^     ''))  		Ii     	 	 	D	KKKs   2
??c                     t          |           t          z
  t          j                                                            t
                    k    S )N)tzinfo)r   EXPIRY_SKEW_PREVENTION_DELAYdatetimeutcnowreplacer   )expirys    r   _is_expiredr$   7   s@    6""%AA ''))111==> ?    c                   2    e Zd ZdZ	 	 	 d	dZd Zd Zd ZdS )

FileOrDataaC  Utility class to read content of obj[%data_key_name] or file's
     content of obj[%file_key_name] and represent it as file or data.
     Note that the data is preferred. The obj[%file_key_name] will be used iff
     obj['%data_key_name'] is not set or empty. Assumption is file content is
     raw data and data field is base64 string. The assumption can be changed
     with base64_file_content flag. If set to False, the content of the file
     will assumed to be base64 and read as is. The default True value will
     result in base64 encode of the file content after read.N Tc                 >   |s|dz   }d | _         d | _        || _        || _        |rt	          j        |d           ||v r||         | _        d S ||v rJt          j                            t          j                            |||                             | _         d S d S )Nz-dataT)nameexist_ok)	_file_data_base64_file_content_temp_file_pathr   makedirspathnormpathjoin)selfobjfile_key_namedata_key_namefile_base_pathbase64_file_contenttemp_file_paths          r   __init__zFileOrData.__init__F   s      	4)G3M

$7!- 	<K^d;;;;C]+DJJJc!!))^S-?@@B BDJJJ "!r%   c                    t          t                    dk    rt          j        t                     t          |          }|t          v rt          |         S t          j        | j                  \  }}|t          |<   t          |d          5 }|
                    t          |t
                    r|                                n|           d d d            n# 1 swxY w Y   |S )Nr   )dirwb)lenr   atexitregisterr   strtempfilemkstempr/   openwrite
isinstanceencode)r4   contentcontent_key_r*   fds         r   _create_temp_file_with_contentz)FileOrData._create_temp_file_with_contentW   s   {q  O/000 'll+%%{++"t';<<<4#'K $ 	PHHGS)A)ANW^^%%%wOOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	Ps   ?CC Cc                    | j          o| j        }|r| j        rht          | j        t                    r| j                                        }n| j        }|                     t          j        |                    | _         n|                     | j                  | _         | j         r;t          j
                            | j                   st          d| j         z            | j         S )zIf obj[%data_key_name] exists, return name of a file with base64
        decoded obj[%data_key_name] content otherwise obj[%file_key_name].zFile does not exists: %s)r,   r-   r.   rG   rB   rH   rM   base64standard_b64decoder   r1   isfiler   )r4   use_data_if_no_filerI   s      r   as_filezFileOrData.as_filee   s     #'*n; 		M( Mdj#.. )"j//11GG"jG!@@-g668 8

 "@@LL
: 	KbgnnTZ88 	K!"<tz"IJJJzr%   c           	         | j          o| j        }|rt          | j                  5 }| j        r\t                              t          j        t          	                    |
                                                              | _         n|
                                | _         ddd           n# 1 swxY w Y   | j         S )zIf obj[%data_key_name] exists, Return obj[%data_key_name] otherwise
        base64 encoded string of obj[%file_key_name] file content.N)r-   r,   rE   r.   bytesdecoderO   standard_b64encoderB   rH   read)r4   use_file_if_no_datafs      r   as_datazFileOrData.as_dataw   s     #'*n; 	*dj!! *Q, *!&1#**QVVXX2F2FGG"I "IDJJ "#DJ* * * * * * * * * * * * * * * zs   A=B//B36B3)Nr(   TN)__name__
__module____qualname____doc__r;   rM   rS   r[    r%   r   r'   r'   <   sp        @ @ :>8< $B B B B"    $    r%   r'   c                       e Zd Z	 	 	 	 	 ddZddZd Zd Zd Zd Zd	 Z	d
 Z
d Zd Zd Zd Zd Zd Zd Zed             ZdS )KubeConfigLoaderNr(   c                    t          |t                    r|| _        nt          d|          | _        d | _        d | _        d | _        d | _        |                     |           || _        || _	        || _
        |r	|| _        d S d | _        d S )Nzkube-config)rG   
ConfigNode_config_current_context_user_clusterproviderset_active_context_config_base_path_config_persisterr/   _get_google_credentials)r4   config_dictactive_contextget_google_credentialsconfig_base_pathconfig_persisterr:   s          r   r;   zKubeConfigLoader.__init__   s     k:.. 	B&DLL%m[AADL $
///!1!1-! 	0+AD(((+/D(((r%   c                    || j         d         }| j         d                             |          | _        | j        d                             d          re| j                             d          rK| j         d                             | j        d         d         d          }|r|d         | _        nd | _        nd | _        | j         d                             | j        d         d	                   d	         | _        | j        0d
| j        v r'd| j        d
         v r| j        d
         d         | _        t                              d|| j        d         d	         | j        d                             d          | j                   d S )Ncurrent-contextcontextscontextuserusersT)safeclustersclusterauth-providerr*   zHkubeconfig loader - current-context %s, cluster %s, user %s, provider %s)	re   get_with_namerf   safe_getrg   rh   ri   loggerdebug)r4   context_namerw   s      r   rj   z#KubeConfigLoader.set_active_context   s   <(9:L $Z 8 F F! !!),55f== 		%%g..		<(66%i08t 7 E ED "!&\

!

DJZ0>>!),Y79 99BD:!o&C&CRVR\]lRmHmHm J7?DM_!*95i@*95>>vFF]		$ 	$ 	$ 	$ 	$r%   c                 4  K   | j         st                              d           dS | j        dk    r|                                  d{V  dS | j        t
          k    r|                                  d{V  dS d| j         v r8t                              d           |                                  d{V }|rdS t                              d           |                                 rdS t                              d           | 	                                 dS )a  Read authentication from kube-config user section if exists.

        This function goes through various authentication methods in user
        section of kube-config and stops if it finds a valid authentication
        method. The order of authentication methods is:

            1. GCP auth-provider
            2. token field (point to a token file)
            3. oidc auth-provider
            4. exec provided plugin
            5. username/password
        z#No user section in current context.NgcpexeczTry to use exec providerzTry to load user tokenz Try to use username and password)
rg   r   r   ri   load_gcp_tokenPROVIDER_TYPE_OIDC_load_oid_tokenload_from_exec_plugin_load_user_token_load_user_pass_token)r4   res_exec_plugins     r   _load_authenticationz%KubeConfigLoader._load_authentication   s>      z 	LL>???F=E!!%%'''''''''F=...&&(((((((((FTZLL3444$($>$>$@$@@@@@@@O -...  "" 	F7888""$$$$$r%   c                 .  K   d| j         d         vri | j         d         j        d<   | j         d         d         }d|vsd|v rt          |d                   r| j        It	          j        | j                  r|                                  d {V }n*|                                 }nt          |           d {V }|j        |j        d<   |j        |j        d<   | j	        r| 	                    | j
        j                   d|d         z  | _        | j        S )Nconfigr|   zaccess-tokenr#   	Bearer %s)rg   valuer$   rm   asyncioiscoroutinefunctionr
   tokenr#   rl   re   )r4   r   credentialss      r   r   zKubeConfigLoader.load_gcp_token   s7     4:o666:<DJ'-h7O,X66))V##F84D(E(E#+7.t/KLL A(,(D(D(F(F"F"F"F"F"F"FKK"&">">"@"@KK$;F$C$CCCCCCC+6+<FL(%0%7FL"% ;&&t|'9::: 6.#99
zr%   c                 >  K   | j         d         }d|vrt          d          d|d         vrH|                     |           d {V  d                    |d         d                   | _        | j        S |d         d                             d          }t          |          dk    rt          d          |d	         }|d
t          |          d
z  z
  dz  z  }t          j        t          j
        |                              d                    }|                    d          }|Gt          t          j                            |                    r|                     |           d {V  d                    |d         d                   | _        | j        S )Nr|   r   zoidc: missing configurationid-tokenz	Bearer {}.   z8oidc: JWT tokens should contain 3 period-delimited partsr      =utf8exp)rg   
ValueError_refresh_oidcformatr   splitr?   jsonloadsrO   	b64decoderV   getr$   r    utcfromtimestamp)r4   ri   partsid_tokenjwt_attributesexpiress         r   r   z KubeConfigLoader._load_oid_token   s     :o.8##:;;;Xh///$$X.........$++HX,>z,JKKDJ:":.44S99u::??WXXX8QX**c11F$4X$>$>$E$Ef$M$MNN $$U++ )::7CCDD   $$X......... ''(::(FGG
zr%   c                   K   d|d         vrt          d          t          j        d          5 }d }|                     |          }|0|                    |           |                                 |j        }t          |d         d         |d         d         |d         d         |          }|                    |d         d                    d {V }|d	         |d         j	        d
<   |d         |d         j	        d<   | j
        r| 
                    | j        j	                   d d d            d S # 1 swxY w Y   d S )Nzrefresh-tokenr   zAoidc: No valid id-token, and cannot refresh without refresh-tokenT)deletez	client-idzclient-secretzidp-issuer-urlr   r   refresh_token)r   rC   NamedTemporaryFile_retrieve_oidc_cacertrF   flushr*   r   r   r   rl   re   )r4   ri   certfilessl_ca_certcert_auth_data	requestorresps          r   r   zKubeConfigLoader._refresh_oidc  s     (8"444!"efff(555 	;K!77AAN)~...   &m'";/"?3"#34	 I #00(1CO1TUUUUUUUUD37
3CHX$Z08<_8MHX$_5% ;&&t|'9:::+	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s   C9D77D;>D;c                 Z    d|d         v r t          j        |d         d                   S d S )Nzidp-certificate-authority-datar   )rO   r   )r4   ri   s     r   r   z&KubeConfigLoader._retrieve_oidc_cacert4  s3    +x/AAA#HX$67W$XYYYtr%   c                    K   	 t          | d          rt          | j                  sdS |                     | j        j                  }t          | j        d                                                    d {V }d|v r/d|d         z  | _	        d|v rt          |d                   | _        nd|v rd|vrt                              d	           d S t          |d d|d
| j                                                  | _        t          |d d|d
| j                                                  | _        nt                              d           dS # t$          $ r2}t                              t'          |                     Y d }~d S d }~ww xY w)Nexec_plugin_expiryTr   r   r   expirationTimestampclientCertificateDataclientKeyDataz2exec: missing clientKeyData field in plugin outputF)r7   r8   r9   r:   zCexec: missing token or clientCertificateData field in plugin output)hasattrr$   r   _get_base_pathrh   r1   r	   rg   runr   r   r   errorr'   r/   rS   	cert_filekey_file	ExceptionrB   )r4   	base_pathstatuses       r   r   z&KubeConfigLoader.load_from_exec_plugin:  s     !	!t122 ;tG^;_;_ t++DM,>??I'
6(:;;??AAAAAAAAF&  (6'?:
(F22.;FCX<Y.Z.ZD+(F22 #&00LL "1 2 2 24!+D"9#,(-#'#7"9 "9 "9
 :A  !+D"1#,(-#'#7!9 !9 !9
 :A   6 7 7 74 	! 	! 	!LLQ         	!s$   $E B&E A=E 
F'FFc                     |                      | j        j                  }t          | j        dd|d                                          }|rd|z  | _        dS d S )N	tokenFiler   F)r8   r9   r   T)r   rg   r1   r'   r[   r   )r4   r   r   s      r   r   z!KubeConfigLoader._load_user_token^  so    ''
88	JW$ %' ' ' (/wyy 	  	$u,DJ4	 	r%   c                     d| j         v rjd| j         v rc| j         d         dz   | j         d         z   }dt          j        |                                                              d          z   | _        dS d S d S )Nusernamepasswordr   zBasic zutf-8T)rg   rO   	b64encoderH   rV   r   )r4   
basic_auths     r   r   z&KubeConfigLoader._load_user_pass_tokenh  s    ##
dj(@(@J/#5
:8NNJ!F$4!!##%% %%%+VG__5DJ4	 $#(@(@r%   c                     | j         | j         S |<t          j                            t          j                            |                    S dS )Nr(   )rk   r   r1   abspathdirname)r4   config_paths     r   r   zKubeConfigLoader._get_base_patho  sA    !-))"7??27??;#?#?@@@rr%   c                    d| j         v r| j         d                             d          | _        | j                            d          r|                     | j         j                  }t          | j         d|| j                                                  | _	        d| j
        vrht          | j        d|| j                                                  | _        t          | j        d|| j                                                  | _        d	| j         v r| j         d	          | _        d
| j         v r| j         d
         | _        d| j         v r| j         d         | _        d S d S )Nserver/httpszcertificate-authority)r8   r:   r   zclient-certificatez
client-keyzinsecure-skip-tls-verifyztls-server-namez	proxy-url)rh   rstriphost
startswithr   r1   r'   r/   rS   r   __dict__rg   r   r   
verify_ssltls_server_nameproxy)r4   r   s     r   _load_cluster_infoz#KubeConfigLoader._load_cluster_infov  sv   t}$$h/66s;;DIy##G,, G //0BCC	#-M#:#,#'#7$9 $9 $9 :A   dm33 &0
$8'0'+';&= &= &= >EWYY N %/
L'0'+';%= %= %= >EWYY M &66"&-0J"KKDO--#'=1B#CD $-''{3DJJJ ('r%   c           	          d| j         v r| j        |j        d<   g d}|D ]*}|| j         v rt          ||t	          | |                     +d S )Nr   BearerToken)r   r   r   r   r   r   r   )r   r   api_keysetattrgetattr)r4   client_configurationkeyskeys       r   _set_configzKubeConfigLoader._set_config  sx    dm##:>* (7: : : 	G 	GCdm##,c743E3EFFF	G 	Gr%   c                    K   |                                   d {V  |                                  |                     |           d S r   )r   r   r   )r4   r   s     r   load_and_setzKubeConfigLoader.load_and_set  sW      '')))))))))!!!-.....r%   c                 0    d | j         d         D             S )Nc                     g | ]	}|j         
S r`   r   ).0rv   s     r   
<listcomp>z2KubeConfigLoader.list_contexts.<locals>.<listcomp>  s    FFF'FFFr%   ru   )re   r4   s    r   list_contextszKubeConfigLoader.list_contexts  s    FFT\*-EFFFFr%   c                     | j         j        S r   )rf   r   r   s    r   current_contextz KubeConfigLoader.current_context  s    $**r%   )NNr(   NNr   )r\   r]   r^   r;   rj   r   r   r   r   r   r   r   r   r   r   r   r   r   propertyr   r`   r%   r   rb   rb      s2       37(,"$"& $	0 0 0 00$ $ $ $4%% %% %%N  2  @; ; ;6  "! "! "!H      4 4 48
G 
G 
G/ / /
G G G + + X+ + +r%   rb   c                   :    e Zd ZdZd
dZd Zd Zd Zd Zdd	Z	dS )rd   zRemembers each config key's path and construct a relevant exception
    message in case of missing keys. The assumption is all access keys are
    present in a well-formed kube-config.Nc                 0    || _         || _        || _        d S r   )r*   r   r1   )r4   r*   r   r1   s       r   r;   zConfigNode.__init__  s    	
			r%   c                     || j         v S r   r   r4   r   s     r   __contains__zConfigNode.__contains__  s    dj  r%   c                 *    t          | j                  S r   )r?   r   r   s    r   __len__zConfigNode.__len__  s    4:r%   c                     t          | j        t                    rt          |t                    s| j        r|| j        v r| j        |         S d S d S r   )rG   r   listintr   s     r   r~   zConfigNode.safe_get  sZ    tz4(( 	#ZS-A-A 	#	# #tz 1 1:c?"	# 	# 1 1r%   c                     |                      |          }|t          d|d| j                  t          |t                    st          |t
                    r t          | j        d||| j                  S |S )Nz'Invalid kube-config file. Expected key  in r   )r~   r   r*   rG   dictr   rd   r1   )r4   r   vs      r   __getitem__zConfigNode.__getitem__  s    MM#9!/33		#$ $ $ a 	*Q"5"5 	CC8!TYGGGHr%   Fc                    t          | j        t                    st          d| j        z            d }| j        D ]I}d|vrt          d| j        z            |d         |k    r ||}.t          d|d| j        d          J|8t          |t
                    r|S t          | j        d|d|| j                  S |rd S t          d	|d| j        d          )
Nz2Invalid kube-config file. Expected %s to be a listr*   zKInvalid kube-config file. Expected all values in %s list to have 'name' keyz=Invalid kube-config file. Expected only one object with name r   z listz[name=]z4Invalid kube-config file. Expected object with name )rG   r   r   r   r*   rd   r1   )r4   r*   ry   resultr   s        r   r}   zConfigNode.get_with_name  sK   $*d++ 	!D)    	- 	-AQ%Ji ! ! ! yD  >FF)/  44,- - -	 ! &*-- :!YYY&'-ty: : :  	4o9=tyyyJK K 	Kr%   r   F)
r\   r]   r^   r_   r;   r   r   r~   r   r}   r`   r%   r   rd   rd     s        - -   
! ! !  # # #
	 	 	K K K K K Kr%   rd   c                   F    e Zd ZdZd Zed             Zd Zd Zd Z	d Z
dS )	KubeConfigMergera  Reads and merges configuration from one or more kube-config's.
    The propery `config` can be passed to the KubeConfigLoader as config_dict.
    It uses a path attribute from ConfigNode to store the path to kubeconfig.
    This path is required to load certs from relative paths.
    A method `save_changes` updates changed kubeconfig's (it compares current
    state of dicts with).
    c                    g | _         i | _        d | _        d}|                    t                    D ]s}|rot
          j                            |          }t
          j                            |          r1| j         	                    |           | 
                    |           d}tt          j        | j                  | _        |st                              d|           d S d S )NFTzConfig not found: %s)pathsconfig_filesconfig_mergedr   ENV_KUBECONFIG_PATH_SEPARATORr   r1   
expanduserexistsappendload_configcopydeepcopyconfig_savedr   warning)r4   r  file_loadedr1   s       r   r;   zKubeConfigMerger.__init__  s    
!KK =>> 	' 	'D 'w))$//7>>$'' 'J%%d+++$$T***"&K M$*;<< 	:NN1599999	: 	:r%   c                     | j         S r   )r	  r   s    r   r   zKubeConfigMerger.config  s    !!r%   c                    t          |          5 }t          j        |          }d d d            n# 1 swxY w Y   | j        4t	          j        |          }dD ]}g ||<   t          |||          | _        dD ]/}|                     ||                    |g           pg |           0d|v r|d         | j        j	        d<   || j
        |<   d S )N)rz   ru   rx   rt   )rE   yaml	safe_loadr	  r  r  rd   _merger   r   r  )r4   r1   rZ   r   r	  items         r   r  zKubeConfigMerger.load_config  s+   $ZZ 	'1^A&&F	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' % M&11M9 ) )&(d##!+D-!F!FD5 	@ 	@DKKfjjr228b$????&&:@AR:SD$%67"($s   155c           	          |D ]s}| j         j        |         D ]}|d         |d         k    r nI| j         j        |                             t          d                    ||          ||                     td S )Nr*   z{}/{})r	  r   r  rd   r   )r4   r  add_cfgr1   new_itemr  s         r   r  zKubeConfigMerger._merge  s     	E 	EH,248 E E&>Xf%555E 6 "(.55jNN422Hd7D 7D E E E	E 	Er%   c                     | j         D ]3}| j        |         | j        |         k    r|                     |           4t	          j        | j                  | _        d S r   )r  r  r  save_configr  r  )r4   r1   s     r   save_changeszKubeConfigMerger.save_changes'  s^    J 	' 	'D &$*;D*AAA  &&& M$*;<<r%   c                     t          |d          5 }t          j        | j        |         |d           d d d            d S # 1 swxY w Y   d S )NwF)default_flow_style)rE   r  	safe_dumpr  )r4   r1   rZ   s      r   r  zKubeConfigMerger.save_config-  s    $__ 	5N4,T2A.35 5 5 5	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s   #AAAN)r\   r]   r^   r_   r;   r   r   r  r  r  r  r`   r%   r   r  r    s         : : :" " " X") ) )$E E E= = =5 5 5 5 5r%   r  Fc                     t          |           }|rd|vr|                                |d<   t          d|j        d d|S )Nrr   )rn   rq   r`   )r  r  rb   r   )filenamepersist_configkwargskcfgs       r   %_get_kube_config_loader_for_yaml_filer)  3  si     H%%D 9,F::%)%6%6%8%8!" K    r%   c                     | $t           j                            t                    } t	          |           }|                                |j        fS r   )r   r1   r  KUBE_CONFIG_DEFAULT_LOCATIONr)  r   r   )config_fileloaders     r   list_kube_config_contextsr.  @  sE    g(()EFF2;??F!!6#999r%   Tc                   K   | t           } t          | |||          }|Ot                              t                    }|                    |           d{V  t	          j        |           n|                    |           d{V  |S )a`  Loads authentication and cluster information from kube-config file
    and stores them in kubernetes.client.configuration.

    :param config_file: Name of the kube-config file.
    :param context: set the active context. If is set to None, current_context
        from config file will be used.
    :param client_configuration: The kubernetes.client.Configuration to
        set configs to.
    :param persist_config: If True, config file will be updated when changed
        (e.g GCP token refresh).
    :param temp_file_path: directory where temp files are stored
        (default - system temp dir).
    N)ro   r&  r:   )r+  r)  type__call__r   r   set_default)r,  rv   r   r&  r:   r-  r   s          r   load_kube_configr3  I  s      $ 22G%%' ' 'F #}--!!&)))))))))!&))))!!"6777777777Mr%   c                   K   t          | d||          }|Ot                              t                    }|                    |           d{V  t          j        |           n|                    |           d{V  |S )a  Loads authentication and cluster information from config_dict
    and stores them in kubernetes.client.configuration.

    :param config_dict: Takes the config file as a dict.
    :param context: set the active context. If is set to None, current_context
        from config file will be used.
    :param client_configuration: The kubernetes_asyncio.client.Configuration to
        set configs to.
    :param temp_file_path: directory where temp files are stored
        (default - system temp dir).
    N)rn   rq   ro   r:   )rb   r0  r1  r   r   r2  )rn   rv   r   r:   r-  r   s         r   load_kube_config_from_dictr5  l  s       %	' ' 'F #}--!!&)))))))))!&))))!!"6777777777Mr%   <   c                 X  K   |t           | j        dk    rE	 t          j        |           d{V  |                                  d{V  | j        |j        d<   Dd| j        v rE	 t          j        |           d{V  |                                  d{V  | j        |j        d<   DdS )a-  Refresh token if necessary, updates the token in client configurarion

    :param loader: KubeConfigLoader returned by load_kube_config
    :param client_configuration: The kubernetes.client.Configuration to
            set configs to.
    :param interval: how often check if token is up-to-date

    Nr   r   r   r   )	NotImplementedErrorri   r   sleepr   r   r   rg   r   )r-  r   intervals      r   r   r     s       #!!%	G-)))))))))''))))))))):@, (7	G 
6<			G-)))))))))..000000000:@, (7	G 
 	r%   c                    K   t                               t                    }t          | ||||           d{V  t	          |          S )zLoads configuration the same as load_kube_config but returns an ApiClient
    to be used with any API object. This will allow the caller to concurrently
    talk with multiple clusters.)r,  rv   r   r&  r:   Nconfiguration)r0  r1  r   r3  r   )r,  rv   r&  r:   client_configs        r   new_client_from_configr?    sn      
 MM-00M
{G0=*8*8: : : : : : : : : :
 =1111r%   c                    K   t                               t                    }t          | |||           d{V  t	          |          S )zLoads configuration the same as load_kube_config_dict but returns an ApiClient
    to be used with any API object. This will allow the caller to concurrently
    talk with multiple clusters.)rn   rv   r   r:   Nr<  )r0  r1  r   r5  r   )rn   rv   r:   r>  s       r   new_client_from_config_dictrA    su      
 MM-00M
$g:G4BD D D D D D D D D D =1111r%   r  r   )NNNTN)NNN)Nr6  )NNTN)7r   r@   rO   r  r    r   loggingr   pathlibplatformrC   r  kubernetes_asyncio.clientr   r   config_exceptionr   dateutilr   r   exec_providerr	   google_authr
   openidr   	timedeltar   environr   Pathhomeas_posixr+  systemr
  r   r   	getLoggerr\   r   r   r$   objectr'   rb   rd   r  r)  r.  r3  r5  r   r?  rA  r`   r%   r   <module>rS     s'          				     > > > > > > > > - - - - - - ( ( ( ( ( ( ( ( ' ' ' ' ' ' 0 0 0 0 0 0 # # # # # #1x1!<<< !z~~lW\=N=N=P=PSa=a<k<k<m<mnn '6x'8'8I'E'E3  		8	$	$  ? ? ?
F F F F F F F FRc+ c+ c+ c+ c+v c+ c+ c+L	?K ?K ?K ?K ?K ?K ?K ?KDC5 C5 C5 C5 C5 C5 C5 C5N "'
 
 
 
: : : : 6:04*.*.       F ;?:>48   >G G G G2 QU042 2 2 2 AE592 2 2 2 2 2r%   