
                            S r SSKJr  SSKJr  SSKJr  SSKrSSK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  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  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	  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.  SSK+J/r/  SS K0J1r1  SS!K2J3r3  SS"K2J4r4  SS#K5J6r6  SS$K5J7r7  SSK8r8S%r9S&r:\Rv                  " \:S'-   5      r<S(r=/ S)Qr> " S* S+\,R~                  5      r? " S, S-\?5      r@ " S. S/\?5      rA " S0 S1\?5      rB " S2 S3\?5      rC " S4 S5\R                  5      rE\ER                  4S6 jrG " S7 S8\H5      rI " S9 S:\H5      rJS; rKS< rLS=\R                  R                  S>\ER                  4S? jrOS@ rPSA rQSB rRSC rSSD rTSE rUSF rVSG rWSH rXg)IzUtilities for `gcloud app` deployment.

Mostly created to selectively enable Cloud Endpoints in the beta/preview release
tracks.
    )absolute_import)division)unicode_literalsN)
exceptions)	scheduler)tasks)build)deploy_app_command_util)deploy_command_util)env)metric_names)runtime_builders)util)version_util)yaml_parsing)	index_api)storage_util)app_deploy_migration_util)actions)base)create_util)deployables)flags)output_helpers)source_files_util)staging)log)metrics)
properties)named_configs)
console_io)progress_tracker)files)timeszFhttps://console.cloud.google.com/appengine/taskqueues/cron?project={}
z[a-z][a-z0-9\-]{0,29}z\Zi   )java7java8java8gpython27go19php55c                       \ rS rSrSrSrg)ErrorS   zBase error for this module. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r.       1lib/googlecloudsdk/command_lib/app/deploy_util.pyr,   r,   S   s    #r5   r,   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )VersionPromotionErrorW   c                 2   > [         [        U ]  SU-   5        g )Na  Your deployment has succeeded, but promoting the new version to default failed. You may not have permissions to change traffic splits. Changing traffic splits requires the Owner, Editor, App Engine Admin, or App Engine Service Admin role. Please contact your project owner and use the `gcloud app services set-traffic --splits <version>=1` command to redirect traffic to your newly deployed version.

Original error: )superr8   __init__)selferr_str	__class__s     r6   r<   VersionPromotionError.__init__Y   s"    	
/	 %	%	&r5   r.   )r/   r0   r1   r2   r<   r4   __classcell__r?   s   @r6   r8   r8   W   s    
& 
&r5   r8   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )StoppedApplicationErrorf   zBError if deployment fails because application is stopped/disabled.c                 t   > [         [        U ]  SR                  UR                  UR
                  5      5        g )Nz`Unable to deploy to application [{}] with status [{}]: Deploying to stopped apps is not allowed.)r;   rD   r<   formatidservingStatus)r=   appr?   s     r6   r<    StoppedApplicationError.__init__i   s/    	
!41	**0&9J9J*KMr5   r.   r/   r0   r1   r2   r3   r<   r4   rA   rB   s   @r6   rD   rD   f   s    JM Mr5   rD   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )InvalidRuntimeNameErroro   zFError for runtime names that are not allowed in the given environment.c                 J   > [         [        U ]  SR                  X5      5        g )Nz?Invalid runtime name: [{}]. Must match regular expression [{}].)r;   rN   r<   rG   )r=   runtimeallowed_regexr?   s      r6   r<    InvalidRuntimeNameError.__init__r   s)    	
!
??Ev$@56r5   r.   rL   rB   s   @r6   rN   rN   o   s    N6 6r5   rN   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )RequiredFileMissingErrory   z6Error for skipped/ignored files that must be uploaded.c                 J   > [         [        U ]  SR                  U5      5        g )NzRequired file is not uploaded: [{}]. This file should not be added to an ignore list (https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore))r;   rU   r<   rG   )r=   filenamer?   s     r6   r<   !RequiredFileMissingError.__init__|   s%    	
"D2	L 
		r5   r.   rL   rB   s   @r6   rU   rU   y   s    > r5   rU   c                   $    \ rS rSrSrSrSrSrSrg)FlexImageBuildOptions   zEEnum declaring different options for building image for flex deploys.         r.   N)	r/   r0   r1   r2   r3   	ON_CLIENT	ON_SERVERBUILDPACK_ON_CLIENTr4   r.   r5   r6   r[   r[      s    M))r5   r[   c                    [         R                  R                  R                  R	                  SS9n[         R                  R                  R
                  R	                  SS9nU(       a  [        R                  nO5Uc
  U(       d  U nO(U(       a  [        R                  nO[        R                  n[        R                  " SU5        U$ )z/Determines where the build should be performed.FrequiredzFlex image build option: %s)r   VALUESrJ   trigger_build_server_sideGetBooluse_flex_with_buildpacksr[   ra   rb   r`   r   debug)default_strategyrg   ri   results       r6   GetFlexImageBuildOptionrm      s     55==u=M  44<<e<L  ",,F!)2JF"66F",,F)))62	-r5   c                   f    \ rS rSrSrS\R                  4S jr\S\R                  4S j5       r	Sr
g)DeployOptions   a  Values of options that affect deployment process in general.

No deployment details (e.g. sources for a specific deployment).

Attributes:
  promote: True if the deployed version should receive all traffic.
  stop_previous_version: Stop previous version
  runtime_builder_strategy: runtime_builders.RuntimeBuilderStrategy, when to
    use the new CloudBuild-based runtime builders (alternative is old
    externalized runtimes).
  parallel_build: bool, whether to use parallel build and deployment path.
    Only supported in v1beta and v1alpha App Engine Admin API.
  flex_image_build_option: FlexImageBuildOptions, whether a flex deployment
    should upload files so that the server can build the image, or build the
    image on client, or build the image on client using the buildpacks.
Fc                 @    Xl         X l        X0l        X@l        XPl        g N)promotestop_previous_versionruntime_builder_strategyparallel_buildflex_image_build_option)r=   rs   rt   ru   rv   rw   s         r6   r<   DeployOptions.__init__   s!     L!6$<!(#: r5   c                     [         R                  R                  R                  R	                  5       n[         R                  R                  R
                  R	                  5       nU " XEUX#5      $ )a  Initialize DeloyOptions using user properties where necessary.

Args:
  runtime_builder_strategy: runtime_builders.RuntimeBuilderStrategy, when to
    use the new CloudBuild-based runtime builders (alternative is old
    externalized runtimes).
  parallel_build: bool, whether to use parallel build and deployment path.
    Only supported in v1beta and v1alpha App Engine Admin API.
  flex_image_build_option: FlexImageBuildOptions, whether a flex deployment
    should upload files so that the server can build the image or build the
    image on client or build the image on client using the buildpacks.

Returns:
  DeployOptions, the deploy options.
)r   rf   rJ   promote_by_defaultrh   rt   )clsru   rv   rw   rs   rt   s         r6   FromPropertiesDeployOptions.FromProperties   s\    ( ##66>>@G33;;= w/G8 8r5   )rw   rv   rs   ru   rt   N)r/   r0   r1   r2   r3   r[   r`   r<   classmethodr|   r4   r.   r5   r6   ro   ro      s<    * $'<'F'F
;  %*-B-L-L8 8r5   ro   c                   Z    \ rS rSrSrS rS rS rS rS r	\
R                  SS4S	 jrS
rg)ServiceDeployer   a  Coordinator (reusable) for deployment of one service at a time.

Attributes:
  api_client: api_lib.app.appengine_api_client.AppengineClient, App Engine
    Admin API client.
  deploy_options: DeployOptions, the options to use for services deployed by
    this ServiceDeployer.
c                     Xl         X l        g rr   
api_clientdeploy_options)r=   r   r   s      r6   r<   ServiceDeployer.__init__   s     O(r5   c                     UR                   nUS:X  a  gSnU R                  R                  n[        R                  " XU5      nU(       d+  [
        R                  U5      (       d  [        U[        5      egg)a  Validates explicit runtime builders are not used without the feature on.

Args:
  service_info: yaml_parsing.ServiceYamlInfo, service configuration to be
    deployed

Raises:
  InvalidRuntimeNameError: if the runtime name is invalid for the deployment
    (see above).
customNT)	rQ   r   ru   r   ShouldUseRuntimeBuildersORIGINAL_RUNTIME_REmatchrN   ORIGINAL_RUNTIME_RE_STRING)r=   service_inforQ   needs_dockerfilestrategyuse_runtime_builderss         r6   _ValidateRuntime ServiceDeployer._ValidateRuntime   su     ""G( "";;H.GG 02(;(A(A'(J(J#G-GHH )Kr5   c	                    Sn	U(       a  UR                  5       (       aT  UR                  R                  R                  (       a/  [        R
                  " SR                  UR                  5      5        [        R                  R                  U5      $ UR                  5       (       Gae  [        XBR                  5       5      (       d  [        UR                  5       5      eU[        R                  :X  a  SUR                  5       0n
[         R"                  R$                  R&                  R)                  5       nU(       aD  [+        [,        R.                  " USS9R0                  5      n[2        R4                  " U5      S-   U
S'   [        R                  R7                  U
5      n	U	$ [8        R:                  " UR<                  X#UUR>                  XgU R@                  RB                  U R@                  RD                  U[        RF                  :H  5
      n	U	$ )a  Builds and Pushes the Docker image if necessary for this service.

Args:
  new_version: version_util.Version describing where to deploy the service
  service: yaml_parsing.ServiceYamlInfo, service configuration to be
    deployed
  upload_dir: str, path to the service's upload directory
  source_files: [str], relative paths to upload.
  image: str or None, the URL for the Docker image to be deployed (if image
    already exists).
  code_bucket_ref: cloud_storage.BucketReference where the service's files
    have been uploaded
  gcr_domain: str, Cloud Registry domain, determines the physical location
    of the image. E.g. `us.gcr.io`.
  flex_image_build_option: FlexImageBuildOptions, whether a flex deployment
    should upload files so that the server can build the image or build the
    image on client or build the image on client using the buildpacks.

Returns:
  BuildArtifact, a wrapper which contains either the build ID for
    an in-progress build, or the name of the container image for a serial
    build. Possibly None if the service does not require an image.
Raises:
  RequiredFileMissingError: if a required file is not uploaded.
NzDeployment of service [{0}] will ignore the skip_files field in the configuration file, because the image has already been built.appYamlPaths)default_suffixcloudBuildTimeout)$RequiresImageparsed
skip_filesregexr   warningrG   serviceapp_cloud_buildBuildArtifactMakeImageArtifact_AppYamlInSourceFilesGetAppYamlBasenamerU   r[   ra   r   rf   rJ   cloud_build_timeoutGetintr$   ParseDurationtotal_secondssix	text_typeMakeBuildOptionsArtifactr   BuildAndPushDockerImageprojectrH   r   ru   rv   rb   )r=   new_versionr   
upload_dirsource_filesimagecode_bucket_ref
gcr_domainrw   r	   cloud_build_optionstimeoutbuild_timeouts                r6   _PossiblyBuildAndPush%ServiceDeployer._PossiblyBuildAndPush   s   8 E				 	 W^^%>%>%D%D **0&1D1D*E	G **<<UCC				 	 "<1K1K1MNN&w'A'A'CDD	 $9$C$C	C7557
 ##'';;??A!!'#>LLN-58]]6"6#
1
2--FF! L $;;lNNO88..0G!5516	7 Lr5   c                    U R                   R                  (       a9   [        R                  " XU R                  U R                   R
                  U5        gU R                   R
                  (       a  [        R                  " S5        gg! [        R                   a:  n[        R                  " [        R                  " U5      5      n[        U5      eSnAff = f)a  Promotes the new version to default (if specified by the user).

Args:
  all_services: dict of service ID to service_util.Service objects
    corresponding to all pre-existing services (used to determine how to
    promote this version to receive all traffic, if applicable).
  new_version: version_util.Version describing where to deploy the service
  wait_for_stop_version: bool, indicating whether to wait for stop operation
    to finish.

Raises:
  VersionPromotionError: if the version could not successfully promoted
NzCNot stopping previous version because new version was not promoted.)r   rs   r   PromoteVersionr   rt   apitools_exceptions	HttpErrorr   r   core_api_exceptionsHttpExceptionr8   r   info)r=   all_servicesr   wait_for_stop_versionerrr>   s         r6   _PossiblyPromote ServiceDeployer._PossiblyPromote;  s     ""-##Lt$($7$7$M$M$9	; 
			2	2	hh    
3 !** --- 3 A A# FG#G,,-s   7B C5CCc                    SnU(       d  U[         R                  :X  d  UR                  (       d  UR                  [        R                  :X  a7  [        XBR                  5       5      (       d  [        UR                  5       5      eSnUR                  [        R                  :X  a  UR                  [        ;   a  [        n[        R                  " X4XXS9nU$ )a  Uploads files for this deployment is required for this service.

Uploads if flex_image_build_option is FlexImageBuildOptions.ON_SERVER,
or if the deployment is non-hermetic and the image is not provided.

Args:
  image: str or None, the URL for the Docker image to be deployed (if image
    already exists).
  service_info: yaml_parsing.ServiceYamlInfo, service configuration to be
    deployed
  upload_dir: str, path to the service's upload directory
  source_files: [str], relative paths to upload.
  code_bucket_ref: cloud_storage.BucketReference where the service's files
    have been uploaded
  flex_image_build_option: FlexImageBuildOptions, whether a flex deployment
    should upload files so that the server can build the image or build the
    image on client or build the image on client using the buildpacks.

Returns:
  Dictionary mapping source files to Google Cloud Storage locations.

Raises:
  RequiredFileMissingError: if a required file is not uploaded.
N)max_file_size)r[   ra   is_hermeticr   FLEXr   r   rU   STANDARDrQ   _RUNTIMES_WITH_FILE_SIZE_LIMITS_MAX_FILE_SIZE_STANDARDr
   CopyFilesToCodeBucket)	r=   r   r   r   r   r   rw   manifestlimits	            r6   _PossiblyUploadFiles$ServiceDeployer._PossiblyUploadFilesU  s    4 H 	 $9$C$C	C%%


chh
&/D
7790; 0;&|'F'F'HIIe


cll
*


"A
A'(>>
OJhOr5   Nc           
         [         R                  R                  SR                  UR                  S95        UR
                  R                  [        R                  :X  a$  U	[        R                  :X  a  [        R                  n	UR
                  nU R                  U5        [        R                  " UR                  UR                  R                   R"                  UR%                  5       UR&                  UR                  UR(                  U
S9nU R+                  X,UR                  XX6U	5      nU R-                  XLUR                  UUU	5      nA0 nU(       a  SUS'   [.        R0                  " [2        R4                  5        U R6                  R9                  UR                  UR:                  XUUU5        [.        R0                  " [2        R<                  5        U R?                  XRU5        g)a   Deploy the given service.

Performs all deployment steps for the given service (if applicable):
* Enable endpoints (for beta deployments)
* Build and push the Docker image (Flex only, if image_url not provided)
* Upload files (non-hermetic deployments and flex deployments with
  flex_image_build_option=FlexImageBuildOptions.ON_SERVER)
* Create the new version
* Promote the version to receive all traffic (if --promote given (default))
* Stop the previous version (if new version promoted and
  --stop-previous-version given (default))

Args:
  service: deployables.Service, service to be deployed.
  new_version: version_util.Version describing where to deploy the service
  code_bucket_ref: cloud_storage.BucketReference where the service's files
    will be uploaded
  image: str or None, the URL for the Docker image to be deployed (if image
    already exists).
  all_services: dict of service ID to service_util.Service objects
    corresponding to all pre-existing services (used to determine how to
    promote this version to receive all traffic, if applicable).
  gcr_domain: str, Cloud Registry domain, determines the physical location
    of the image. E.g. `us.gcr.io`.
  disable_build_cache: bool, disable the build cache.
  wait_for_stop_version: bool, indicating whether to wait for stop operation
    to finish.
  flex_image_build_option: FlexImageBuildOptions, whether a flex deployment
    should upload files so that the server can build the image or build the
    image on client or build the image on client using the buildpacks.
  ignore_file: custom ignore_file name. Override .gcloudignore file to
    customize files to be skipped.
  service_account: identity this version runs as. If not set, Admin API will
    fallback to use the App Engine default appspot SA.
z.Beginning deployment of service [{service}]...)r   )ignore_filetruezno-cacheN) r   statusPrintrG   r   r   r   MANAGED_VMSr[   ra   r`   r   r   GetSourceFilesr   r   r   r   HasExplicitSkipFilesrQ   sourcer   r   r   CustomTimedEventr   DEPLOY_API_STARTr   DeployServicerH   
DEPLOY_APIr   )r=   r   r   r   r   r   r   disable_build_cacher   rw   r   service_accountr   r   r	   r   extra_config_settingss                    r6   DeployServiceDeployer.Deploy  s   ^ JJELL## M % &  COO3#8#B#BB 5 ? ?''L,'$33&&,,))+!L &&{'.'9'9<'6'>@E (()0););\)8)@BH
 	*0J' \::;OO!!+"5"5{~~".%"7J \445,5JKr5   r   )r/   r0   r1   r2   r3   r<   r   r   r   r   r[   r`   r   r4   r.   r5   r6   r   r      s;    )I0;z 4*j &;%D%D!ZLr5   r   c                    [         R                  R                  U 5        [         R                  R                  U 5        [         R                  R                  U 5        [         R
                  R                  U 5        U R                  SS[         R                  SS9  U R                  S[        R                  R                  SS9  U R                  SSS	9  U R                  S
SSS9  U R                  S[        R                  " [        R                  R                  R                   5      SS9  U R                  SSS	9  U R                  SSS	9  U R                  S[        R                  " [        R                  R                  R"                  5      SS9  U R                  SSSSS9  U R%                  SS9nUR                  SSSSS9  UR                  S SS	9  g!)"zgGet arguments for this command.

Args:
  parser: argparse.ArgumentParser, the parser for this command.
z	--versionz-vzThe version of the app that will be created or replaced by this deployment.  If you do not specify a version, one will be generated for you.)typehelpz--bucketzThe Google Cloud Storage bucket used to stage files associated with the deployment. If this argument is not specified, the application's default code bucket is used.z--service-accountzThe service account that this deployed version will run as. If this argument is not specified, the App Engine default service account will be used for your current deployed version.)r   r   *a         The yaml files for the services or configurations you want to deploy.
      If not given, defaults to `app.yaml` in the current directory.
      If that is not found, attempts to automatically generate necessary
      configuration files (such as app.yaml) in the current directory.)nargsr   z--stop-previous-versiona        Stop the previously running version when deploying a new version that
      receives all traffic.

      Note that if the version is running on an instance
      of an auto-scaled service in the App Engine Standard
      environment, using `--stop-previous-version` will not work
      and the previous version will continue to run because auto-scaled service
      instances are always running.)actionr   z--image-urlz(App Engine flexible environment only.) Deploy with a specific Docker image. Docker url must be from one of the valid Artifact Registry hostnames.z	--appyamlzTDeploy with a specific app.yaml that will replace the one defined in the DEPLOYABLE.z	--promotez4Promote the deployed version to receive all traffic.z--cache
store_trueTz]Enable caching mechanisms involved in the deployment process, particularly in the build step.)r   defaultr   )hiddenz--skip-stagingFzTHIS ARGUMENT NEEDS HELP TEXT.z--staging-commandN)r   SERVER_FLAGAddToParserIGNORE_CERTS_FLAGDOCKER_BUILD_FLAGIGNORE_FILE_FLAGadd_argumentVERSION_TYPEr   BucketReferenceFromArgumentr   StoreBooleanPropertyr   rf   rJ   rt   rz   add_mutually_exclusive_group)parserstaging_groups     r6   
ArgsDeployr     s    '%%f-%%f-$$V,
	   	''449  ; 	N  P
 	J  K 	))





5
57'	  ( 	  
 	+  , 	))





2
24A	  C
 	(	  ) 55T5B-+	  -
  @  Br5   c                    U (       a  [         R                  " U5      $ U(       a5  [         R                  R                  U5      n[         R                  " XC5      $ U(       a  [         R
                  " U5      $ [         R                  " U5      $ )aj  Creates the appropriate stager for the given arguments/release track.

The stager is responsible for invoking the right local staging depending on
env and runtime.

Args:
  skip_staging: bool, if True use a no-op Stager. Takes precedence over other
    arguments.
  use_beta_stager: bool, if True, use a stager that includes beta staging
    commands.
  staging_command: str, path to an executable on disk. If given, use this
    command explicitly for staging. Takes precedence over later arguments.
  staging_area: str, the path to the staging area

Returns:
  staging.Stager, the appropriate stager for the command
)r   GetNoopStagerExecutableCommand	FromInputGetOverrideStagerGetBetaStager	GetStager)skip_staginguse_beta_stagerstaging_commandstaging_areacommands        r6   _MakeStagerr  -  sg    $   ..''11/BG$$W;;  ..\**r5   FTc                    [         R                  R                  R                  R	                  SS9n[
        R                  UUUS9n[        R                  " 5        n[        U R                  UU R                  U5      n	[        R                  " U R                  U	[        R                  " 5       U R                  5      u  p[!        U5      nU
 Vs/ s H  oR"                  PM     nn[$        R&                  " U R(                  U5        [*        R,                  " SR/                  UR0                  R2                  UR0                  R4                  S95        [7        X5      n[9        X5        U R:                  (       d  [=        X5      nU R>                  =(       d    [@        RB                  " 5       n[D        RF                  " XXUURH                  U RJ                  UR0                  R4                  5      n[L        RN                  " SS9  U(       Ga  [P        RR                  " [T        RV                  5        U R:                  =(       d    [$        RX                  " X5      n[P        RR                  " [T        RZ                  5        [*        R,                  " SR/                  UR]                  5       S95        [_        U Vs/ s H  nURa                  5       PM     sn5      (       a  [b        Rd                  " U5        [g        URi                  5        Vs/ s H  nURj                  U4PM     sn5      nOS	n0 n/ n[m        X5      nS
nU
 GH%  nU(       d$  [P        RR                  " [T        Rn                  5        [p        Rr                  " UURt                  U5      nURw                  UUUU R(                  UURx                  U Rz                  (       + UUU R|                  U RJ                  S9  UR                  U5        [*        R                  R                  SR/                  URt                  UURt                     5      5        U(       d$  [P        RR                  " [T        R                  5        SnGM(     S	S	S	5        W(       Ga  [P        RR                  " [T        R                  5        U GH@  nSR/                  UR                  S9n[        R                  " U5         UR                  S:X  a   UR                  UR                  5       5        OUR                  [        R                  R                  :X  a"  [        R                  " UUR                  5        OUR                  [        R                  R                  :X  a  [        U5        OVUR                  [        R                  R                  :X  a  [        U5        O"[        SR/                  UR                  S95      eS	S	S	5        GMC     [P        RR                  " [T        R                  5        U Vs/ s H  nUR                  PM     nn[        WU5        UUS.$ s  snf s  snf s  snf ! , (       d  f       GN= f! , (       d  f       GM  = fs  snf )a  Perform a deployment based on the given args.

Args:
  args: argparse.Namespace, An object that contains the values for the
    arguments specified in the ArgsDeploy() function.
  api_client: api_lib.app.appengine_api_client.AppengineClient, App Engine
    Admin API client.
  use_beta_stager: Use the stager registry defined for the beta track rather
    than the default stager registry.
  runtime_builder_strategy: runtime_builders.RuntimeBuilderStrategy, when to
    use the new CloudBuild-based runtime builders (alternative is old
    externalized runtimes).
  parallel_build: bool, whether to use parallel build and deployment path.
    Only supported in v1beta and v1alpha App Engine Admin API.
  flex_image_build_option: FlexImageBuildOptions, whether a flex deployment
    should upload files so that the server can build the image or build the
    image on client or build the image on client using the buildpacks.

Returns:
  A dict on the form `{'versions': new_versions, 'configs': updated_configs}`
  where new_versions is a list of version_util.Version, and updated_configs
  is a list of config file identifiers, see yaml_parsing.ConfigYamlInfo.
Trd   )ru   rv   rw   z4API endpoint: [{endpoint}], API version: [{version}])endpointversion)cancel_on_nozUsing bucket [{b}].)bNF)r   r   rw   r   r   zDeployed service [{0}] to [{1}]zUpdating config [{config}])configdispatchzUnknown config [{config}])versionsconfigs)Vr   rf   corer   r   ro   r|   r#   TemporaryDirectoryr  r   r  r   GetDeployablesGetPathMatchersappyaml_CheckIfConfigsContainDispatchr   r   ValidateImageUrl	image_urlr   rj   rG   clienturl_VERSION_PossiblyCreateApp_RaiseIfStoppedbucket_PossiblyRepairAppr  r   GenerateVersionIdr   DisplayProposedDeploymentrs   r   r!   PromptContinuer   r   r   GET_CODE_BUCKET_STARTGetCodeBucketGET_CODE_BUCKETToUrlanyr   r   PossiblyEnableFlexdictListServicesrH   r   FIRST_SERVICE_DEPLOY_STARTr   Version
service_idr   	gcrDomaincacher   appendr   r   FIRST_SERVICE_DEPLOYUPDATE_CONFIG_STARTnamer"   ProgressTrackerUpdateDispatchRulesGetRulesr   ConfigYamlInfoINDEXr   #CreateMissingIndexesViaDatastoreApir   QUEUERunDeployCloudTasksCRONRunDeployCloudScheduler
ValueErrorUPDATE_CONFIGPrintPostDeployHints)argsr   r  ru   rv   rw   r   r   r  stagerservicesr  r   dservice_infosrJ   
version_iddeployed_urlsr   r   r   new_versionsdeployerservice_deployedr   r   r  messagecupdated_configss                                 r6   	RunDeployrL  J  s   > ""**...=' //7#5 0 7.
 !\**O--|=F#22&+"="="?OH ;7C-56X^^XM6	4>>=9 IIDKK""&&
0A0A0J0J L L M
Z
1CJ$ ;;z/c 9!7!7!9J"<<h^5K5Kj//88:M 40 |AABHu':':3'Ho|;;<	ii%,,/D/D/F,GH 
7Aaoo7	8	8..w7j.E.E.GH.GADD!9.GHIlolLz:H   !H!HI (('2D2D)35koo



..

--#'::~ 5"9&&..  0 +&	jj8??


mG,>,>?A B  !B!BC- c "T \==>,336;;3Gg++G4;;*$

(
():
;[[L77===

7
7
O[[L77===
f
%[[L77<<<
!&
))000D  54  \778%,-WQVVW/-|_5 #	??u 7: 8 IQ "!\ 54 .sL   A4YX6%GY8X;
9YY 
#EYDYY*6Y
Y
Y'	c                     [         R                  " [        R                  R                  5      n[
        R                  " U5      n[
        R                  " U 5        [
        R                  " XU5        g)a   Perform a deployment using Cloud Tasks API based on the given args.

Args:
  config: A yaml_parsing.ConfigYamlInfo object for the parsed YAML file we are
    going to process.

Returns:
  A list of config file identifiers, see yaml_parsing.ConfigYamlInfo.
N)	r   GetApiAdapterr   ReleaseTrackBETAr   FetchCurrentQueuesDataValidateQueueYamlFileConfigDeployQueuesYamlFile)r  	tasks_apiqueues_datas      r6   r9  r9    sN     !!$"3"3"8"89))@@K+77?00KPr5   c                     [         R                  " [        R                  R                  SS9n[
        R                  " U5      n[
        R                  " U 5        [
        R                  " XU5        g)a  Perform a deployment using Cloud Scheduler APIs based on the given args.

Args:
  config: A yaml_parsing.ConfigYamlInfo object for the parsed YAML file we are
    going to process.

Returns:
  A list of config file identifiers, see yaml_parsing.ConfigYamlInfo.
T)legacy_cronN)	r   rN  r   rO  rP  r   FetchCurrentJobsDataValidateCronYamlFileConfigDeployCronYamlFile)r  scheduler_api	jobs_datas      r6   r;  r;    sS     ))
$0-'<<]K)66v>..}iPr5   c                 ~   [         R                  R                  U;   a  [        R                  R                  S5        [         R                  R                  U;  a  [        R                  R                  S5        [        R                  R                  [        R                  [        R                  R                  R                  R                  5       5      5        [         R                  R                  U;   a  [        R                  R                  S5        [         R                  R                  U;   a>  [        R                  R                  S5        [        R                  R                  S5        [         R                  R                  U;   a  [        R                  R                  S5        U (       d  g[!        U 5      S:  a  SnO4U S	   R"                  S
:X  a  SnOU S	   R"                  nSR                  US9n[$        R&                  R)                  5       R                  SS5      n[        R                  R                  R                  R                  5       nXE:w  a  SU-   nOSn[        R                  R                  SU=(       d    S-   5        [        R                  R                  SU-   U-   5        g)z0Print hints for user at the end of a deployment.z
Cron jobs have been updated.zU
Visit the Cloud Platform Console Task Queues page to view your queues and cron jobs.z#
Custom routings have been updated.z
Task queues have been updated.z3
Indexes are being rebuilt. This may take a moment.Nr]   z -s <service>r   r    z	 -s {svc})svcr  r   z --project=zO
You can stream logs from the command line by running:
  $ gcloud app logs tailz -s defaultzG
To view your application in the web browser run:
  $ gcloud app browse)r   r5  r:  r   r   r   r8  _TASK_CONSOLE_LINKrG   r   rf   r  r   r   DISPATCHr6  lenr   r    ActivePropertiesFileLoad)rF  rK  service_hintr   	proj_confr   project_hints          r6   r>  r>    s     %%8JJ56""((?	jj < =	jj

#
#J$5$5$:$:$B$B$F$F$H
IK  ))_<JJ;<  &&/9JJ78JJ : ;  &&/9JJKL	

<1"LA)+L1o%%G%%'%2L00557;;FIN)""**..0' 7*LL** .1=1NP Q** +-9:<HI Jr5   c                      U R                  5       $ ! [        R                   an    [        R                  " SSS9  [
        R                  " 5       (       a(  [        R                  " X5        U R                  5       s $ [        R                  " U5      e[        R                   ag    [        R                  R                  R                  R!                  5       n["        R$                  " SR'                  U R)                  5       U5      5      ef = f)a  Returns an app resource, and creates it if the stars are aligned.

App creation happens only if the current project is app-less, we are running
in interactive mode and the user explicitly wants to.

Args:
  api_client: Admin API client.
  project: The GCP project/app id.

Returns:
  An app object (never returns None).

Raises:
  MissingApplicationError: If an app does not exist and cannot be created.
zNo app found:T)exc_infozPermissions error fetching application [{}]. Please make sure that you have permission to view applications on the project and that {} has the App Engine Deployer (roles/appengine.deployer) role.)GetApplicationr   HttpNotFoundErrorr   rj   r!   	CanPromptr   CreateAppInteractivelyr   MissingApplicationErrorHttpForbiddenErrorr   rf   r  accountr   r   r   rG   
_FormatApp)r   r   active_accounts      r6   r  r  !  s     E$$&&		.	. 6 IIo- ((=&&((

,
,W
55		/	/ E&&++33779N

+
+
, -3F:3H3H3J3A-C	E EEs    A)D=BDc                 j    UR                   (       d!  SnU R                  US9  U R                  5       nU$ )a  Repairs the app if necessary and returns a healthy app object.

An app is considered unhealthy if the codeBucket field is missing.
This may include more conditions in the future.

Args:
  api_client: Admin API client.
  app: App object (with potentially missing resources).

Returns:
  An app object (either the same or a new one), which contains the right
  resources, including code bucket.
z!Initializing App Engine resources)progress_message)
codeBucketRepairApplicationrj  )r   rJ   rI  s      r6   r  r  N  s4     
1G  ' :

#
#
%C	*r5   c                 F    U R                  U5      (       a  [        U5      eg)zChecks if app is disabled and raises error if so.

Deploying to a disabled app is not allowed.

Args:
  api_client: Admin API client.
  app: App object (including status).

Raises:
  StoppedApplicationError: if the app is currently disabled.
N)	IsStoppedrD   )r   rJ   s     r6   r  r  c  s%     #
!#
&& r5   c                 :    U  H  nUR                   S:X  d  M    g   g)zChecks if list of configs contains dispatch config.

Args:
  configs: list of configs

Returns:
  bool, indicating if configs contain dispatch config.
r  TF)r1  )r  r  s     r6   r  r  s  s"     f{{j   
r5   c                 N   [         R                  R                  R                  R	                  5       bk  [         R                  R                  R                  R                  5       (       a  [        R                  R                  $ [        R                  R                  $ U [        R                  R                  L a  [        R                  R                  $ U [        R                  R                  L a  [        R                  R                  $ [!        SR#                  U 5      5      e)a  Gets the appropriate strategy to use for runtime builders.

Depends on the release track (beta or GA; alpha is not supported) and whether
the hidden `app/use_runtime_builders` configuration property is set (in which
case it overrides).

Args:
  release_track: the base.ReleaseTrack that determines the default strategy.

Returns:
  The RuntimeBuilderStrategy to use.

Raises:
  ValueError: if the release track is not supported (and there is no property
    override set).
zUnrecognized release track [{}])r   rf   rJ   r   r   rh   r   RuntimeBuilderStrategyALWAYSNEVERr   rO  GAALLOWLIST_GArP  ALLOWLIST_BETAr<  rG   )release_tracks    r6   GetRuntimeBuilderStrategyr    s    & //335A1199;;44;;;44:::d''***22???))...22AAA
6==mL
MMr5   c                     U (       d  g[         R                  R                  U5      n[        U  Vs/ s H  o3U:H  PM	     sn5      $ s  snf )NF)ospathbasenamer%  )r   app_yaml_pathapp_yaml_filenamefs       r6   r   r     s@    	 gg&&}5	l;l$$l;	<<;s   A)Yr3   
__future__r   r   r   enumr  reapitools.base.pyr   r   googlecloudsdk.api_libr   r   googlecloudsdk.api_lib.appr	   r   r
   r   r   r   r   r   r   r    googlecloudsdk.api_lib.datastorer   googlecloudsdk.api_lib.storager   googlecloudsdk.api_lib.tasksr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r   googlecloudsdk.command_lib.appr   r   r   r   r   r   googlecloudsdk.corecore_exceptionsr   r   r   "googlecloudsdk.core.configurationsr    googlecloudsdk.core.consoler!   r"   googlecloudsdk.core.utilr#   r$   r   r`  r   compiler   r   r   r,   r8   rD   rN   rU   Enumr[   r`   rm   objectro   r   r   r  r{  r}  rL  r9  r;  r>  r  r  r  r  r  r   r.   r5   r6   <module>r     s   '  '  	 	 > , ( ? > : * 3 7 + 3 3 6 7 B I + ( 6 6 5 0 9 < 2 = # ' * < 2 8 * * 
  6 jj!;e!CD  + # 
$O!! $&E &Me M6e 6u DII  .C-L-L (68F 68rCLf CLLLB^+@ -DDJJ1;;G@TQ"Q(%JP*EZ*'  NB=r5   