
                         2   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Jr  SS
KJr  SSKJr  SSKJr  SSKJr  \
R*                  " \
R,                  R.                  5      \
R0                   " S S\
R2                  5      5       5       rg)z#Create GCB v2 repo trigger command.    )absolute_import)division)unicode_literals)cloudbuild_util)trigger_config)base)concepts)resource_args)concept_parsers)log)
properties)	resourcesc                   <    \ rS rSrSrSS0r\S 5       rS rS r	Sr
g	)
CreateRepository    z/Create a build trigger for a GCB v2 repository.EXAMPLESa              To create a push trigger for all branches:

              $ {command} --name="my-trigger" --service-account="projects/my-project/serviceAccounts/my-byosa@my-project.iam.gserviceaccount.com" --repository=projects/my-project/locations/my-location/connections/my-connection/repositories/my-repository --branch-pattern=".*" --build-config="cloudbuild.yaml"

            To create a pull request trigger for master:

              $ {command} --name="my-trigger" --service-account="projects/my-project/serviceAccounts/my-byosa@my-project.iam.gserviceaccount.com" --repository=projects/my-project/locations/my-location/connections/my-connection/repositories/my-repository --pull-request-pattern="^master$" --build-config="cloudbuild.yaml"
          c                    [         R                  " SS[         R                  [        R                  " 5       S9n[
        R                  R                  SUSSS9R                  U 5        [        R                  " 5       n[        R                  " U SS	9nUR                  S
SSS9  UR                  SS9n[        R                  " U5        [        R                   " U5        UR#                  SS9nUR                  SSSSS9  UR                  SUR$                  R&                  R(                  SS9  [        R*                  " USS9n[        R,                  " USS9  [        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.
cloudbuild.projects.locationsregion)resource_name
projectsIdlocationsIdz--regionzCloud regionTrequiredF)add_region_flagz--repositoryz'Resource name of the GCB v2 repository.)helpr   zPull Request settings)r   z--pull-request-patternREGEXa  A regular expression specifying which base git branch to match for
pull request events.

This pattern is used as a regex search for the base branch (the branch you are
trying to merge into) for pull request updates.
For example, --pull-request-pattern=foo will match "foo", "foobar", and "barfoo".

The syntax of the regular expressions accepted is the syntax accepted by
RE2 and described at https://github.com/google/re2/wiki/Syntax.
)metavarr   r   z--comment-controlzkRequire a repository collaborator or owner to comment '/gcbrun' on a pull request before running the build.)defaultr   )add_docker_args)require_docker_imageN)r	   ResourceSpec DEFAULT_PROJECT_ATTRIBUTE_CONFIGr
   RegionAttributeConfigr   ConceptParserForResourceAddToParserr   GetMessagesModuletrigger_utilsAddTriggerArgsadd_argumentadd_mutually_exclusive_groupAddBranchPatternAddTagPatternadd_argument_groupPullRequestFilterCommentControlValueValuesEnumCOMMENTS_ENABLEDAddBuildConfigArgsAddBuildDockerArgsAddRepoEventArgs)parserregion_specmessagesflag_config
ref_config	pr_configbuild_configs          0lib/surface/builds/triggers/create/repository.pyArgsCreateRepository.Args3   si    '''<<!779	;K
 !!--	 .  #{6*002H..vuMKF   9949HJ"":.
+--3J-KI 
	   **HH		|	   	((eL $$\M"";/    c                 D   [         R                  " 5       n[        R                  " X5      u  p4U(       a  U$ UR	                  UR
                  S9nUR                  (       ad  UR                  UR                  S9Ul        UR                  (       a4  UR                  R                  UR                  5      UR                  l        O)UR                  UR                  UR                  S9Ul        XSl        [        R"                  " X1USS9  [        R$                  " X15        U$ )zParses command line arguments into a build trigger.

Args:
  args: An argparse arguments object.

Returns:
  A build trigger object.

Raises:
  RequiredArgumentException: If comment_control is defined but
  pull_request_pattern isn't.
)
repository)branch)rC   tagN)default_image)r   r(   r)   ParseTriggerArgsRepositoryEventConfigrB   pull_request_patternr0   pullRequestcomment_controlr1   commentControl
PushFilterbranch_patterntag_patternpushrepositoryEventConfigParseBuildConfigArgsParseRepoEventArgs)selfargsr8   triggerdonerepos         r=   ParseTriggerFromFlags&CreateRepository.ParseTriggerFromFlagsj   s     002H!224BMGn ))T__)ED  !33** 4 ,d			*2*D*D*b*b  +"' %%$$$*:*: & <di$(!&&xt5$$W3Nr@   c           	         [         R                  " 5       n[         R                  " 5       nU R                  U5      n[        R
                  R                  R                  R                  SS9nUR                  nUc1  [        R
                  R                  R                  R                  SS9nUR                  S5      S   n[        R                  R                  SUUS9R                  5       nUR                   R                  UR#                  XtS95      n[        R                  R%                  SS	S
UUUR&                  S.S9n	[(        R*                  " U	5        U$ )zThis 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.
Tr   N/r   )
collectionr   r   )parentbuildTriggerz&cloudbuild.projects.locations.triggersv1)r   r   
triggersId)r]   api_versionparams)r   GetClientInstancer(   rX   r   VALUEScoreprojectGetr   buildssplitr   REGISTRYCreateRelativeNameprojects_locations_triggers0CloudbuildProjectsLocationsTriggersCreateRequestParseidr   CreatedResource)
rS   rT   clientr8   rU   rg   locationr^   created_triggertrigger_resources
             r=   RunCreateRepository.Run   sO    ..0F002H((.G $$,,00$0?G{{H""))0044d4Ch~~c"2&H&&2 '  +ln  88??AA 	B 	12O !))//;!#),,
	 0  ()r@    N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr>   rX   rw   __static_attributes__ry   r@   r=   r   r       s8     8 - 40 40l%N)r@   r   N)r~   
__future__r   r   r   !googlecloudsdk.api_lib.cloudbuildr   r   r)   googlecloudsdk.callioper    googlecloudsdk.calliope.conceptsr	   %googlecloudsdk.command_lib.cloudbuildr
   (googlecloudsdk.command_lib.util.conceptsr   googlecloudsdk.corer   r   r   ReleaseTracksReleaseTrackALPHAHiddenCreateCommandr   ry   r@   r=   <module>r      su    * &  ' = M ( 5 ? D # * ) D%%++,Wt)) W  -Wr@   