
    Y-                        S 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S.rSrSrS r\R<                  " \R>                  R@                  \R>                  RB                  \R>                  RD                  5      \RF                   " S S\RH                  5      5       5       r%g)zCreate a release.    N)client_util)release)base)
exceptions)delivery_pipeline_util)deploy_policy_util)deploy_util)flags)promote_util)release_util)resource_args)log)	resources)files)timesz{description}a       To create a release with source located at storage URL `gs://bucket/object.zip`
    and the first rollout in the first target of the promotion sequence:

       $ {command} my-release --source=`gs://bucket/object.zip` --delivery-pipeline=my-pipeline --region=us-central1

    To create a release with source located at current directory
    and deploy a rollout to target prod :

      $ {command} my-release --delivery-pipeline=my-pipeline --region=us-central1 --to-target=prod

    The following command creates a release without a `skaffold.yaml` as input, and generates one
    for you:

      $ {command} my-release --delivery-pipeline=my-pipeline --region=us-central1 --from-k8s-manifest=path/to/kubernetes/k8.yaml

    The current UTC date and time on the machine running the gcloud command can
    also be included in the release name by adding $DATE and $TIME parameters:

      $ {command} 'my-release-$DATE-$TIME' --delivery-pipeline=my-pipeline --region=us-central1

    If the current UTC date and time is set to 2021-12-21 12:02, then the created release
    will have its name set as my-release-20211221-1202.

    When using these parameters, please be sure to wrap the release name in single quotes
    or else the template parameters will be overridden by environment variables.
    )DESCRIPTIONEXAMPLESr      c                 2   [         R                  " U SSS9  [        R                  " U 5        [        R                  " U 5        [        R
                  " U 5        [        R                  " U 5        [        R                  " U S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        [        R&                  " U 5        [        R(                  " U 5        g)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.
T)
positionalrequiredzDescription of the release.N)r   AddReleaseResourceArgr
   AddGcsSourceStagingDirFlagAddImagesGroupAddIgnoreFileFlagAddToTargetFlagAddDescriptionAddAnnotationsFlag_RELEASEAddLabelsFlagAddDockerVersionAddHelmVersionAddKptVersionAddKubectlVersionAddKustomizeVersionAddSkaffoldVersionAddSkaffoldSourcesAddInitialRolloutGroupAddDeployParametersFlagAddOverrideDeployPoliciesparsers    %lib/surface/deploy/releases/create.py_CommonArgsr.   I   s    %%fM""6*v&!v<=68,fh' vf&!F#6"6"v&'!!&)    c                   8    \ rS rSrSr\r\S 5       rS r	S r
Srg)Created   z3Creates a new release, delivery pipeline qualified.c                     [        U 5        g )N)r.   r+   s    r-   ArgsCreate.Argsm   s
    r/   c                    S nUR                   nUc  gUR                  =(       dX    UR                  =(       dE    UR                  =(       d2    UR                  =(       d    UR
                  =(       d    UR                  nU(       d  UR                  c  gU" UR                  R                  5      nUbm  U[        R                  " 5       -
  [        R                  " [        S9::  a;  [        R                  R!                  SR#                  UR%                  S5      S95        g[&        R(                  R*                  UR                  4[&        R(                  R,                  UR                  4[&        R(                  R.                  UR                  4[&        R(                  R0                  UR                  4[&        R(                  R2                  UR
                  4[&        R(                  R4                  UR                  4/n/ nU Hj  u  pU	(       d  M  U" U	R                  5      nUc  M%  U[        R                  " 5       -
  [        R                  " [        S9::  d  MY  UR7                  U5        Ml     U(       aO  SR9                  U Vs/ s H  oR:                  PM     sn5      n
[        R                  R!                  SU
 S	35        ggs  snf )
z>Checks to see if a release is close to the maintenance window.c                     U c  g [         R                  " U 5      $ ! [         R                  [         R                  4 a     gf = f)z8Parses the maintenance dt, returning a datetime or None.N)r   ParseDateTimeDateTimeSyntaxErrorDateTimeValueError)dts    r-   _ParseDt0Create._CheckIfNearMaintenance.<locals>._ParseDtt   sC    	""2&&'')A)AB s    $AAN)daysa!  WARNING: This release's Skaffold version will be in maintenance mode beginning on {date}. After that you won't be able to create releases using this version of Skaffold.
https://cloud.google.com/deploy/docs/using-skaffold/select-skaffold#skaffold_version_deprecation_and_maintenance_policyz%Y-%m-%d)datez, z'WARNING: The versions used for tools: [z] will be in maintenance mode soon. After that you won't be able to create releases using these versions of the tools.
https://cloud.google.com/deploy/docs/select-tool-version)	conditiondockerVersionSupportedConditionhelmVersionSupportedConditionkptVersionSupportedCondition kubectlVersionSupportedCondition"kustomizeVersionSupportedCondition!skaffoldVersionSupportedConditionskaffoldSupportedConditionmaintenanceModeTimer   Nowdatetime	timedelta_MAINTENANCE_WARNING_DAYSr   statusPrintformatstrftimer   ToolsDOCKERHELMKPTKUBECTL	KUSTOMIZESKAFFOLDappendjoinvalue)selfrelease_objr<   release_conditionhas_tool_versionsmaintenance_dt$tools_supported_condition_to_processtools_almost_in_maintenancetoolr@   joineds              r-   _CheckIfNearMaintenanceCreate._CheckIfNearMaintenanceq   s    $--  	99 	?::	?99	? ==	? ??		?
 >>  		5	5	=

6
6
J
Jn 
$uyy{*%>?@ 	

& '-f#,,Z8 '- '
	
 
 %%==	

 ##;;	

 ""::	

 &&>>	

 ((@@	

 ''??	
+,(4 #%?	 = =>n

$uyy{*%>?@ 	$**40 @ #yy1LM1L**1LMNf	jj3F8 <E E #Ms   	K
c                 	   UR                   (       a(  UR                  (       a  [        R                  " SS5      e[        R
                  " UR                  R                  R                  5      UR                  R                  l        UR                  R                  R                  5       n[        R                  " UR                  5       R                  5       5      nSR                  UR                  5       5      n[        R                  " X45        UR                   (       Ga"  ["        R$                  R'                  UR                   5      (       a  UR(                  S:X  a  ["        R*                  " 5       nSnOUR(                  nSn[,        R.                  " XQR                   5      (       d0  [0        R2                  " SR                  UR                   U5      5      e["        R$                  R5                  ["        R$                  R7                  UR                   5      ["        R$                  R7                  U5      5      Ul        [        R8                  " 5       n[        R:                  " UR(                  UR<                  UR>                  UR@                  URB                  URD                  URF                  URH                  URJ                  URL                  URN                  URP                  UR                   URS                  5       S   URT                  URV                  URX                  UURZ                  5      n[\        R^                  " UR`                  U[\        Rb                  Rd                  URf                  URh                  5        URk                  X(5      n	[l        Rn                  Rq                  U	Rr                  S	S
9n
[t        Rv                  " 5       Ry                  X5        [z        R|                  R                  SR                  UR                  5       5      5        [        R8                  " 5       R                  UR                  5       5      nU R                  U5        UR                   (       a  U$ UR                  5       n[        R                  " XR                  5      n[        R                  " UUUR                  SUR                  UR                  UR                  US9nX4$ )zThis is what gets called when the user runs this command.

Args:
  args: All the arguments that were provided to this command invocation.

Returns:
  The release and rollout created.
z--disable-initial-rolloutz--to-targetzCannot create release {}..zcurrent working directorysourcez[The skaffold file {} could not be found in the {}. Please enter a valid Skaffold file path.locationsIdz)clouddeploy.projects.locations.operations)
collectionz Created Cloud Deploy release {}.T)	is_createlabelsannotationsstarting_phase_idoverride_deploy_policies)Kdisable_initial_rollout	to_targetc_exceptionsConflictingArgumentsExceptionr   RenderPatternCONCEPTSparsed_argsr   Parser   GetPipelineParentRelativeNamerO   ThrowIfPipelineSuspendedskaffold_fileospathisabsrh   getcwdr   IsDirAncestorOfcore_exceptionsErrorrelpathabspathReleaseClientCreateReleaseConfiggcs_source_staging_dirignore_fileimagesbuild_artifactsdescriptiondocker_versionhelm_versionkpt_versionkubectl_versionkustomize_versionskaffold_versionAsDictuidfrom_k8s_manifestfrom_run_manifestdeploy_parametersr	   SetMetadatamessagesResourceTypeRELEASErm   rl   r1   r   REGISTRYParseRelativeNamenamer   OperationsClientWaitForOperationr   rM   rN   NameGetrd   r   CreateDeployPolicyNamesFromIDsro   r   Promoteinitial_rollout_labelsinitial_rollout_annotationsinitial_rollout_phase_id)r[   argsrelease_refpipeline_objfailed_activity_msgrh   source_descriptionclientrelease_config	operationoperation_refr\   pipeline_refpoliciesrollout_resources                  r-   Run
Create.Run   s    ##66
%}  )5(B(B!!)))DMM% --''--/K)55))+L 6<<  " 33 bggmmD,>,>??		8%""6+=+=>>##++16""$6,
 	
 77??
''//$,,
-rwwv/Fd ""$F!55##]+'N,   (( k:I&&88#N 9 M   "33IMJJ*11+2B2B2DE '')--k.F.F.HIK  -## %%'L!@@33H $++**4477!)	 ((r/    N)__name__
__module____qualname____firstlineno____doc___DETAILED_HELPdetailed_helpstaticmethodr4   rd   r   __static_attributes__r   r/   r-   r1   r1   d   s+    
 < - _Bn)r/   r1   )&r   rJ   os.pathr}   "googlecloudsdk.api_lib.clouddeployr   r   googlecloudsdk.callioper   r   rr   !googlecloudsdk.command_lib.deployr   r   r	   r
   r   r   r   googlecloudsdk.corer   r   r   googlecloudsdk.core.utilr   r   r   r   rL   r.   ReleaseTracksReleaseTrackALPHABETAGADefaultUniverseOnlyCreateCommandr1   r   r/   r-   <module>r      s       : 6 ( > D @ 9 3 : : ; = # ) * * #<  *6 T..33T5F5F5I5I X)T X) X)r/   