
    e&                     .   S 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r " S
 S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\R*                  5      rS rg	)z-Flags for serverless local development setup.    )absolute_import)division)unicode_literals)arg_parsers)base)map_util)
exceptionsNc                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
FlagDef   z<Object that holds a flag definition and adds it to a parser.c                     Xl         X l        g N)namekwargsselfr   r   s      ,lib/googlecloudsdk/command_lib/code/flags.py__init__FlagDef.__init__   s    IK    c                 4    U R                   UR                   :H  $ r   r   r   others     r   __eq__FlagDef.__eq__"       99

""r   c                 4    U R                   UR                   :g  $ r   r   r   s     r   __ne__FlagDef.__ne__%   r   r   c                 ,    [        U R                  5      $ r   )hashr   r   s    r   __hash__FlagDef.__hash__(   s    		?r   c                 R    UR                   " U R                  40 U R                  D6  g r   )add_argumentr   r   )r   parsers     r   ConfigureParserFlagDef.ConfigureParser+   s    
		1T[[1r   )r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   r   r$   r)   __static_attributes__ r   r   r   r      s    D##2r   r   c                   0    \ rS rSrSrS rS rS rS rSr	g)	FlagDefs/   z Base type for all flag builders.c                 "    [        5       U l        g r   )set_operationsr#   s    r   r   FlagDefs.__init__2   s    uDr   c                 :    U R                  [        U40 UD65        g r   )_AddOperationr   r   s      r   _AddFlagFlagDefs._AddFlag5   s    wt.v./r   c                 :    U R                   R                  U5        g r   )r7   add)r   	operations     r   r:   FlagDefs._AddOperation8   s    #r   c                 L    U R                    H  nUR                  U5        M     g r   )r7   r)   )r   r(   r?   s      r   r)   FlagDefs.ConfigureParser;   s     %%	' &r   )r7   N)
r+   r,   r-   r.   r/   r   r;   r:   r)   r0   r1   r   r   r3   r3   /   s    (0$(r   r3   c                       \ rS rSrSrS rSrg)MutuallyExclusiveGroupDef@   zEFlag builder where all flags are added to a mutually exclusive group.c                 j    UR                  SS9nU R                   H  nUR                  U5        M     g )NF)required)add_mutually_exclusive_groupr7   r)   )r   r(   groupops       r   r)   )MutuallyExclusiveGroupDef.ConfigureParserC   s3    ///?E r   r1   N)r+   r,   r-   r.   r/   r)   r0   r1   r   r   rD   rD   @   s
    M r   rD   c                   $    \ rS rSrSrS rS rSrg)BuilderFlagsI   zFlags for builder settings.c                 &    U R                  SSSS9  g )Nz--dockerfile
Dockerfilez!Dockerfile for the service image.)defaulthelpr;   r#   s    r   AddDockerfileBuilderFlags.AddDockerfileL   s    MM0  2r   c                 $    U R                  SSS9  g )Nz	--builderzGBuild with a given Cloud Native Computing Foundation Buildpack builder.rR   rS   r#   s    r   
AddBuilderBuilderFlags.AddBuilderR   s    MM  r   r1   N)r+   r,   r-   r.   r/   rT   rX   r0   r1   r   r   rM   rM   I   s    #2r   rM   c                        \ rS rSrS rS rSrg)CredentialFlagsY   c                 $    U R                  SSS9  g )Nz--service-accountzMWhen connecting to Google Cloud Platform services, use a service account key.rW   rS   r#   s    r   AddServiceAccount!CredentialFlags.AddServiceAccount[   s    MM  r   c                 (    U R                  SSSSS9  g )Nz --application-default-credential
store_trueFzZWhen connecting to Google Cloud Platform services, use the application default credential.)actionrQ   rR   rS   r#   s    r   AddApplicationDefaultCredential/CredentialFlags.AddApplicationDefaultCredentiala   s!    MM**	  +r   r1   N)r+   r,   r-   r.   r^   rc   r0   r1   r   r   r[   r[   Y   s    +r   r[   c                   $    \ rS rSrSrS rS rSrg)EnvVarFlagsj   zEnvironment variable flags.c           
          U R                  SS[        R                  [        R                  " [        R
                  [        R
                  S9SS9  g )Nz
--env-vars	KEY=VALUEkey_type
value_typez8List of key-value pairs to set as environment variables.metavarrb   typerR   r;   r   UpdateActionArgDictsix	text_typer#   s    r   
AddEnvVarsEnvVarFlags.AddEnvVarsm   sA    MM''  ]]s}}>G  Ir   c           	          U R                  SS[        R                  " [        R                  [        R                  S9SS9  g )Nz--env-vars-file	FILE_PATHrj   zIPath to a local YAML file with definitions for all environment variables.)rn   ro   rR   )r;   r   ArgDictFilers   rt   r#   s    r   AddEnvVarsFileEnvVarFlags.AddEnvVarsFilev   s9    MM!!]]s}}>  r   r1   N)r+   r,   r-   r.   r/   ru   rz   r0   r1   r   r   rf   rf   j   s    #Ir   rf   c                      ^  \ rS rSrSrU 4S jrS rS rS rS r	S r
S	 rS
 rS rSS jrS rS rS rS rS rS rS rS rS rS rSrU =r$ )CommonFlags   z;Flags that are common between the gcloud code dev commands.c                 8   > [         [        U ]  5         0 U l        g r   )superr}   r   _group_cache)r   	__class__s    r   r   CommonFlags.__init__   s    	+t%'Dr   c                 .    U R                  S[        SS9  g )Nz--local-portzoLocal port to which the service connection is forwarded. If this flag is not set, then a random port is chosen.ro   rR   )r;   intr#   s    r   AddLocalPortCommonFlags.AddLocalPort   s    MM9  :r   c                 $    U R                  SSS9  g )Nz--sourcez^The directory containing the source to build. If not specified, the current directory is used.rW   rS   r#   s    r   	AddSourceCommonFlags.AddSource   s    MM;  <r   c                 &    U R                  SSSS9  g )Nz--service-nameFzName of the service.rG   rR   rS   r#   s    r   AddServiceNameCommonFlags.AddServiceName   s    MM"U9OMPr   c                 &    U R                  SSSS9  g )Nz--imageFzName for the built image.r   rS   r#   s    r   AddImageCommonFlags.AddImage   s    MM)e2MMNr   c                 J    U R                  S[        R                  " SS9SS9  g )Nz--memoryB)default_unitzContainer memory limit. Limit is expressed either as an integer representing the number of bytes or an integer followed by a unit suffix. Valid unit suffixes are "B", "KB", "MB", "GB", "TB", "KiB", "MiB", "GiB", "TiB", or "PiB".r   )r;   r   
BinarySizer#   s    r   	AddMemoryCommonFlags.AddMemory   s)    MM##5)  *r   c                 J    U R                  S[        R                  " SS9SS9  g )Nz--cpug        )lower_boundzjContainer CPU limit. Limit is expressed as a number of CPUs. Fractional CPU limits are allowed (e.g. 1.5).r   )r;   r   BoundedFloatr#   s    r   AddCpuCommonFlags.AddCpu   s)    MM%%#68  9r   c                 N    U R                  S[        R                  " 5       SSS9  g )Nz--cloudsql-instancesCLOUDSQL_INSTANCEzYCloud SQL instance connection strings. Must be in the form <project>:<region>:<instance>.)ro   rn   rR   )r;   r   ArgListr#   s    r   AddCloudsqlInstances CommonFlags.AddCloudsqlInstances   s*    MM  "#)	  *r   c                 *    U R                  SSSSSS9  g )Nz--readiness-probeFra   TzAdd a readiness probe to the list of containers that delays deployment stabilization until the application app has bound to $PORTrQ   rb   hiddenrR   rS   r#   s    r   AddReadinessProbeCommonFlags.AddReadinessProbe   s(     	MMP  Qr   c                 D    SnU(       a  US-  nU R                  SSSUS9  g)z_AddFlag for service_config, which has two possible help strings.

Args:
  include_app_engine_docs: Add paragraph that says app.yaml is allowed.
zservice.yaml filename override. Defaults to the first file matching ```*service.dev.yaml``` then ```*service.yaml```, if any exist. This path is relative to the --source dir.a  
An App Engine config path (typically ```app.yaml```) may also be provided here, and we will build with a Cloud Native Computing Foundation Buildpack builder selected from gcr.io/gae-runtimes/buildpacks, according to the App Engine ```runtime``` specified in app.yaml.service_configSERVICE_CONFIG?)rn   nargsrR   NrS   )r   include_app_engine_docs	help_texts      r   AddServiceConfigPositionalArg)CommonFlags.AddServiceConfigPositionalArg   s?    	<  12i 	MM 	  r   c                 B    U R                  S[        R                  SS9  g )Nz--allow-secret-managerzBSuppress warnings if secrets need to be pulled from secret manager)rb   rR   )r;   r   StoreTrueFalseActionr#   s    r   AddAllowSecretManagerFlag%CommonFlags.AddAllowSecretManagerFlag   s$    MM //  r   c           
          U R                  SS[        R                  [        R                  " [        R
                  [        R
                  S9SS9  g )Nz	--secretsri   rj   z*List of key-value pairs to set as secrets.rm   rp   r#   s    r   
AddSecretsCommonFlags.AddSecrets   s@    MM''  ]]s}}>9  ;r   c                 L    U R                  SSSSSS9  U R                  SSSS	9  g )
Nz--cloudFra   Tzdeploy code to Cloud Runr   z--regionz region to deploy the dev service)rR   r   rS   r#   s    r   AddCloudCommonFlags.AddCloud   s>    MM'  ) 	MM;D  Jr   c                     XR                   ;  a&  U" 5       nX R                   U'   U R                  U5        U R                   U   $ r   )r   r:   )r   klassrI   s      r   	_GetGroupCommonFlags._GetGroup   sB    %%%ge!&
U##r   c                 ,    U R                  [        5      $ r   )r   r[   r#   s    r   CredentialsGroupCommonFlags.CredentialsGroup   s    >>/**r   c                 ,    U R                  [        5      $ r   )r   rf   r#   s    r   EnvVarsGroupCommonFlags.EnvVarsGroup   s    >>+&&r   c                 ,    U R                  [        5      $ r   )r   rM   r#   s    r   BuildersGroupCommonFlags.BuildersGroup   s    >>,''r   c                     U R                  5         U[        R                  R                  :X  a  U R	                  5         U[        R                  R                  :H  nU R                  US9  g )N)r   )_AddBetaFlagsr   ReleaseTrackALPHA_AddAlphaFlagsr   )r   release_trackappyaml_supports      r   AddAlphaAndBetaFlags CommonFlags.AddAlphaAndBetaFlags  sW    ))///
 $t'8'8'>'>>O&&&Or   c                    U R                  5       R                  5         U R                  5         U R                  5         U R	                  5       R                  5         U R	                  5       R                  5         U R                  5         U R                  5         U R                  5         U R                  5       R                  5         g)z0Set up flags that are for alpha and beta tracks.N)r   rT   r   r   r   r^   rc   r   r   r   rX   r#   s    r   r   CommonFlags._AddBetaFlags  s    &&(NN--/;;=""$OO##%r   c                 <   U R                  5         U R                  5         U R                  5         U R                  5         U R	                  5         U R                  5       R                  5         U R                  5       R                  5         U R                  5         g)z+Set up flags that are for alpha track only.N)	r   r   r   r   r   r   ru   rz   r   r#   s    r   r   CommonFlags._AddAlphaFlags  sk     	MMONNKKM""$&&(MMOr   )r   )F)r+   r,   r-   r.   r/   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r0   __classcell__)r   s   @r   r}   r}      st    C:<QO*9*
Q4;J$+'(P
&
 
r   r}   c                       \ rS rSrSrSrg)InvalidFlagErrori&  zFlag settings are illegal.r1   N)r+   r,   r-   r.   r/   r0   r1   r   r   r   r   &  s    "r   r   c                     SU ;   aP  U R                  S5      (       a9  U R                  S5      (       d"  U R                  S5      (       d  [        S5      egggg)z>Validate flag requirements that cannot be handled by argparse.cloudsql_instancesservice_accountapplication_default_credentialzd--cloudsql-instances requires --service-account or --application-default-credential to be specified.N)IsSpecifiedr   )	namespaces    r   Validater   *  sj    i'011  !233  !ABB
 O P P C 4 2 (r   )r/   
__future__r   r   r   googlecloudsdk.callioper   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer	   rs   objectr   r3   rD   rM   r[   rf   r}   Errorr   r   r1   r   r   <module>r      s    4 &  ' / ( 9 * 
2f 2((v ("   ,  +/ +"+ ,c( cL#z'' #Pr   