o
    .&ßaé  ã                   @   s`   d dl mZ d dlmZ d dlmZ d dlZdd„ Zdd„ ZG d	d
„ d
eƒZ	G dd„ deƒZ
dS )é    )ÚBasicCommand)Ú!create_client_from_parsed_globals)Ú	b64decodeNc                 C   s   |   dt¡ d S )Nzbuilding-command-table.ecr)ÚregisterÚ_inject_commands)Úcli© r   ú;/usr/lib/python3/dist-packages/awscli/customizations/ecr.pyÚregister_ecr_commands   s   r
   c                 K   s   t |ƒ| d< t|ƒ| d< d S )Nú	get-loginúget-login-password)ÚECRLoginÚECRGetLoginPassword)Úcommand_tableÚsessionÚkwargsr   r   r	   r      s   r   c                
   @   sZ   e Zd ZdZdZe d¡Zdddddœd	d
d	dddddœddddd	dddœgZdd„ Z	dS )r   zLog in with 'docker login'r   zecr/get-login_description.rstzregistry-idszbA list of AWS account IDs that correspond to the Amazon ECR registries that you want to log in to.Fú+)ÚnameÚ	help_textÚrequiredÚnargszinclude-emailÚ
store_trueÚinclude_emailTaE  Specify if the '-e' flag should be included in the 'docker login' command.  The '-e' option has been deprecated and is removed in Docker version 17.06 and later.  You must specify --no-include-email if you're using Docker version 17.06 or later.  The default behavior is to include the '-e' flag in the 'docker login' output.)r   ÚactionÚ
group_nameÚdestÚdefaultr   r   zno-include-emailzInclude email argÚstore_false)r   r   r   r   r   r   r   c           
      C   s¬   t | jd|ƒ}|js| ¡ }n|j|jd�}|d D ]9}t|d ƒ ¡ }| d¡\}}ddd|d	|g}	|jr=|	 d
dg¡ |	 	|d ¡ t
j d |	¡¡ t
j d¡ qdS )NÚecr)ÚregistryIdsÚauthorizationDataÚauthorizationTokenú:ÚdockerÚloginz-uz-pz-eÚnoneÚproxyEndpointú Ú
r   )r   Ú_sessionÚregistry_idsÚget_authorization_tokenr   ÚdecodeÚsplitr   ÚextendÚappendÚsysÚstdoutÚwriteÚjoin)
ÚselfÚparsed_argsÚparsed_globalsÚ
ecr_clientÚresultÚauthÚ
auth_tokenÚusernameÚpasswordÚcommandr   r   r	   Ú	_run_mainE   s$   ÿ
ÿzECRLogin._run_mainN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚNAMEr   Ú	FROM_FILEÚDESCRIPTIONÚ	ARG_TABLEr>   r   r   r   r	   r      s6    
ûøùé"r   c                   @   s&   e Zd ZdZdZe d¡Zdd„ ZdS )r   z?Get a password to be used with container clients such as Dockerr   z&ecr/get-login-password_description.rstc           	      C   s\   t | jd|ƒ}| ¡ }|d d }t|d ƒ ¡ }| d¡\}}tj |¡ tj d¡ dS )Nr   r    r   r!   r"   r(   )	r   r)   r+   r   r,   r-   r0   r1   r2   )	r4   r5   r6   r7   r8   r9   r:   Ú_r<   r   r   r	   r>   `   s   ýzECRGetLoginPassword._run_mainN)	r?   r@   rA   rB   rC   r   rD   rE   r>   r   r   r   r	   r   Y   s    ÿr   )Úawscli.customizations.commandsr   Úawscli.customizations.utilsr   Úbase64r   r0   r
   r   r   r   r   r   r   r	   Ú<module>   s   <