o
    !d                     @   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.10/site-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)Zcommand_tableZ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)ZregistryIdsauthorizationDataauthorizationToken:ZdockerZloginz-uz-pz-enoneZproxyEndpoint 
r   )r   _sessionZ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DESCRIPTIONZ	ARG_TABLEr7   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&   r)   r*   r+   )	r-   r.   r/   r0   r1   r2   r3   _r5   r   r   r	   r7   `   s   zECRGetLoginPassword._run_mainN)	r8   r9   r:   r;   r<   r   r=   r>   r7   r   r   r   r	   r   Y   s    r   )Zawscli.customizations.commandsr   Zawscli.customizations.utilsr   base64r   r)   r
   r   r   r   r   r   r   r	   <module>   s   <