
    o9is                     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                   0    e Zd ZdZddZe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
    Nc                    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                  |       |j                  d	      r|| _
        nd
| _
        |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valueprovideClusterInfoN)r   api_versionr
   safe_getextendosenvironcopyr   updateclustercwd)	selfexec_configr   r   keyadditional_varsitemr   r   s	            h/var/www/html/leadgen/airagagent/rag_env/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, 45"DLDL;$    c                 &    t         j                  dv S )N)win32cygwin)sysplatform)r   s    r   shellzExecProvider.shell>   s     ||222r   c           
         t        t        j                  d      xr t        j                  j                         }| j                  dd|id}|r||d   d<   | j
                  rw| j
                  j                  |d   d<   | j
                  j                  j                  d      r6| j
                  j                  d   D ]  }|d	   d
k(  s|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$                        }|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 # t0        $ r}t-        d|z        d }~ww xY w)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   sP    X6N3::;L;L;N**$~ 
 7H (4<<6:ll6H6H (3||!!%%l3!%!3!3L!A I (,OOLUVaLb,V4Y?I
 ,0::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   H7 7	I II)N)__name__
__module____qualname____doc__r   propertyr%   rJ    r   r   r   r      s%    	8 3 32r   r   )r8   r   r:   r#   config_exceptionr   objectr   rP   r   r   <module>rS      s$     	  
 -c6 cr   