
    $                        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SKJr  SSKJr  SSKrSr\R@                  " \RB                  RD                  \RB                  RF                  5      \RH                   " S S\RJ                  5      5       5       r&g)zCommand to register an Attached cluster with the fleet.

This command performs the full end-to-end steps required to attach a cluster.
    N)attached)	locations)base)cluster_util)flags)resource_args)	kube_util)command_util)	constants)endpoint_util)errors)
exceptions)pretty_print)
console_io)retryaD  
Register a cluster to a fleet.

To register a cluster with a private OIDC issuer, run:

$ {command} my-cluster --location=us-west1 --platform-version=PLATFORM_VERSION --fleet-project=FLEET_PROJECT_NUM --distribution=DISTRIBUTION --context=CLUSTER_CONTEXT --has-private-issuer

To register a cluster with a public OIDC issuer, run:

$ {command} my-cluster --location=us-west1 --platform-version=PLATFORM_VERSION --fleet-project=FLEET_PROJECT_NUM --distribution=DISTRIBUTION --context=CLUSTER_CONTEXT --issuer-url=https://ISSUER_URL

To specify a kubeconfig file, run:

$ {command} my-cluster --location=us-west1 --platform-version=PLATFORM_VERSION --fleet-project=FLEET_PROJECT_NUM --distribution=DISTRIBUTION --context=CLUSTER_CONTEXT --has-private-issuer --kubeconfig=KUBECONFIG_PATH

To register and set cluster admin users, run:

$ {command} my-cluster --location=us-west1 --platform-version=PLATFORM_VERSION --fleet-project=FLEET_PROJECT_NUM --distribution=DISTRIBUTION --context=CLUSTER_CONTEXT --issuer-url=https://ISSUER_URL --admin-users=USER1,USER2

To specify custom tolerations and labels for system component pods, run:

$ {command} my-cluster --location=us-west1 --platform-version=PLATFORM_VERSION --fleet-project=FLEET_PROJECT_NUM --distribution=DISTRIBUTION --context=CLUSTER_CONTEXT --system-component-tolerations=TOLERATIONS --system-component-labels=LABELS

where TOLERATIONS have the format:
  key=value:Effect:NoSchedule (examples: key1=value1:Equal:NoSchedule,key2:Exists:PreferNoSchedule, :Exists:NoExecute)
and LABELS have the format:
  key=value (examples: key1=value1,key2="")
c                   N    \ rS rSrSrS\0r\S 5       rS r	S r
S rS rS	 rS
rg)RegisterH   zRegister an Attached cluster.EXAMPLESc                    [         R                  " U S5        [        R                  " U 5        [        R                  " U 5        [        R
                  " U SS9  [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U S5        [        R                  " U 5        [        R                   " U 5        [        R"                  " U S5        [        R$                  " U SS5        [        R&                  " U 5        [        R(                  " U 5        [        R*                  " U 5        [        R,                  " U 5        U R.                  R1                  [2        R4                  5        g)z!Registers flags for this command.zto registerT)requiredzcluster to createN)r   AddAttachedClusterResourceArgattached_flagsAddPlatformVersionAddRegisterOidcConfigAddDistributionAddAdminUsers
AddKubectlAddProxyConfigAddSkipClusterAdminCheckAddSystemComponentTolerationsAddSystemComponentLabelsr   AddAnnotationsAddValidateOnlyAddFleetProjectAddDescription
AddLoggingAddMonitoringConfigAddBinauthzEvaluationModeAddAdminGroups AddWorkloadVulnerabilityScanningAddResourceManagerTagsdisplay_info	AddFormatr   ATTACHED_CLUSTERS_FORMAT)parsers    3lib/surface/container/attached/clusters/register.pyArgsRegister.ArgsO   sC    //F%%f-((0""6D9  (f%!!&)++F3008++F3	 	&"56	&!	 	VT"	fdD1	##F+	 	**62	  (
!!)"D"DE    c           	         [         R                  " U5      R                  n[        R                  " U5      (       a0  [        R
                  " U5      S:X  a  [        R                  " S5      e[        R                  " U5        [        R                  " U5         [         R                  " U5      nU R                  X5      n[        R                  " [        R                  " U5      [        R                  " U5      SS9 n[        R                   " U5      (       d  UR#                  5         [        R                  " U5      (       aC  [$        R&                  " S5        U R)                  U5      u  pg[+        USU5        [+        USU5         [,        R.                  " U5      (       dw  [$        R&                  " S5        UR1                  U5        [2        R4                  " [6        R8                  S	9nUR;                  [<        R>                  U4[6        R@                  S
9  U RC                  X5      n	U RG                  XU5        S S S 5        W	sS S S 5        $ ! [2        RD                   ac  n
U RG                  XU5        U
RH                  S   (       a7  [J        RL                  " U
RH                  S   S   U
RH                  S   S   5        e S n
A
f[N        RP                   aI    SRS                  U[        RT                  " U5      URV                  5      n[$        R&                  " U5        e   U RG                  XU5        e = f! , (       d  f       GN= f! , (       d  f       g = f)NekszEDistributions of type "eks" cannot use the `has-private-issuer` flag.T)
kubeconfigcontextenable_workload_identityz!Fetching cluster OIDC information
issuer_url	oidc_jwksz!Creating in-cluster install agent)max_retrials)argssleep_ms      zTo manually clean up the in-cluster install agent, run:

$ gcloud container attached clusters generate-install-manifest --location={} --platform-version={} --format="value(manifest)"  {}  | kubectl delete -f -

AFTER the attach operation completes.
),r   ParseAttachedClusterResourceArglocationsIdr   GetHasPrivateIssuerGetDistributionrun_exceptionsArgumentErrorGetSystemComponentTolerationsr   GkemulticloudEndpointOverride_get_manifestr	   KubernetesClientGetKubeconfig
GetContextGetSkipClusterAdminCheckCheckClusterAdminPermissionsr   Info_get_authoritysetattrr   GetValidateOnlyApplyr   Retryerr   %ATTACHED_INSTALL_AGENT_VERIFY_RETRIESRetryOnExceptionr   verify_install_agent_deployed%ATTACHED_INSTALL_AGENT_VERIFY_WAIT_MS_create_attached_clusterRetryException_remove_manifestlast_resultr   reraiser   OperationCancelledErrorformatGetPlatformVersionattachedClustersId)selfr=   locationcluster_refmanifestkube_clientr:   jwksretryercreate_respemsgs               r1   RunRegister.Runk   s   <<TBNNH**400**40E9(( 
 006		4	4X	>!AA$Gk##D6h%%#11$7 ++D1#' 66t<<

2
2
4--d33


?
@!00=
*
$j
1
$T
*&	&&t,,ABh'mm&LLG $$::!^"HH %  55dH+6 	d:mp y 
?	>@ ## 	


8
<
 ]]1q}}Q/2AMM!4DQ4GH
11 	
 F//5,,  

C
 
	


8
<
i 	 
?	>sM   A&M>B
L9	B#I,L9>	ML6%AKA3L66L99
M	M
Mc                 b    [         R                  " 5       nUR                  X!S9nUR                  $ )N)r=   )loc_utilLocationsClientGenerateInstallManifestre   )rb   r=   rd   location_clientresps        r1   rI   Register._get_manifest   s-    ..0O22;2JD==r4   c                     [         R                  " U5      (       d(  [        R                  " S5        UR	                  U5        g g )Nz!Deleting in-cluster install agent)r   rR   r   rO   Delete)rb   r=   rf   re   s       r1   r[   Register._remove_manifest   s5      &&;<" 'r4   c                     [         R                  " UR                  5       SS9n[        R                  " U5      R                  S5      nU(       d  [        R                  " U5      eUR                  5       nX44$ )Nzutf-8)encodingissuer)	six
ensure_strGetOpenIDConfigurationjsonloadsgetr   MissingOIDCIssuerURLGetOpenIDKeyset)rb   rf   openid_config_jsonr:   rg   s        r1   rP   Register._get_authority   sg    **,w ./33H=J''(:;;&&(Dr4   c                     [         R                  " 5       n[        R                  " UR                  S[
        R                  S9n[        R                  " UUUU[
        R                  S9$ )NCreating)actionkind)resource_refresource_clientr=   messager   )	api_utilClustersClientr
   ClusterMessagera   r   ATTACHEDCreateATTACHED_CLUSTER_KIND)rb   r=   rd   cluster_clientr   s        r1   rY   !Register._create_attached_cluster   s_    ,,.N))&&G
  &,, r4    N)__name__
__module____qualname____firstlineno____doc__	_EXAMPLESdetailed_helpstaticmethodr2   rl   rI   r[   rP   rY   __static_attributes__r   r4   r1   r   r   H   s@     &y)-F F6HT
#
r4   r   )'r   r~   .googlecloudsdk.api_lib.container.gkemulticloudr   r   r   ro   googlecloudsdk.callioper   -googlecloudsdk.command_lib.container.attachedr   r   r   r   *googlecloudsdk.command_lib.container.fleetr	   2googlecloudsdk.command_lib.container.gkemulticloudr
   r   r   r   googlecloudsdk.command_lib.runr   rE   r   googlecloudsdk.coregooglecloudsdk.core.consoler   googlecloudsdk.core.utilr   r{   r   ReleaseTracksReleaseTrackALPHAGADefaultUniverseOnlyCreateCommandr   r   r4   r1   <module>r      s   
  O P ( F Q G @ K H L E D G 7 * 2 * 
	< D%%++T->->-A-ABLt!! L  CLr4   