
    {                     P   d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ ddlm	Z ddlmZ ddlmZ dZej*                  ej,                   ej.                  ej0                  j2                         G d dej4                                             Zy)zHA docker credential helper that provides credentials for GCR registries.    )absolute_import)division)unicode_literalsN)base)
exceptions)log)
properties)creds)store)credential_utils3300sc                   .    e Zd ZdZdZdZed        Zd Zy)DockerHelperzAA Docker credential helper to provide access to GCR repositories.getlistc                 `    | j                  dd       | j                  j                  d       y )Nmethodz$The docker credential helper method.)helpjson)add_argumentdisplay_info	AddFormat)parsers    !lib/surface/auth/docker_helper.pyArgszDockerHelper.Args.   s*    
'MN
!!&)    c                    |j                   t        j                  k(  r&t        j                         D ci c]  }d|z   d
 c}S |j                   t        j
                  k(  r	 t        j                  d      }t        j                  t               t        j                   j#                         j%                         }t&        j(                  j*                  j,                  j/                         sL|j1                  ddd      t        j2                         vr%t5        j6                  d	j9                  |
            t;        j<                  |      r|j>                  n|j@                  }|ddS |jC                         jE                  d       yc c}w # t        j                  $ r. t        j                  d       t        j                  d       Y \w xY w)zRun the helper command.zhttps://_dcgcloud_tokenT)use_google_authz}You do not currently have an active account selected. See https://cloud.google.com/sdk/docs/authorizing for more information.   )window z'Repository url [{url}] is not supported)url)SecretUsernamenoneN)#r   r   LISTr   DefaultAuthenticatedRegistriesGETc_storeLoadcreds_exceptionsNoActiveAccountExceptionr   PrintsysexitRefreshIfExpireWithinWindowTOKEN_MIN_LIFETIMEstdinreadstripr	   VALUES	artifactsallow_unrecognized_registryGetBoolreplaceSupportedRegistriesr   Errorformatc_credsIsGoogleAuthCredentialstokenaccess_tokenGetDisplayInfor   )selfargsr#   credr@   s        r   RunzDockerHelper.Run4   s    {{l''' &DDF
 Gc //F  
((	(||D1 ))$7IJIINN""$c((DDLLNKK
B"2"F"F"HI  7>>3>GI I ,,T2 **8<8I8I 
 '  	##F+U 66 		 ! 	" 		s   F#F =GGN)	__name__
__module____qualname____doc__r)   r'   staticmethodr   rF    r   r   r   r   %   s)     J#	$* *
.r   r   )rJ   
__future__r   r   r   r/   googlecloudsdk.callioper   googlecloudsdk.corer   r   r	   googlecloudsdk.core.credentialsr
   r>   r,   r   r*   googlecloudsdk.core.dockerr   r2   HiddenUniverseCompatibleReleaseTracksReleaseTrackGACommandr   rL   r   r   <module>rX      s     O &  ' 
 ( * # * < J < 7   D%%(():4<< : *  :r   