
    %                        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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r\R8                  " \R:                  R<                  \R:                  R>                  5      \R@                   " S S\RB                  5      5       5       r"g)z@Command for deploying containers from Compose file to Cloud Run.    N)api_enabler)base)docker_util)util)artifact_registry)
exceptions)flags)pretty_print)up)compose_resource)tracker)log)metrics)
properties)progress_trackerzcloud-run-source-deployc                   l    \ rS rSrSrSSS.r\S 5       r\S 5       rS r	S	 r
S
 rS rS rS rS rSrg)Up'   z/Deploy to Cloud Run from compose specification.z"          {description}
          z          To deploy a container from the source Compose file on Cloud Run:

              $ {command} compose.yaml

          To deploy to Cloud Run with unauthenticated access:

              $ {command} compose.yaml --allow-unauthenticated
         )DESCRIPTIONEXAMPLESc                     [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        U R                  SSSS9  g )Nz
--no-build
store_truez(Skip building from source if applicable.)actionhelp)r	   AddDeployFromComposeArgumentAddRegionArgAddDryRunFlagAddAllowUnauthenticatedFlagadd_argumentparsers    lib/surface/run/compose/up.py
CommonArgsUp.CommonArgs;   sV    	&&v.	v		%%f-
7      c                 .    [         R                  U 5        g )N)r   r#   r    s    r"   ArgsUp.ArgsG   s    MM&r%   c                 	   U R                  5       nU" SU[        R                  " 5       [        R                  R                  :*  UR
                  US9nSn	UR                  (       d  UR                  (       a.  [        UR                  [        5      (       a  UR                  S   n	[        R                  " [        R                  R                  R                  R                  5       SU	5        [         R"                  " U	5      e [$        R&                  R)                  UR                  S   5      n
[        R*                  " S5        [        R*                  " SU
 35        [        R                  R,                  R.                  R                  S	S
9nU
R1                  UR2                  5      nU(       a  [4        R6                  " X5        [8        R:                  " SU R=                  U
5      SSSS9 nU
R?                  XSXR2                  5      n[        R*                  " SU 35        SSS5        WRA                  5       nU" SUUU[        R                  " 5       [        R                  R                  :*  UR
                  UUS9nUR                  (       Ga  [$        RB                  R)                  UR                  S   5      n[        R*                  " S5        [        R*                  " S[        URD                  RG                  5       5      [        URH                  RG                  5       5      -    35        URH                  RG                  5        H  n[$        RJ                  " UUUUS9  M     URD                  RG                  5        H  n[$        RJ                  " UUUUS9  M     U$ UR                  (       a.  [        UR                  [        5      (       a  UR                  S   n	[        R                  " [        R                  R                  R                  R                  5       SU	5        [         R"                  " U	5      e! , (       d  f       GN%= f! [L         a%    [        R*                  " SUR                   35        e f = f)z-Handles the resource and translate run logic.resource)commandcompose_filedebugdry_runregionzFailed to process compose file.resource_errorr   z+Successfully parsed resources config proto.zResourcesConfig:
TrequiredzSetting up resources...zSetup failedFzResource setup complete.)failure_messagesuppress_outputsuccess_messagezHandled ResourcesConfig:
N	translate)r+   repor,   resources_configr-   r.   project_numberr/   z1Successfully translated resources config to YAML.zYAML files:
)yaml_file_pathr/   argsrelease_tracktranslate_errorzRaw output: )'ReleaseTrackr   GetVerbosityloggingDEBUGr.   stdoutstderr
isinstancelistr   CustomKeyValuer   VALUEScommand_nameGetr   ConfigurationErrorr   ResourcesConfig	from_jsonr-   coreprojectget_required_apisno_buildr   check_and_enable_apisr   StagedProgressTracker_AddTrackerStageshandle_resourcesto_jsonTranslateResultservicesvaluesmodelsdeploy_application	Exception)selfcommand_executorr,   r8   r:   r/   r<   r=   resource_responseerror_messageconfig
project_idrequired_apisr   r9   resources_config_jsonresponsetranslate_result
model_yamlservice_yamls                       r"   _ResourceAndTranslateRunUp._ResourceAndTranslateRunK   s    %%'M(! CKK$5$55 6M## 
	!	!j

"
"D' ' *004



#
#
0
0
4
4
6


 ))-88I//99

"
"1
%f 
ii=>	ii$VH-.$$))1155t5Dj..t}}=m	))*D11
#

 
 
((4 !22'==
 			./?.@AB /668!#0  "ckk&7&77,,'	h 
+;;EEOOA
 			EF		$--4467$?O?V?V?]?]?_:``ac	
 +1188:J

-
-')	 ; -55<<>L

-
-))	 ?" o ??z(//4@@"//"--%%22668	

 ++M::q v  	ii,07789:s-   C+Q /6Q%F Q &BQ 
QQ /Rc                 z   [         R                  R                  S5        [        R                  " USS9nU R                  U5        [        R                  R                  R                  R                  SS9n[        R                  " U5      nU R                  UU5      n[        R                  " UU[         S9n["        R$                  " USSS9(       a  U R'                  U5        [(        R*                  " 5       nUR,                  (       a  UR,                  nOU R/                  5       nU R1                  XxXTX!5      n	U	$ )z=Deploy a container from the source Compose file to Cloud Run.z&Deploying from Compose to Cloud Run...T)promptr2   )rb   location_idrepo_id)skip_activation_promptskip_console_prompt)r   statusPrintr	   	GetRegion_SetRegionConfigr   rH   rN   rO   rJ   projects_utilGetProjectNumber_GenerateRepositoryNamer   
DockerRepoDEFAULT_REPO_NAMEr   ShouldCreateRepository_CreateARRepositoryr   RunComposeWrapperr,   _GetComposeFileri   )
r]   r<   r/   rO   r:   r8   docker_repor^   r,   re   s
             r"   RunUp.Run   s   JJ=>__T$/F&!$$,,00$0?G"33G<N''D ((!K //Dd {+++-&&l))+l,,fH Or%   c                 p    SR                  U5      nSR                  X1R                  SS5      [        5      $ )z#Generate a name for the repository.z{}-docker.pkg.devz{}/{}/{}:/)formatreplacery   )r]   rO   r/   
repositorys       r"   rw   Up._GenerateRepositoryName   s6    $++F3JOOC-/@ r%   c                 2   [         R                  R                  R                  R	                  5       (       d`  [
        R                  R                  SR                  US95        [         R                  R                  R                  R                  U5        gg)zSet the region config.z]Region set to {region}.You can change the region with gcloud config set run/region {region}.
)r/   N)
r   rH   runr/   rJ   r   rq   rr   r   Set)r]   r/   s     r"   rt   Up._SetRegionConfig   sm      ''++--	jj//5vVv/D ""&&v. .r%   c                     S H+  n[         R                  R                  U5      (       d  M)  Us  $    [        R                  " S5      e)N)zcompose.yamlzcompose.ymlzdocker-compose.yamlzdocker-compose.ymlz5No compose file found. Please provide a compose file.)ospathexistsr   rK   )r]   filenames     r"   r}   Up._GetComposeFile   s@     
	!	! 
'
'? r%   c                 t    [         R                  " SUR                   35        [        R                  " USS9  g)z6Create an Artifact Registry Repository if not present.z&Creating AR Repository in the region: T)ro   N)r
   Successlocationr   CreateRepository)r]   r~   s     r"   r{   Up._CreateARRepository   s3    
01E1E0FG &&{4Pr%   c           
      X   / nUR                   (       a`  UR                    HP  nUR                  [        R                  " SU S3[        R
                  R                  R                  US9S95        MR     UR                  (       aJ  UR                  [        R                  " S[        R
                  R                  R                  5       S95        UR                  R                  (       d  UR                  R                  (       aJ  UR                  [        R                  " S[        R
                  R                  R                  5       S95        UR                  (       aJ  UR                  [        R                  " S[        R
                  R                  R                  5       S95        U$ )z&Add a tracker to the progress tracker.zBuilding container z from source...)	container)keyzCreating secrets...zCreating volumes...zCreating configs...)source_buildsappendr   StagestagesStagedProgressTrackerStageBUILDget_keysecretsSECRETSvolumes
bind_mountnamed_volumeVOLUMESconfigsCONFIGS)r]   ra   staged_operationscontainer_names       r"   rT   Up._AddTrackerStages   sG   "00.  ""%n%5_E55;;CC, D 	
 1 ~~

 
 #33;;CCE ~~  FNN$?$?

 
 #33;;CCE ~~

 
 #33;;CCE r%    N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr#   r'   ri   r   rw   rt   r}   r{   rT   __static_attributes__r   r%   r"   r   r   '   sg     8	- 	 	  cJB/Q"r%   r   )#r   r   googlecloudsdk.api_lib.runr   googlecloudsdk.callioper   $googlecloudsdk.command_lib.artifactsr   #googlecloudsdk.command_lib.projectsr   ru   googlecloudsdk.command_lib.runr   r   r	   r
   r   &googlecloudsdk.command_lib.run.composer   r   r   googlecloudsdk.corer   r   r   googlecloudsdk.core.consoler   ry   ReleaseTracksr?   ALPHABETADefaultUniverseOnlyBinaryBackedCommandr   r   r%   r"   <module>r      s    G 	 2 ( < E < 5 0 7 - C D # ' * 8 .  D%%++T->->-C-CDn	!	! n  Enr%   