
                          H   S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	  SS	K
Jr  SS
KJr  SSKJr  SSKJr  \R"                  rSr\R(                  " \R*                  R,                  5      \R.                  " S\S9 " S S\R0                  5      5       5       rg)zEnable Docker CLI access to Google Container Registry.

Sets Docker up to authenticate with Container Registry,
and passes all flags after `--` to the Docker CLI.
    )absolute_import)division)unicode_literalsN)arg_parsers)base)
exceptions)log)
client_lib)	constants)dockera  `gcloud docker` will not be supported for Docker client versions above 18.03.

As an alternative, use `gcloud auth configure-docker` to configure `docker` to
use `gcloud` as a credential helper, then use `docker` as you would for non-GCR
registries, e.g. `docker pull gcr.io/project-id/my-image`. Add
`--verbosity=error` to silence this warning: `gcloud docker
--verbosity=error -- pull gcr.io/project-id/my-image`.

See: https://cloud.google.com/container-registry/docs/support/deprecation-notices#gcloud-docker
F)
is_removedwarningc                   J    \ rS rSrSrS\R                  0r\S 5       r	S r
Srg)Docker6   ae  Enable Docker CLI access to Google Container Registry.

{command} wraps Docker commands so that `gcloud` can
inject the appropriate fresh authentication token into requests that interact
with the Docker registry.

All Docker-specific flags are passed through to the underlying `docker`
command. A full reference of Docker's command line options available after
`--` can be found here:
[](https://docs.docker.com/engine/reference/commandline/cli/). You may also
run `{command} -- --help` to view the Docker CLI's help directly.

Detailed documentation on Container Registry can be found here:
[](https://cloud.google.com/container-registry/docs/)

## EXAMPLES

To pull the image '{registry}/google-containers/pause:1.0' from the docker
registry, run:

```
{command} -- pull {registry}/google-containers/pause:1.0
```

Push the image '{registry}/example-org/example-image:latest' to our private
docker registry.

```
{command} -- push {registry}/example-org/example-image:latest
```

Configure authentication, then simply use docker:

```
{command} --authorize-only
docker push {registry}/example-org/example-image:latest
```

registryc           
          U R                  SS[        R                  " SS9SSS[        S9  U R                  S	S
SSS9  U R                  SSS9  U R                  S[        R
                  / SS9  g )Nz--serverz-s   )
min_lengthSERVERz%Address of the Google Cloud Registry.F)typemetavarhelprequireddefaultz--authorize-onlyz-azKConfigure Docker authorization only; do not launch the Docker command-line.
store_true)r   actionz--docker-hostzSURL to connect to Docker Daemon. Format: tcp://host:port or unix:///path/to/socket.)r   docker_argszArguments to pass to Docker.)nargsr   r   )add_argumentr   ArgList_DEFAULT_REGISTRIESargparse	REMAINDER)parsers    lib/surface/docker.pyArgsDocker.Argse   s    
D  A.4#  % D	   "  #
 X//+  -    c                    UR                   (       a  [        R                  " S5        [        R                  " 5          SnUR
                   HF  nU[        ;  a#  [        R                  " SR                  US95        [        R                  " X2S9  SnMH     UR                  (       a@  [        R                  R                  SR                  UR
                  S95         SSS5        gUR                  =(       d    / nUR                  (       d  UOS	UR                  /U-   n[        R                   " U5      nU(       a  ["        R$                  " US
9e SSS5        g! , (       d  f       g= f)a  Executes the given docker command, after refreshing our credentials.

Args:
  args: An argparse.Namespace that contains the values for
     the arguments specified in the .Args() method.

Raises:
  exceptions.ExitCodeNoError: The docker command execution failed.
zDocker uses the account from the gcloud config.To set the account in the gcloud config, run `gcloud config set account <account_name>`.Tz1Authenticating to a non-default server: {server}.)server)refreshFz+Short-lived access for {server} configured.Nz-H)	exit_code)accountr	   r   r   WithLegacyQuotar+   r"   formatr   UpdateDockerCredentialsauthorize_onlyerrPrintr   docker_hostdocker_client_utilsExecuter   ExitCodeNoError)selfargsforce_refreshr+   r   results         r&   Run
Docker.Run}   s3    || 
kk @ A 
			mKK&,,
++AHH I !" 	&&vE   
		
 	CJJ;; K   	!% 
 	( $$*k!--+D$:J:J3K
4  #**;7f 
((6::= 
 		s   B!E'A+E
E) N)__name__
__module____qualname____firstlineno____doc__r   DEFAULT_REGISTRYdetailed_helpstaticmethodr'   r=   __static_attributes__r?   r)   r&   r   r   6   s5    &R ),,- - -.2r)   r   )rD   
__future__r   r   r   r#   googlecloudsdk.callioper   r   r   googlecloudsdk.corer	   googlecloudsdk.core.dockerr
   r6   r   r   "DEFAULT_REGISTRIES_TO_AUTHENTICATEr"   _DEPRECATION_WARNINGReleaseTracksReleaseTrackGA	DeprecateCommandr   r?   r)   r&   <module>rT      s     '  '  / ( . # H 0 -  BB 
  D%%(()5*>?wT\\ w @ *wr)   