o
    g                     @   s@   d dl Z d dlZd dlZd dlZddlmZ G dd deZdS )    N   )ConfigExceptionc                   @   s$   e Zd ZdZdddZd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           	      C   s   dD ]}||vrt d| q|d | _|d g| _|dr'| j|d  tj | _|drMi }|d D ]}|d }|d }|||< q8| j	| |d	rV|| _
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
    r   V/var/www/visachat/venv/lib/python3.10/site-packages/kubernetes/config/exec_provider.py__init__"   s,   




zExecProvider.__init__c              
   C   sV  t tjdo
tj }| jdd|id}|r||d d< | jr&| j|d d< t|| jd< t	j
| jt	j|r9tjnt	j|r@tjnd | j| jd	d	d
}| \}}| }|dkrld| }| }|rh|d| 7 }t|zt|}	W n ty }
 ztd|
 d }
~
ww dD ]}||	vrtd| q|	d | jkrtd|	d | jf |	d S )NisattyExecCredentialinteractive)r   kindspecr!   responser   KUBERNETES_EXEC_INFOT)stdoutstderrstdinr   r   universal_newlinesshellr   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 %s does not match %sr)   )hasattrsysr$   r   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   r   r   r   run>   sd   	zExecProvider.run)N)__name__
__module____qualname____doc__r   r>   r   r   r   r   r      s    
r   )r,   r   r.   r+   config_exceptionr   objectr   r   r   r   r   <module>   s   