
    Z                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ej                   ej                  ej                  j                         G d dej                                      Zy)	z8Implements commands for the GOAUTH environment variable.    )base)endpoint_util)go_util)logc                   0    e Zd ZdZdddZed        Zd Zy)Autha\  Print authentication commands for the GOAUTH environment variable.

  This command implements the GOAUTH credential provider command introduced in
  Go 1.24. For more details about the GOAUTH environment variable, see
  https://pkg.go.dev/cmd/go#hdr-GOAUTH_environment_variable.  When you configure
  the GOAUTH environment variable for repositories, Artifact Registry looks for
  credentials in the following order:

  * Application Default Credentials (ADC)
  * Credentials provided by the Google Cloud CLI, including user credentials
      from the command `gcloud auth application-default login`.

  z{description}a      To configure the GOAUTH environment variable for repositories in `us-central1` and use your credentials:

        $ export GOAUTH="{command} --location=us-central1"

    To configure the GOAUTH environment variable for repositories in `us-central1` and use the credentials from a service account:

        $ export GOAUTH="{command} --location=us-central1 --json-key=path/to/key.json"
    )DESCRIPTIONEXAMPLESc                 ~    | j                  ddd       | j                  dddd	       | j                  d
dd       y)z\Set up arguements for this command.

    Args:
      parser: An argparse.ArgumentPaser.
    url*z/A URL generated by Go to set up authentication.)nargshelpz
--locationLOCATIONTz5The location of the repository to print commands for.)metavarrequiredr   z
--json-keyJSON_KEYzThe path to the JSON key file to use for authentication. If not specified, the authentication commands printed will use the token from the logged in user.)r   r   N)add_argument)parsers     lib/surface/artifacts/go/auth.pyArgsz	Auth.Args7   sa     >  
 D	   (	      c                    t        j                  |j                  ddd      }t        j                  |j
                        }t        j                  j                  |       t        j                  j                  d       t        j                  j                  |       t        j                  j                  d       y)zRun the go goauth command.goFhttps)repprotocol N)	r   ArtifactRegistryDomainEndpointlocationr   AuthorizationHeaderjson_keyr   outPrint)selfargsurl_lineheader_lines       r   RunzAuth.RunV   sw     ;;tH --dmm<KGGMM(GGMM"GGMM+GGMM"r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r)    r   r   r   r      s1      	-  <
r   r   N)r-   googlecloudsdk.callioper   $googlecloudsdk.command_lib.artifactsr   r   googlecloudsdk.corer   DefaultUniverseOnlyReleaseTracksReleaseTrackGACommandr   r0   r   r   <module>r9      s_    ? ( > 8 # D%%(()G4<< G * Gr   