
                             d 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  G d
 de
j                        Zy)zList images command.    )absolute_import)division)unicode_literals)docker_image)util)base)log)
propertiesc                   D     e Zd ZdZdddZed        Zd Zd fd	Z xZ	S )	ListzList existing images.z          The container images list command of gcloud lists metadata about
          existing container images in a specified repository. Repositories
          must be hosted by the Google Container Registry.
      a8            List the images in a specified repository:

            $ {command} --repository=gcr.io/myproject

          List the images in the default repository:

            $ {command}

          List images with names prefixed with 'test-project':

            $ {command} --filter="name:test-project"

      )DESCRIPTIONEXAMPLESc                 b    | j                  ddd       | j                  j                  d       y)zRegister flags for this command.

    Args:
      parser: An argparse.ArgumentParser-like object. It is mocked out in order
        to capture some information, but behaves like an ArgumentParser.
    z--repositoryFznThe name of the repository. Format: *.gcr.io/repository. Defaults to gcr.io/<project>, for the active project.)requiredhelpztable(name)N)add_argumentdisplay_info	AddFormat)parsers    $lib/surface/container/images/list.pyArgsz	List.Args7   s:     F  H
 !!-0    c           	        	 |j                   }d| _        |st        j                  j                  j
                  j                  d      }|j                  ddd      }dj                  |      }dj                  |      | _        | xj                  d	z  c_        t        j                  |      		fd
}t        j                         }t        j                  	      5  t        j                  t        j                         	|      5 }|j!                         D cg c]  }d ||      i }}|cddd       cddd       S c c}w # 1 sw Y   nxY w	 ddd       y# 1 sw Y   yxY w)a  This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.

    Raises:
      exceptions.Error: If the repository could not be found, or access was
      denied.
      docker_http.V2DiagnosticException: Any other error occurred while
      accessing GCR.
    NT)r   :/   z
gcr.io/{0}zOnly listing images in {0}. z6Use --repository to list images in other repositories.c                 (    dj                  |       S )z!Display the fully-qualified name.z{0}/{1})format)c
repositorys    r   _DisplayNamezList.Run.<locals>._DisplayNamec   s    j!,,r   )basic_credsname	transportr#   )r    _epilogr
   VALUEScoreprojectGetreplacer   r   ValidateRepositoryPathHttpWrapExpectedDockerlessErrorsr   FromRegistryCredentialProviderchildren)
selfargsrepository_arg
project_idr!   http_objrr   imagesr    s
            @r   RunzList.RunF   s3     __NDL$$))1155t5Dj%%c32j#**:6n3::>Jdl
llNNl ,,^<J- yy{H		*	*:	6$$--/ "#56ZZ\B\6<?+\B  
7	6
 C	   
7	6	6s6   +EEE,E/	EEE	EE&c                     t         t        |   |       | j                  r*t        j
                  j                  | j                         y y )N)superr   Epilogr%   r	   statusPrint)r1   resources_were_displayed	__class__s     r   r;   zList.Epilogp   s5    	$56||	jjt||$ r   )T)
__name__
__module____qualname____doc__detailed_helpstaticmethodr   r8   r;   __classcell__)r?   s   @r   r   r      s;    

-0 1 1(T% %r   r   N)rC   
__future__r   r   r   containerregistry.client.v2_2r   'googlecloudsdk.api_lib.container.imagesr   googlecloudsdk.callioper   googlecloudsdk.corer	   r
   ListCommandr    r   r   <module>rN      s6     &  ' 6 8 ( # *X%4 X%r   