
    Zis                     N    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dS )    N   )ConfigExceptionc                   8    e Zd ZdZddZed             ZddZdS )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
    Nc                    dD ]}||vrt          d|z            |d         | _        |d         g| _        |                    d          r | j                            |d                    t
          j                                        | _        |                    d          r<i }|d         D ]}|d         }|d         }|||<   | j        	                    |           |                    d	          r|| _
        nd
| _
        |pd
| _        d
S )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valueprovideClusterInfoN)r   api_versionr
   safe_getextendosenvironcopyr   updateclustercwd)	selfexec_configr   r   keyadditional_varsitemr   r   s	            Z/root/projects/butler/venv/lib/python3.11/site-packages/kubernetes/config/exec_provider.py__init__zExecProvider.__init__"   s<    - 	I 	IC+%%%ACGI I I & '|4 +,	'' 	2I[0111:??$$&& 	- O#E* . .F|W(-%%HOOO,,, 455 	 "DLLDL;$    c                     t           j        dv S )N)win32cygwin)sysplatform)r   s    r   shellzExecProvider.shell>   s     |222r   c           
      j   t          t          j        d          ot          j                                        }| j        dd|id}|r||d         d<   | j        rn| j        j        |d         d<   | j        j                            d          r:| j        j        d         D ]'}|d	         d
k    r|d         |d         d         d<    n(t          j	        |          | j
        d<   t          j        | j        t          j        |rt          j        nt          j        |rt          j        nd | j        | j
        d| j                  }|                                \  }}|                                }|dk    r2d|z  }	|                                }|r|	d|z  z  }	t-          |	          	 t          j        |          }
n$# t0          $ r}t-          d|z            d }~ww xY wdD ]}||
vrt-          d|z            |
d         | j        k    r t-          d|
d         d| j                  |
d         S )NisattyExecCredentialinteractive)r	   kindspecr+   responser   
extensionsr   z!client.authentication.k8s.io/exec	extensionconfigKUBERNETES_EXEC_INFOT)stdoutstderrstdinr   r   universal_newlinesr%   r   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 r5   )hasattrr#   r1   r'   r   r   r   getjsondumpsr   
subprocessPopenr
   PIPEr2   r3   r   r%   communicatewaitstripr   loads
ValueError)r   previous_responseis_interactivekubernetes_exec_infor.   processr1   r2   	exit_codemsgdatader   s                r   runzExecProvider.runG   s    X66N3:;L;L;N;N*$~ 
  
  	I7H (4< 	6:l6H (3|!%%l33 !%!3L!A  I (,OOOLUVaLb,V4Y?I P ,0:6J+K+K'("I?!/D3::Z_-7#))4#*   #..00LLNN	>>-	9C\\^^F 'v&!#&&&	B:f%%DD 	B 	B 	B!;b@B B B	B 4 	J 	JC$%BSHJ J J  !111!/l###T%5%578 8 8 H~s   (F= =
GGG)N)__name__
__module____qualname____doc__r   propertyr%   rJ    r   r   r   r      sa        	 	   8 3 3 X32 2 2 2 2 2r   r   )r8   r   r:   r#   config_exceptionr   objectr   rP   r   r   <module>rS      s~     				     



 - - - - - -c c c c c6 c c c c cr   