
    q                     d    S SK r S SKrS SKrS SKrS SKrSSKJr  SSKJr  SSKJ	r	   " S S5      r
g)    N   )	constants)errors)create_environment_dictc                   <    \ rS rSrS
S jrS rS rS rS rS r	S	r
g)Store   Nc                    [         R                  U-   U l        [        R                  " U R                  5      U l        X l        U R
                  c0  [        R                  " SR                  U R                  5      5        gg)zCreate a store object that acts as an interface to
perform the basic operations for storing, retrieving
and erasing credentials using `program`.
N){} not installed or not available in PATH)
r   PROGRAM_PREFIXprogramshutilwhichexeenvironmentwarningswarnformat)selfr   r   s      +lib/third_party/docker/credentials/store.py__init__Store.__init__   s`    
 !//'9<<-&88MM;BBLL     c                 *   [        U[        5      (       d  UR                  S5      nU R                  SU5      n[        R
                  " UR                  S5      5      nUS   S:X  a,  US   S:X  a#  [        R                  " SU R                   35      eU$ )z_Retrieve credentials for `server`. If no credentials are found,
a `StoreError` will be raised.
utf-8getUsername SecretzNo matching credentials in )

isinstancebytesencode_executejsonloadsdecoder   CredentialsNotFoundr   )r   serverdataresults       r   r   	Store.get   s     &%((]]7+F}}UF+DKK01 *#x(8B(>,,-dll^<  r   c                 x    [         R                  " UUUS.5      R                  S5      nU R                  SU5      $ )zJStore credentials for `server`. Raises a `StoreError` if an error
occurs.
)	ServerURLr   r   r   store)r$   dumpsr"   r#   )r   r(   usernamesecret
data_inputs        r   r.   Store.store0   sA     ZZ !
  6'?	 	
 }}Wj11r   c                 t    [        U[        5      (       d  UR                  S5      nU R                  SU5        g)zJErase credentials for `server`. Raises a `StoreError` if an error
occurs.
r   eraseN)r    r!   r"   r#   )r   r(   s     r   r5   Store.erase;   s-     &%((]]7+Fgv&r   c                 p    U R                  SS5      n[        R                  " UR                  S5      5      $ )zAList stored credentials. Requires v0.4.0+ of the helper.
        listNr   )r#   r$   r%   r&   )r   r)   s     r   r8   
Store.listC   s,     }}VT*zz$++g.//r   c                    U R                   c/  [        R                  " SR                  U R                  5      5      eS n[        U R                  5      n [        R                  " U R                   U/X$S9nU$ ! [        R                   a%  n[        R                  " XPR                  5      eS nAf[         a  nUR                  [        R                  :X  a/  [        R                  " SR                  U R                  5      5      e[        R                  " SR                  UR                  UR                  5      5      eS nAff = f)Nr   )inputenvz"Unexpected OS error "{}", errno={})r   r   
StoreErrorr   r   r   r   
subprocesscheck_outputCalledProcessErrorprocess_store_errorOSErrorerrnoENOENTstrerror)r   subcmdr2   outputr<   es         r   r#   Store._executeI   s   88##?FF 
 %d&6&67	,,6"*F$  ,, 	>,,Q== 	ww%,,&''?FF  ''8??

AGG 	s%   !A8 8E B,,E9BE  E)r   r   r   )N)__name__
__module____qualname____firstlineno__r   r   r.   r5   r8   r#   __static_attributes__ r   r   r   r      s     (	2'0r   r   )rC   r$   r   r>   r   r   r   r   utilsr   r   rO   r   r   <module>rQ      s)           *Y Yr   