
    h0                        S 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 r	\R                  \R                  " \R                  R                  5       " S S	\R                  5      5       5       r\R                  " \R                  R                   5       " S
 S\5      5       r\R                  " \R                  R$                  5       " S S\5      5       rg)zSubmit build command.    N)cloudbuild_util)base)flags)submit_utilc                 h   U R                  5       nUR                  SSSSS9  UR                  SSSS	9  [        R                  " U 5        [        R                  " U 5        [        R
                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5      n[        R                  " U 5        [        R                  " U 5        [        R                   " U 5        U R"                  R%                  S
5        U R"                  R'                  S5        [        R(                  " U 5        [        R*                  " U 5        U R                  SSS9  U R                  SSS9  U R                  S[,        R.                  " S5      S9  U R                  S[,        R.                  " S5      S9  U$ )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.

Returns:
  worker pool flag group
source?.a   The location of the source to build. The location can be a directory on a local disk, an archive file (e.g., .zip, .tar.gz) or a manifest file (.json) in Google Cloud Storage, a Git repo url starting with http:// or https://, a 2nd-gen Cloud Build repository resource, or a Developer Connect GitRepositoryLink resource. If the source is a local directory, this command skips the files specified in the `--ignore-file`. If `--ignore-file` is not specified, use`.gcloudignore` file. If a `.gcloudignore` file is absent and a `.gitignore` file is present in the local source directory, gcloud will use a generated Git-compatible `.gcloudignore` file that respects your .gitignored files. The global `.gitignore` is not respected. For more information on `.gcloudignore`, see `gcloud topic gcloudignore`.)nargsdefaulthelpz--no-source
store_truez:Specify that no source should be uploaded with this build.)actionr   aj  
        table(
          id,
          createTime.date('%Y-%m-%dT%H:%M:%S%Oz', undefined='-'),
          duration(start=startTime,end=finishTime,precision=0,calendar=false,undefined="  -").slice(2:).join(""):label=DURATION,
          build_source(undefined="-"):label=SOURCE,
          build_images(undefined="-"):label=IMAGES,
          status
        )
      Nz--git-source-dirzDirectory, relative to the source root, in which to run the build.
This must be a relative path. If a step's `dir` is specified and is an absolute
path, this value is ignored for that step's execution.
)r   z--git-source-revisiona  Revision to fetch from the Git repository such as a branch, a tag, a commit
SHA, or any Git ref to run the build.

Cloud Build uses `git fetch` to fetch the revision from the Git repository;
therefore make sure that the string you provide for `revision` is parsable by
the command. For information on string values accepted by `git fetch`, see
https://git-scm.com/docs/gitrevisions#_specifying_revisions. For information on
`git fetch`, see https://git-scm.com/docs/git-fetch.
z--diraf      Directory, relative to the source root, in which to run the build. This is
    used when the build source is a 2nd-gen Cloud Build repository resource, or
    a Developer Connect GitRepositoryLink resource. This must be a relative
    path. If a step's `dir` is specified and is an absolute path, this value is
    ignored for that step's execution.
    z
--revisiona      Revision to fetch from the Git repository such as a branch, a tag, a commit
    SHA, or any Git ref to run the build. This is used when the build source is
    a 2nd-gen Cloud Build repository resource, or a Developer Connect
    GitRepositoryLink resource.

    Cloud Build uses `git fetch` to fetch the revision from the Git repository;
    therefore make sure that the string you provide for `revision` is parsable
    by the command. For information on string values accepted by `git fetch`,
    see https://git-scm.com/docs/gitrevisions#_specifying_revisions. For
    information on `git fetch`, see https://git-scm.com/docs/git-fetch.
)add_mutually_exclusive_groupadd_argumentr   AddRegionFlagAddServiceAccountFlagAddGcsSourceStagingDirFlagAddGcsLogDirFlagAddTimeoutFlagAddPollingIntervalFlagAddMachineTypeFlagAddDiskSizeFlagAddSubstitutionsFlagAddDefaultBucketsBehaviorFlagAddWorkerPoolFlagAddNoCacheFlagAddAsyncFlagAddSuppressLogsFlagdisplay_info	AddFormatAddCacheUpdaterAddIgnoreFileFlagAddConfigFlagstextwrapdedent)parserr   worker_poolss      lib/surface/builds/submit.py_CommonArgsr*      s    ..0&"  ( 	G   ff%""6* vv&6"V$%%f-((0,vVF# 	!
 	 	%%d+&!v   		   	??  	  	 	??      
    c                   <    \ rS rSrSrSSS.rSr\S 5       rS r	S	r
g
)Submit   ESubmit a build using Cloud Build.

Submit a build using Cloud Build.
a            {description}

          When the `builds/use_kaniko` property is `True`, builds submitted with
          `--tag` will use Kaniko
          (https://github.com/GoogleContainerTools/kaniko) to execute builds.
          Kaniko executes directives in a Dockerfile, with remote layer caching
          for faster builds. By default, Kaniko will cache layers for 6 hours.
          To override this, set the `builds/kaniko_cache_ttl` property.
      a  
      To submit a build with source located at storage URL `gs://bucket/object.zip`:

         $ {command}  "gs://bucket/object.zip" --tag=gcr.io/my-project/image

      To submit a build with source located at storage URL `gs://bucket/object.zip`
      using config file `config.yaml`:

        $ {command} "gs://bucket/object.zip" --config=config.yaml

      To submit a build with source from a source manifest:

        $ {command} "gs://bucket/manifest.json" --config=config.yaml

      To submit a build with local source `source.tgz` asynchronously:

        $ {command} "source.tgz" --tag=gcr.io/my-project/image --async

      To submit a build with source from a Git repository `https://github.com/owner/repo`:

        $ {command} "https://github.com/owner/repo" --git-source-revision=main --config=config.yaml

      To submit a build with source from a 2nd-gen Cloud Build repository resource `projects/my-project/locations/us-west1/connections/my-conn/repositories/my-repo`:

        $ {command} "projects/my-project/locations/us-west1/connections/my-conn/repositories/my-repo" --revision=main

      To submit a build with source from a Developer Connect GitRepositoryLink resource `projects/my-project/locations/us-west1/connections/my-conn/gitRepositoryLinks/my-repo-link`:

        $ {command} "projects/my-project/locations/us-west1/connections/my-conn/gitRepositoryLinks/my-repo-link" --revision=main
      )DESCRIPTIONEXAMPLESFc                     [        U 5        g N)r*   )r'   s    r)   ArgsSubmit.Args   s
    r+   c                 6   UR                   n[        R                  " 5       n[        R                  " UR
                  UR                  UUR                  UR                  UR                  S5      UR                  UR                  UR                  UR                  UR                  UR                  UR                   UR"                  UR$                  UR&                  UR(                  UR*                  UR,                  UR.                  SUR0                  SSS9n[        R2                  " XB5      nU=(       d    [        R4                  n[        R6                  " UUUR                  S5      UR                  UR                  UR                  UR(                  UR*                  UR$                  UR&                  UR                  SUUR0                  5      n[        R8                  " UUR:                  UUU R<                  UR>                  UR@                  S9u  pVU$ ).  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:
  FailedBuildException: If the build is completed and not 'SUCCESS'.
r   FTgcloudsubmitsskip_set_source
client_tag)build_regionsupport_gclsuppress_logspolling_interval)!regionr   GetMessagesModuler   CreateBuildConfigtagno_cachesubstitutionsconfigIsSpecified	no_sourcer   gcs_source_staging_dirignore_filegcs_log_dirmachine_type	disk_sizeworker_poolgit_source_dirgit_source_revisiondirrevisionservice_accountpackdefault_buckets_behaviorDetermineBuildRegionDEFAULT_REGION	SetSourceBuildasync__support_gclr>   r?   selfargsr<   messagesbuild_configbuild_s          r)   Run
Submit.Run   s    ;;L002H 00"##  		%%"1L6 33LOLA?#A#AL (("##  %%L$   !%%((..0HE Lr+    N)__name__
__module____qualname____firstlineno____doc__detailed_helpr[   staticmethodr4   rc   __static_attributes__re   r+   r)   r-   r-      s8    	

)-V , Kr+   r-   c                       \ rS rSrSrSrSrg)
SubmitBetai  r/   Tre   N)rf   rg   rh   ri   rj   r[   rm   re   r+   r)   ro   ro     s    
 ,r+   ro   c                   .    \ rS rSrSr\S 5       rS rSrg)SubmitAlphai"  r/   c                 F    [        U 5      n[        R                  " U5        g r3   )r*   r   AddConfigFlagsAlpha)r'   r(   s     r)   r4   SubmitAlpha.Args)  s    v&L	l+r+   c                 "   UR                   n[        R                  " 5       n[        R                  " UR
                  UR                  UUR                  UR                  UR                  S5      UR                  UR                  UR                  UR                  UR                  UR                  UR                   UR"                  UR$                  UR&                  UR(                  UR*                  UR,                  UR.                  UR0                  SUR2                  SSS9n[        R4                  " XB5      nU=(       d    [        R6                  n[        R8                  " UUUR                  S5      UR                  UR                  UR                  UR(                  UR*                  UR,                  UR.                  UR                  SUUR2                  5      n[        R:                  " UUR<                  UUSUR>                  S9u  pVU$ )r7   r   FTr8   r9   )r<   r=   r?   ) r@   r   rA   r   CreateBuildConfigAlpharC   rD   rE   rF   rG   rH   r   rI   rJ   rK   rL   rM   memory
vcpu_countrN   rQ   rR   rO   rP   rT   rU   rV   rW   rX   rY   rZ   r?   r\   s          r)   rc   SubmitAlpha.Run.  s    ;;L002H 55"##  		%%"3L8 33LOLA?#A#AL (("##  %%L$   !..0HE Lr+   re   N)	rf   rg   rh   ri   rj   rl   r4   rc   rm   re   r+   r)   rq   rq   "  s!    
 , ,Kr+   rq   )rj   r%   !googlecloudsdk.api_lib.cloudbuildr   googlecloudsdk.callioper   !googlecloudsdk.command_lib.buildsr   r   r*   UniverseCompatibleReleaseTracksReleaseTrackGACreateCommandr-   BETAro   ALPHArq   re   r+   r)   <module>r      s      = ( 3 9tn D%%(()BT B * BJ D%%**+  , D%%++,V* V -Vr+   