
    Ig                     F    d dl Z d dlZd dlZd dlZddlmZ  G d de      Zy)    N   )ConfigExceptionc                       e Zd ZdZd ZddZy)ExecProvidera,  
    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                    dD ]  }||vst        d|z         |d   | _        |d   g| _        |j                  d      r| j                  j	                  |d          t
        j                  j                         | _        |j                  d      r6i }|d   D ]  }|d   }|d   }|||<    | j                  j                  |       |xs d	| _
        y	)
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cwd)selfexec_configr   keyadditional_varsitemr   r   s           \/var/www/html/answerous/venv/lib/python3.12/site-packages/kubernetes/config/exec_provider.py__init__zExecProvider.__init__"   s     - 	IC+%%ACGI I	I '|4 +,	'II[01::??$& O#E* .F|W(-%. HHOOO,;$    Nc           	         t        t        j                  d      xr t        j                  j                         }| j                  dd|id}|r||d   d<   t        j                  |      | j                  d<   t        j                  | j                  t        j                  |rt        j                  nt        j                  |rt        j                  nd | j                  | j                  d	      }|j                         \  }}|j!                         }|d
k7  r*d|z  }|j#                         }|r|d|z  z  }t%        |      	 t        j&                  |      }	dD ]  }||	vst%        d|z         |	d   | j                  k7  rt%        d|	d   d| j                        |	d   S # t(        $ r}
t%        d|
z        d }
~
ww xY w)NisattyExecCredentialinteractive)r	   kindspecr#   responseKUBERNETES_EXEC_INFOT)stdoutstderrstdinr   r   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*   )hasattrsysr&   r   r   jsondumpsr   
subprocessPopenr
   PIPEr'   r(   r   communicatewaitstripr   loads
ValueError)r   previous_responseis_interactivekubernetes_exec_infoprocessr&   r'   	exit_codemsgdatader   s               r   runzExecProvider.run;   s    X6N3::;L;L;N**$~ 
 7H (4+/::6J+K'(""II??!/3::Z__-#))4#% #..0LLN	>-	9C\\^Fv&!#&&	B::f%D 4 	JC$%BSHJ J	J !1!11!l#T%5%578 8 H~  	B!;b@B B	Bs   F) )	G2G  G)N)__name__
__module____qualname____doc__r   r?    r   r   r   r      s    	2)r   r   )r-   r   r/   r,   config_exceptionr   objectr   rD   r   r   <module>rG      s$     	  
 -N6 Nr   