
                         F    S SK r S SKrS SKrS SKrSSKJr   " S S\5      rg)    N   )ConfigExceptionc                   (    \ rS rSrSrS rSS jrSrg)ExecProvider   a  
Implementation of the proposal for out-of-tree client
authentication providers as described here --
https://github.com/kubernetes/community/blob/master/contributors/design-proposals/auth/kubectl-exec-plugins.md

Missing from implementation:

* TLS cert support
* caching
c                    S H  nX!;  d  M
  [        SU-  5      e   US   U l        US   /U l        UR                  S5      (       a  U R                  R	                  US   5        [
        R                  R                  5       U l        UR                  S5      (       a8  0 nUS    H  nUS   nUS   nXcU'   M     U R                  R                  U5        g	g	)
z
exec_config must be of type ConfigNode because we depend on
safe_get(self, key) to correctly handle optional exec provider
config parameters.
)command
apiVersionz)exec: malformed request. missing key '%s'r
   r	   argsenvnamevalueN)
r   api_versionr   safe_getextendosenvironcopyr   update)selfexec_configkeyadditional_varsitemr   r   s          2lib/third_party/kubernetes/config/exec_provider.py__init__ExecProvider.__init__$   s     )		K!" # 	# ) #<0DY'(DIF##
ii{6*+zz DHE""oe$$F|W % % hhooo& #    Nc                    U R                   SS[        R                  R                  5       0S.nU(       a  XS   S'   [        R
                  " U5      U R                  S'   [        R                  " U R                  [        R                  [        R                  U R                  SS9nUR                  5       u  pEUR                  5       nUS	:w  a/  S
U-  nUR                  5       nU(       a  USU-  -  n[        U5      e [        R                  " U5      nS H  n
X;  d  M
  [        SU
-  5      e   US   U R                   :w  a   [        SUS   < SU R                   < 35      eUS   $ ! [          a  n	[        SU	-  5      eS n	A	ff = f)NExecCredentialinteractive)r
   kindspecr#   responseKUBERNETES_EXEC_INFOT)stdoutstderrr   universal_newlinesr   zexec: process returned %dz. %sz)exec: failed to decode process output: %s)r
   r"   statusz*exec: malformed response. missing key '%s'r
   zexec: plugin api version z does not match r)   )r   sysr&   isattyjsondumpsr   
subprocessPopenr   PIPEcommunicatewaitstripr   loads
ValueError)r   previous_responsekubernetes_exec_infoprocessr&   r'   	exit_codemsgdatader   s              r   runExecProvider.run;   s   && 3::,,.
 1B6":.'+zz2F'GDHH#$		HH!G **,VIA~')3c||~f	vC  NZZd 0	L!" # 	# 0 LT---!,/1A1AC D D>  NG"LMMNs    E* *
F4FF)r   r   r   )N)__name__
__module____qualname____firstlineno____doc__r   r=   __static_attributes__ r   r   r   r      s    	'.$r   r   )r,   r   r.   r*   config_exceptionr   objectr   rE   r   r   <module>rH      s$      	  
 -G6 Gr   