
    [4                       S r SSKJr  SSKJr  SSKJr  SSK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K$r$Sr%Sr&Sr'Sr(Sr)Sr*Sr+Sr,Sr-Sr.Sr/Sr0S r1S!r2S"r3S#r4S$r5S%r6S&r7S'r8S(r9S)r:S*r;S+r<S,r=S-r>S.r?S/r@S0rAS1rBS2rCS3rDS4rES5rFS6rGS7rHS8rIS7rJS9rKS:rLS;rMS<rNS=rOS>rPS?rQS@rRSArSSBrTSCrUSDrVSErWSFrXSGrYSHrZSIr[SJr\SKr]SLr^SMr_SNr`SOraS@rbSPrcSQrdSRreSSrfSTrgSUrhSVriSWrjSXrkS@rlSYrmS@rnSZroS[rpS\rqSLrrS]rsS^rtSMruSNrvS_rwS`rxSarySbrzScr{Sdr|SMr}Ser~SfrSgrShrSirSjrSkrSlr " Sm Sn\GR                  5      rSo rSprSqrSrrSsrStrSu rSv rSw rSx rSy rSz rS{ rS| rS} rS~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\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rS rS rS rS rS rS rS rS rSS jrSS jrS rSS jrSS jrS rSS jrSS jrS rSS jrS rSS jrS rS rS rS rS rS\4S jrg)z)Common utilities for the containers tool.    )absolute_import)division)unicode_literalsN)encoding)
exceptions)
kubeconfig)
enable_api)	arg_utils)config)log)
properties)yaml)store)resource_printer)update_manager)files)	platformsa  
    table(
        name,
        zone:label=LOCATION,
        master_version():label=MASTER_VERSION,
        endpoint:label=MASTER_IP,
        nodePools[0].config.machineType,
        currentNodeVersion:label=NODE_VERSION,
        firstof(currentNodeCount,initialNodeCount):label=NUM_NODES,
        status,
        ipAllocationPolicy.stackType.yesno(no='IPV4'):label=STACK_TYPE
    )
z
    table(
        name,
        operationType:label=TYPE,
        zone:label=LOCATION,
        targetLink.basename():label=TARGET,
        statusMessage,
        status,
        startTime,
        endTime
    )
z|
     table(
        name,
        config.machineType,
        config.diskSizeGb,
        version:label=NODE_VERSION
     )
z;ResponseError: code={status_code}, message={status_message}zNode version is specified while node auto-upgrade is enabled. Node-pools created at the specified version will be auto-upgraded whenever auto-upgrade preconditions are met.z Kubernetes Beta APIs are not stable, it is advised to use them with caution. Please read carefully about limitations and associated risks at https://cloud.google.com//kubernetes-engine/docs/how-to/use-beta-apis zR'--max-surge-upgrade' and '--max-unavailable-upgrade' must be used in conjunction.zinsecureKubeletReadonlyPortEnabled specified in both config file and by flag. Please specify either command line option or the value in the config file.         kubeletConfigcpuManagerPolicycpuCFSQuotacpuCFSQuotaPeriodpodPidsLimit"insecureKubeletReadonlyPortEnabledallowedUnsafeSysctlscontainerLogMaxSizecontainerLogMaxFilesimageGcHighThresholdPercentimageGcLowThresholdPercentimageMinimumGcAgeimageMaximumGcAgenodeSwapSizeGibmaxParallelImagePullslinuxConfigsysctl
cgroupModetransparentHugepageEnabledtransparentHugepageDefraghugepageConfighugepage_size2mhugepage_size1gmemoryManagerpolicytopologyManagerscopesingleProcessOomKillkernelOverrideskernelCommandlineOverridesspecRstackOverflowinitOnAlloclruGenenabledminTtlMsadditionalEtcHosts additionalEtcSystemdResolvedConfadditionalEtcResolvConftimeZonecustomNodeInit
initScriptgcsUrigcsGenerationargsiphostkeyvalue
swapConfigencryptionConfigdisabledbootDiskProfileephemeralLocalSsdProfilededicatedLocalSsdProfileswapSizeGibswapSizePercent	diskCountprivateRegistryAccessConfigwritableCgroupsregistryHostsserverhostsoverridePathheaderdialTimeoutcapabilitiesgcpSecretManagerSecretUricaclientcert certificateAuthorityDomainConfig!gcpSecretManagerCertificateConfig	secretURIfqdnsevictionSoftevictionSoftGracePeriodevictionMinimumReclaim evictionMaxPodGracePeriodSecondsc                       \ rS rSrSrSrg)Error   z.Class for errors raised by container commands. N)__name__
__module____qualname____firstlineno____doc____static_attributes__rh       ,lib/googlecloudsdk/api_lib/container/util.pyrf   rf      s    6ro   rf   c                     [         R                  " 5       n[        R                  " USR	                  U 5      US9  UR                  5       $ )Nzlist[title="{0}"])out)ioStringIOr   Printformatgetvalue)titleitemsbufs      rp   ConstructListr{      s7    
# 3 : :5 AsK	ro   zAccessing a Kubernetes Engine cluster requires the kubernetes commandline
client [kubectl]. To install, run
  $ gcloud components install kubectl
kubectlzCGROUP_MODE_V1 is deprecated. Please use CGROUP_MODE_V2 instead. For additional details, please refer to https://cloud.google.com/kubernetes-engine/docs/how-to/migrate-cgroupv2zNode pool {0} is running cgroupv1 which is deprecated. Please use cgroupv2 instead. For additional details, please refer to https://cloud.google.com/kubernetes-engine/docs/how-to/migrate-cgroupv2zhProblem checking cgroup mode of node pools:

{}

Please make sure the node pools are running cgroupv2`.
c                      [         R                  " 5       R                  bL  [        R                  R                  5       n [        R                  " U SS9nUR                  5       n[        U;   $ g )NF)platform_filterwarn)
r   Pathssdk_rootr   PlatformCurrentr   UpdateManagerGetCurrentVersionsInformation_KUBECTL_COMPONENT_NAME)platformmanagerinstalled_componentss      rp   _KubectlInstalledAsComponentr      sZ    \\^(!!))+H**8%PG"@@B"&:::	 )ro   c                      [         R                  " [        5      n [        5       nU (       d"  U(       d  [        R
                  " [        5        gU (       a  U $ U$ )zBVerify that the kubectl component is installed or print a warning.N)
file_utilsFindExecutableOnPathr   r   r   warningMISSING_KUBECTL_MSG)
executable	components     rp   CheckKubectlInstalledr      s=    ../FG**,)
	KK#$!0y0ro   c                 `    SR                  U R                  U R                  U R                  S9$ )Nzchttps://console.cloud.google.com/kubernetes/workload_/gcloud/{location}/{cluster}?project={project})locationclusterproject)rv   zone	clusterId	projectId)cluster_refs    rp   GenerateClusterUrlr     s7    @
F####  ro   c                     U R                   R                  R                   H  nUR                  U:X  d  M  Us  $    [	        X5      eN)privateClusterConfigcrossConnectConfigry   
subnetworkMissingCrossConnectError)r   cross_connect_subnetworkitems      rp   (_GetCrossConnectConfigItemFromSubnetworkr     s>    **==CCd22k D 	!CCro   c                 0    [        X5      nUR                  $ )zFExtract endpoint for the kubeconfig from the cross connect subnetwork.)r   privateEndpoint)r   r   cross_connect_config_items      rp   "_GetCrossConnectSubnetworkEndpointr     s    F 
#	2	22ro   c                 N    U R                   R                  nUc  [        U 5      eU$ )z2Extract endpoint for the kubeconfig from the fqdn.)r   privateEndpointFqdnMissingPrivateFqdnError)r   fqdns     rp   _GetFqdnPrivateEndpointr     s(    		%	%	9	9$	\
!'
**	+ro   c                 &    U R                  SS5      $ )a  Converts a resource identifier (possibly a full URI) to the zonal format.

e.g., container.projects.locations.clusters (like
projects/foo/locations/us-moon1/clusters/my-cluster) ->
container.projects.zones.clusters (like
projects/foo/zones/us-moon1/clusters/my-cluster). While the locational format
is newer, we have to use a single one because the formats have different
fields. This allows either to be input, but the code will use entirely the
zonal format.

Args:
  path: A string resource name, possibly a URI (i.e., self link).

Returns:
  The string identifier converted to zonal format if applicable. Unchanged if
  not applicable (i.e., not a full path or already in zonal format).
z/locations/z/zones/)replace)paths    rp   LocationalResourceToZonalr   '  s    $ 
mY	//ro   c                    U R                   b\  U R                   R                  bE  U R                   R                  R                  (       d   U(       d  U(       d  U(       a  [        U 5      eU(       ay  U R                   bl  U R                   R                  bU  U R                   R                  R
                  (       d0  [        5       (       d  [        U 5      e[        R                  " S5        U(       dI  U R                   bG  U R                   R                  b0  U R                   R                  R                  (       d  [        U 5      $ U(       d  U(       d  U(       ax  U R                  (       d  [        U 5      eU R                  R                  (       d  [        U 5      eUb  [        X5      $ U(       a  [!        U 5      $ U R                  R                  $ U R"                  (       d  [%        U 5      eU R"                  $ )z<Get the cluster endpoint suitable for writing to kubeconfig.zRetrieving DNS endpoint for internal user even though allowExternalTraffic is disabled. Remove the --dns-endpoint flag if this is not intended.)controlPlaneEndpointsConfigipEndpointsConfigr8   IPEndpointsIsDisabledErrordnsEndpointConfigallowExternalTraffic_IsGoogleInternalUser#AllowExternalTrafficIsDisabledErrorr   r   _GetDNSEndpointr   NonPrivateClusterErrorr   MissingPrivateEndpointErrorr   r   endpointMissingEndpointError)r   use_internal_ipr   use_private_fqdnuse_dns_endpoints        rp   _GetClusterEndpointr   <  s|    ))5

-
-
?
?
K11CCKK	48H
$W
-- 

-
-
9

-
-
?
?
K

-
-
?
?
T
T !""/88	kk# ))5

-
-
?
?
K11CCKK7##04D''"7++''77'00+/
  $W--''777			
w
''			ro   c                    U R                   (       a@  U R                   R                  (       a%  U R                   R                  R                  (       d  [        U 5      eU R                   R                  R                  nUc  [	        U 5      eU$ )zLExtract dns endpoint for the kubeconfig from the ControlPlaneEndpointConfig.)r   r   r   MissingDnsEndpointConfigErrorMissingDNSEndpointError)r   dns_endpoints     rp   r   r   w  sj     
-
-00BB00BBKK
'
0044FFOO,
!'
**	ro   z)kubeconfig entry generated for {cluster}.c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r   i  z=Error for retrieving private fqdn of a cluster that has none.c                 ^   > [         [        U ]  SR                  UR                  5      5        g )Nz$cluster {0} is missing private fqdn.)superr   __init__rv   nameselfr   	__class__s     rp   r    MissingPrivateFqdnError.__init__  s%    	
!41.55gllCro   rh   ri   rj   rk   rl   rm   r   rn   __classcell__r   s   @rp   r   r     s    E ro   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r   i  zCError for retrieving DNSEndpoint config of a cluster that has none.c                 ^   > [         [        U ]  SR                  UR                  5      5        g )Nz)cluster {0} is missing DNSEndpointConfig.)r   r   r   rv   r   r   s     rp   r   &MissingDnsEndpointConfigError.__init__  s%    	
'73::7<<Hro   rh   r   r   s   @rp   r   r     s    K ro   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r   i  z<Error for retrieving DNSEndpoint of a cluster that has none.c                 ^   > [         [        U ]  SR                  UR                  5      5        g )Nz#cluster {0} is missing DNSEndpoint.)r   r   r   rv   r   r   s     rp   r    MissingDNSEndpointError.__init__  s%    	
!41-44W\\Bro   rh   r   r   s   @rp   r   r     s    D ro   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r   i  zEError for retrieving cross-connect-subnet of a cluster that has none.c                 `   > [         [        U ]  SR                  UR                  U5      5        g )Nz4cluster {0} is missing cross-connect subnetwork {1}.)r   r   r   rv   r   )r   r   cross_connect_subnetr   s      rp   r   !MissingCrossConnectError.__init__  s+    	
"D2>EELL.	
ro   rh   r   r   s   @rp   r   r     s    M ro   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r   i  z?Error for attempting to persist a cluster that has no endpoint.c                 ^   > [         [        U ]  SR                  UR                  5      5        g )Nz:cluster {0} is missing endpoint. Is it still PROVISIONING?)r   r   r   rv   r   r   s     rp   r   MissingEndpointError.__init__  s(    	
.DKKLL	
ro   rh   r   r   s   @rp   r   r     s    G ro   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r   i  zEError for attempting to persist internal IP of a non-private cluster.c                 ^   > [         [        U ]  SR                  UR                  5      5        g )Nz%cluster {0} is not a private cluster.)r   r   r   rv   r   r   s     rp   r   NonPrivateClusterError.__init__  s%    	
 $0/66w||Dro   rh   r   r   s   @rp   r   r     s    M ro   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r   i  zBError for attempting to persist a cluster that has no internal IP.c                 ^   > [         [        U ]  SR                  UR                  5      5        g )NzBcluster {0} is missing private endpoint. Is it still PROVISIONING?)r   r   r   rv   r   r   s     rp   r   $MissingPrivateEndpointError.__init__  s&    	
%t5	w||,ro   rh   r   r   s   @rp   r   r     s    J ro   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )NodeConfigErrori  z6Error for attempting parse node config YAML/JSON file.c                 J   > [         [        U ]  SR                  U5      5        g )NzInvalid node config: {0})r   r   r   rv   r   er   s     rp   r   NodeConfigError.__init__  s    	/4)*D*K*KA*NOro   rh   r   r   s   @rp   r   r     s    >P Pro   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )AutoprovisioningConfigErrori  zBError for attempting parse autoprovisioning config YAML/JSON file.c                 J   > [         [        U ]  SR                  U5      5        g )Nz)Invalid autoprovisioning config file: {0})r   r   r   rv   r   s     rp   r   $AutoprovisioningConfigError.__init__  s!    	
%t53::1=ro   rh   r   r   s   @rp   r   r     s    J ro   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r   i  zXError for attempting to persist internal IP for cluster with ipEndpoint access disabled.c                 ^   > [         [        U ]  SR                  UR                  5      5        g )Nz&IP access is disabled for cluster {0}.)r   r   r   rv   r   r   s     rp   r   #IPEndpointsIsDisabledError.__init__  s%    	
$d4077Ero   rh   r   r   s   @rp   r   r     s    ` ro   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r   i  z\Error for attempting to persist DNS endpoint for cluster with allowExternalTraffic disabled.c                 ^   > [         [        U ]  SR                  UR                  5      5        g )Nz_controlPlaneEndpointsConfig.dnsEndpointConfig.allowExternalTraffic is disabled for cluster {0}.)r   r   r   rv   r   r   s     rp   r   ,AllowExternalTrafficIsDisabledError.__init__  s&    	
-t=	%%+VGLL%9ro   rh   r   r   s   @rp   r   r     s    d ro   r   c                      \ rS rSrSrSrSrS rS rS r	\
S 5       r\
S	 5       r\
S
 5       r\
S 5       r\
S 5       r\
S 5       r\
S 5       r\S 5       r\S 5       r\SS j5       rS r\       SS j5       r\S 5       r\S 5       rSrg)ClusterConfigi  zzEncapsulates persistent cluster config data.

Call ClusterConfig.Load() or ClusterConfig.Persist() to create this
object.
z{project}_{zone}_{cluster}zgke_{project}_{zone}_{cluster}c                    US   U l         US   U l        US   U l        US   U l        UR	                  S5      U l        UR	                  S5      U l        UR	                  S5      U l        UR	                  S5      U l        UR	                  S	5      U l	        UR	                  S
5      U l
        UR	                  S5      U l        UR	                  S5      U l        UR	                  S5      U l        g )Ncluster_namezone_id
project_idrS   auth_provider	exec_authca_dataclient_cert_dataclient_key_datar   impersonate_service_accountkubecontext_overrideuse_iam_token)r   r   r   rS   getr   r   r   r   r   r   r  r  r  )r   kwargss     rp   r   ClusterConfig.__init__  s    ~.D)$DL\*DO"DKO4DZZ,DN::i(DL"JJ'9:D!::&78D

>2D'-zz2O'PD$ &

+A BDO4Dro   c                 \    SU R                   < SU R                  < SU R                  < S3$ )NzClusterConfig{project:z
, cluster:z, zone:})r   r   r   r   s    rp   __str__ClusterConfig.__str__  s#     ro   c                     [         R                  R                  [         R                  R                  U R                  U5      5      $ r   )osr   abspathjoin
config_dir)r   filenames     rp   	_FullpathClusterConfig._Fullpath  s(    77??277<<BCCro   c                 l    [         R                  U R                  U R                  U R                  5      $ r   )r   GetConfigDirr   r   r   r	  s    rp   r  ClusterConfig.config_dir  s*    %%4<< ro   c                     [         R                  U R                  U R                  U R                  U R
                  5      $ r   )r   KubeContextr   r   r   r  r	  s    rp   kube_contextClusterConfig.kube_context  s5    $$!!	 ro   c                 R    [        U R                  =(       a    U R                  5      $ r   )boolr   r   r	  s    rp   has_cert_dataClusterConfig.has_cert_data$  s    $$>)>)>??ro   c                     U R                   $ r   )r  r	  s    rp   	has_certsClusterConfig.has_certs(  s    ro   c                     U R                   $ r   )r   r	  s    rp   has_ca_certClusterConfig.has_ca_cert,  s    <<ro   c                     U R                   $ r   )r   r	  s    rp   has_dns_endpointClusterConfig.has_dns_endpoint0  s    ro   c                     U R                   $ r   )r  r	  s    rp   has_impersonate_service_account-ClusterConfig.has_impersonate_service_account4  s    +++ro   c                  p    [         R                  R                  R                  R	                  5       (       + $ r   )r   VALUES	containeruse_client_certificateGetBoolrh   ro   rp   UseGCPAuthProvider ClusterConfig.UseGCPAuthProvider8  s&      **AAIIKKKro   c           	          [         R                  R                  [        R                  " 5       R
                  [        R                  R                  X!U S95      $ )N)r   r   r   )	r  r   r  r   r   container_config_pathr   _CONFIG_DIR_FORMATrv   )r   r   r   s      rp   r  ClusterConfig.GetConfigDir<  sD    77<<,,((//l 	0 	
 ro   Nc                 P    U(       a  U$ [         R                  R                  X US9$ )N)r   r   r   )r   KUBECONTEXT_FORMATrv   )r   r   r   overrides       rp   r  ClusterConfig.KubeContextE  s-    o++22w 3  ro   c                    U R                   n[        R                  R                  5       n0 nSU R                  0nU R
                  (       a  U R                  US'   U R                  (       a  U R                  US'   U R                  US'   U R                  (       a  SUS'   U R                  (       a  U R                  US'   U R                  (       a  [        5       US'   [        R                  " XU5      UR                   U'   [        R"                  " U40 UD6UR$                  U'   [        R&                  " XR(                  40 UD6UR*                  U'   UR-                  U5        UR/                  5         [        R                  R1                  5       n[2        R4                  " S	U5        [2        R6                  R9                  [:        R=                  U R>                  US
95        g)z%Generate kubeconfig for this cluster.r   r   	cert_datakey_dataTr&  r  	iam_tokenzSaved kubeconfig to %s)r   contextN) r  kconfig
KubeconfigDefaultr   r#  r   r  r   r   r&  r)  r  r  _GenerateIamTokenContextcontextsUserusersClusterrS   clustersSetCurrentContext
SaveToFileDefaultPathr   debugstatusru   KUBECONFIG_USAGE_FMTrv   r   )r   r>  r   cluster_kwargsuser_kwargsr   s         rp   GenKubeconfigClusterConfig.GenKubeconfigM  s   G##++-JN++K "&,,nY!%!6!6k+ $ 4 4k*+/n'(++

*
* /0 !2!4k+ $+??7W#MJ  'W D DJW#*??$ .$J    )))+DII&-JJ##D,=,=w#Oro   c
                    [        UUUUU5      n
UR                  UR                  USU
-   UU	S.nU(       dI  UR                  b@  UR                  R                  b)  UR                  R                  R
                  (       d  XS'   UR                  nU(       a!  UR                  (       a  UR                  US'   O[        R                  " S5        U R                  5       (       a  SUS'   O@UR                  (       a/  UR                  (       a  UR                  US'   UR                  US	'   U(       a  X{S
'   U " S0 UD6nUR                  5         U$ )a  Saves config data for the given cluster.

Persists config file and kubernetes auth file for the given cluster
to cloud-sdk config directory and returns ClusterConfig object
encapsulating the same data.

Args:
  cluster: valid Cluster message to persist config data for.
  project_id: project that owns this cluster.
  use_internal_ip: whether to persist the internal IP of the endpoint.
  cross_connect_subnetwork: full path of the cross connect subnet whose
    endpoint to persist (optional)
  use_private_fqdn: whether to persist the private fqdn.
  use_dns_endpoint: whether to generate dns endpoint address.
  impersonate_service_account: the service account to impersonate when
    connecting to the cluster.
  kubecontext_override: the path to the kubeconfig file to write to.
  use_iam_token: whether to generate and persist an IAM token in the
    kubeconfig file.

Returns:
  ClusterConfig of the persisted data.

Raises:
  Error: if cluster has no endpoint (will be the case for first few
    seconds while cluster is PROVISIONING).
zhttps://)r   r   r   rS   r  r  r   r   z.Cluster is missing certificate authority data.gcpr   r   r   r  rh   )r   r   r   r   r   r8   
masterAuthclusterCaCertificater   r   r0  clientCertificate	clientKeyrQ  )clsr   r   r   r   r   r   r  r  r  r   r  authc_configs                 rp   PersistClusterConfig.Persistr  s+   P # H  << x' 4&F ++7//AAM33EEMM'^D))33fY 
kkBC
 %f_			DNN$(NN !%)%;%;!"".I*+}V}HOro   c           
         [         R                  " SUUU5        [        R                  R	                  5       nU R                  XX45      nUR                  R                  U5      =(       a    UR                  U   R                  S5      nUR                  R                  U5      =(       a    UR                  U   R                  S5      nUR                  R                  U5      =(       a    UR                  U   R                  S5      n	U(       a  U(       a  U	(       d  [         R                  " SU5        gU	R                  S5      U:w  d  U	R                  S5      U:w  a  [         R                  " SU	5        gUR                  S5      n
[        R                  " S	U
5      nUR                  S
5      nUR                  S5      nU
(       d  [         R                  " SU5        gU(       a  U(       a  [         R                  " S5        gO%U(       d  U(       a  [         R                  " S5        gUR                  S5      nUR                  S5      nUR                  S5      nUR                  S5      nU=(       a    UnU=(       d    U=(       d    UnU(       d  [         R                  " SXh5        gUUUU
UUUUUS.	nU " S0 UD6$ )as  Load and verify config for given cluster.

Args:
  cluster_name: name of cluster to load config for.
  zone_id: compute zone the cluster is running in.
  project_id: project in which the cluster is running.
  kubecontext_override: the path to the kubeconfig file to read from.

Returns:
  ClusterConfig for the cluster, or None if config data is missing or
  incomplete.
z9Loading cluster config for cluster=%s, zone=%s project=%sr   userr>  z!missing kubeconfig entries for %sNzinvalid context %srS   z\d+\.\d+\.\d+\.\d+zinsecure-skip-tls-verifyzcertificate-authority-dataz#missing cluster.server entry for %szScluster cannot specify both certificate-authority-data and insecure-skip-tls-verifyzOcluster must specify one of certificate-authority-data|insecure-skip-tls-verifyzauth-providerexeczclient-certificate-datazclient-key-dataz!missing auth info for user %s: %s)	r   r   r   rS   r   r   r   r   r   rh   )r   rL  r?  r@  rA  r  rH  r  rF  rD  research)rY  r   r   r   r  krE   r   r_  r>  rS   uses_ip_endpointinsecurer   r   r   r;  r<  	cert_authhas_valid_authr  s                        rp   LoadClusterConfig.Load  sB    IIC	 	""$A
//zC jjnnS!Dajjo&9&9)&DG77;;s8 0 0 8DjjnnS!Dajjo&9&9)&DG$g	ii3S9{{6c!W[[%;s%B	ii$g. [["Fyy!6?{{56Hkk67G	ii5s;			+	
  
 )	ii@  HH_-M I23Ixx)*H&hI"<i<9N	ii3S? % &#%
F ==ro   c                 h   U R                  XU5      n[        R                  R                  U5      (       a  [        R
                  " U5        [        R                  R                  5       nUR                  U R                  XX45      5        UR                  5         [        R                  " SU5        g )NzPurged cluster config from %s)r  r  r   existsr   RmTreer?  r@  rA  Clearr  rJ  r   rL  )rY  r   r   r   r  r  r   s          rp   PurgeClusterConfig.Purge  s    !!,DJ	ww~~j!!
###++-JzP II-z:ro   )r   r   r   r   r   r   r   r  r  r   rS   r  r   r   )FNNNNNF)ri   rj   rk   rl   rm   r4  r7  r   r
  r  propertyr  r  r  r   r#  r&  r)  staticmethodr0  r  r  rQ  classmethodr\  rh  rn  rn   rh   ro   rp   r   r     sP    475 D  
   @ @       , , L L    #J 
 #"&P Pd N N` 
; 
;ro   r   c                     U c  [         nO<U R                  S5      S   nUR                  5       (       d  g[        U5      nUS:  a  gSSU-
  -  SS[        -
  -  -
  nSS[
        -
  -  nX4:  a  g[        X4-  5      $ )a6  Calculate the maximum number of nodes for route based clusters.

Args:
  cluster_ipv4_cidr: The cluster IPv4 CIDR requested. If cluster_ipv4_cidr is
    not specified, GKE_DEFAULT_POD_RANGE will be used.

Returns:
  The maximum number of nodes the cluster can have.
  The function returns -1 in case of error.
/r          )GKE_DEFAULT_POD_RANGEsplit	isdecimalintGKE_ROUTE_BASED_SERVICE_RANGEGKE_DEFAULT_POD_RANGE_PER_NODE)cluster_ipv4_cidr	pod_range	blocksizepod_range_ipspod_range_ips_per_nodes        rp    CalculateMaxNodeNumberByPodRanger  $  s     %I!'',R0I  II1}Y'!((+ - &D!DE+	]3	44ro   c                     UR                  U 5      nU(       a3  [        XU5        U" 5       nU H  nXd;   d  M
  [        XVXF   5        M     U$ g)aP  Loads eviction map configuration.

Args:
  parent_name: The parent name of the eviction map configuration.
  opts: The eviction map configuration contents.
  msg_type: The message type of the eviction map configuration.
  field_spec: The field spec of the eviction map configuration.

Returns:
  The eviction map configuration message.
N)r  _CheckNodeConfigFieldssetattr)parent_nameoptsmsg_type
field_specmap_optsmsg_instancerE   s          rp   LoadEvictionMapConfigr  B  sL     XXk"(;*=:L	8=1  	ro   c                 J*    [         R                  " U5      n[        SU[        [        [        [        05        UR                  [        5      nU(       Ga  0 [        [        _[        [        _[        [        _[        [         _["        [        _[$        [&        _[(        [        _[*        [         _[,        [         _[.        [         _[0        [        _[2        [        _[4        [        _[6        [        _[8        [        _[:        [         _[<        [         _[>        [        [@        [        [B        [        [D        [         0En[        [        Xg5        URG                  5       U l$        UR                  [        5      U RH                  l%        UR                  [        5      U RH                  l&        UR                  [        5      U RH                  l'        UR                  [        5      U RH                  l(        UR                  ["        5      U RH                  l)        UR                  [(        5      U RH                  l*        UR                  [*        5      U RH                  l+        UR                  [.        5      U RH                  l,        UR                  [,        5      U RH                  l-        UR                  [0        5      U RH                  l.        UR                  [2        5      U RH                  l/        UR                  [8        5      U RH                  l0        UR                  [:        5      U RH                  l1        UR                  [<        5      U RH                  l2        [        [        [        [        [        [        S.n[g        [>        UURh                  U5      U RH                  l5        [g        [@        UURl                  U5      U RH                  l7        [g        [B        UURp                  U5      U RH                  l9        UR                  [D        5      U RH                  l:        UR                  [6        5      n	U	(       aU  URw                  5       U RH                  l<        U	R                  [z        5      n
U
(       a  XRH                  Rx                  l>        UR                  [4        5      nU(       a  UR                  5       U RH                  l@        UR                  [        5      nU(       a  UU RH                  R                  l>        UR                  [        5      nU(       a  XRH                  R                  lC        UR                  [$        5      nU(       a  XRH                  lD        U SL=(       a-    U RH                  SL=(       a    U RH                  RR                  SLnUSLnU(       a  U(       a  [        [        5      eUR                  [        5      nU(       Ga  [        [        U[        [        [        [        [        [        [        [        [        [        [        [        [        [        [        [&        [        [&        [        [&        [        [        [        [        05        UR                  5       U lS        UR                  [        5      nU(       a  U R                  R                  5       U R                  lU        [        [        R                  " U5      5       Hh  u  nn[        UU[        5        U R                  R                  R                  R                  U R                  R                  R                  UUS95        Mj     UR                  [        5      nU(       a  [        UR                  S5      (       d  [        SR	                  U5      5      eUR                  R                  R                  UR                  R                  R                  UR                  R                  R                  S.nUU;  a  [        S	R	                  U5      5      eUS
:X  a  [        R                  " [        5        UU   U R                  le        UR                  [        5      nU(       a  UR                  R                  R                  UR                  R                  R                  UR                  R                  R                  UR                  R                  R                  S.nUU;  a  [        SR	                  U5      5      eUU   U R                  lk        UR                  [        5      nU(       a  UR                  R                  R                  UR                  R                  R                  UR                  R                  R                  UR                  R                  R                  UR                  R                  R                  UR                  R                  R                  S.nUU;  a  [        SR	                  U5      5      eUU   U R                  ls        UR                  [        5      nU(       a  UR                  5       U R                  lu        UR                  [        5      nU(       a  UU R                  R                  lw        UR                  [        5      nU(       a  UU R                  R                  ly        UR                  [        5      =n(       Ga  UR                  5       U R                  l{        [        [        U[        [        [        [        [        [        [        [        G[         [        05        UR                  [        5      nUb  UU R                  R                  l        UR                  [        5      n U (       a  UGR                  5       U R                  R                  l        [        [        U G[        [        05        U R                  G[        5      n!U!b&  U!U R                  R                  GR                  l        UR                  [        5      n"U"(       a  UGR                  5       n#[        [        U"G[        [         G[        [         05        U"R                  G[        5      n$U$b  U$U#l        U"R                  G[        5      n%U%b  U%U#l        U#U R                  R                  l        UR                  [        5      n&U&(       a  UGR                  5       n'[        [        U&G[        [         G[        [         05        U&R                  G[        5      n$U$b  U$U'l        U&R                  G[        5      n%U%b  U%U'l        U'U R                  R                  l        UR                  G[         5      n(U((       ai  UGR                  5       n)[        G[         U(G[        [         05        U(R                  G[        5      n*U*b  U*U)l        U)U R                  R                  l        UR                  [        5      n+U+GbZ  UGR%                  5       U R                  l        [        [        U+G[(        [        G[*        [        05        U+R                  G[(        5      n,U,Gb5  U,R                  G[,        5      n-U,R                  G[.        5      n.UGR1                  5       U R                  GR&                  l        U-bl  Sn/U-U/:X  aI  UGR0                  GR4                  GR6                  U R                  GR&                  GR2                  l        O[        SR	                  U-U/5      5      eU.bl  Sn0U.U0:X  aI  UGR0                  GR:                  GR<                  U R                  GR&                  GR2                  l        O[        SR	                  U.U05      5      eU+R                  G[*        5      n1U1b  UGRA                  5       U R                  GR&                  l        U1R                  G[D        5      n2U1R                  G[F        5      n3U2b'  U2U R                  GR&                  GRB                  l        U3b'  U3U R                  GR&                  GRB                  l        UR                  [        5      n4/ U R                  l        U4(       a  G[M        U45       H  u  n5n[        SR	                  [        U55      UG[N        [        G[P        [        05        UGRS                  5       n6UR                  G[N        5      U6l        UR                  G[P        5      U6l        U R                  GRJ                  R                  U65        M     UR                  [        5      n7/ U R                  l        U7(       a  G[M        U75       H  u  n5n[        SR	                  [        U55      UG[Z        [        G[\        [&        05        UGR_                  5       n8UR                  G[Z        5      U8l        UR                  G[\        5      U8l        U R                  GRX                  R                  U85        M     UR                  [        5      n9/ U R                  l        U9(       a  G[M        U95       H  u  n5n[        SR	                  [        U55      UG[Z        [        G[\        [&        05        UGR_                  5       n8UR                  G[Z        5      U8l        UR                  G[\        5      U8l        U R                  GRd                  R                  U85        M     UR                  [        5      n:U:(       a  U:U R                  l        UR                  [        5      n;U;(       Gap  UGRi                  5       U R                  l        [        [        U;G[l        [        05        U;R                  G[l        5      n<UGRo                  5       U R                  GRj                  l        U<(       a  [        G[l        U<G[r        [        G[t        [         G[v        [&        05        U<R                  G[r        5      U R                  GRj                  GRp                  l        U<R                  G[t        5      U R                  GRj                  GRp                  l        U<R                  G[v        5      n=U=b(  U=U R                  GRj                  GRp                  l        ggggg! [         R                   a  n[        SR	                  U5      5      eSnAff = f)a|  Load system configuration (sysctl & kubelet config) from YAML/JSON file.

Args:
  node_config: The node config object to be populated.
  content: The YAML/JSON string that contains sysctl and kubelet options.
  opt_readonly_port_flag: kubelet readonly port enabled.
  messages: The message module.

Raises:
  Error: when there's any errors on parsing the YAML/JSON system config.
"config is not valid YAML/JSON: {0}N<root>)memoryAvailablenodefsAvailablenodefsInodesFreeimagefsAvailableimagefsInodesFreepidAvailable)rE   rF   r(   z*setting cgroupMode as {0} is not supported)CGROUP_MODE_UNSPECIFIEDCGROUP_MODE_V1CGROUP_MODE_V2zucgroup mode "{0}" is not supported, the supported options are CGROUP_MODE_UNSPECIFIED, CGROUP_MODE_V1, CGROUP_MODE_V2r  )(TRANSPARENT_HUGEPAGE_ENABLED_UNSPECIFIED#TRANSPARENT_HUGEPAGE_ENABLED_ALWAYS$TRANSPARENT_HUGEPAGE_ENABLED_MADVISE"TRANSPARENT_HUGEPAGE_ENABLED_NEVERztransparent hugepage enabled "{0}" is not supported, the supported options are TRANSPARENT_HUGEPAGE_ENABLED_ALWAYS, TRANSPARENT_HUGEPAGE_ENABLED_MADVISE, TRANSPARENT_HUGEPAGE_ENABLED_NEVER, TRANSPARENT_HUGEPAGE_ENABLED_UNSPECIFIED)'TRANSPARENT_HUGEPAGE_DEFRAG_UNSPECIFIED"TRANSPARENT_HUGEPAGE_DEFRAG_ALWAYS!TRANSPARENT_HUGEPAGE_DEFRAG_DEFER.TRANSPARENT_HUGEPAGE_DEFRAG_DEFER_WITH_MADVISE#TRANSPARENT_HUGEPAGE_DEFRAG_MADVISE!TRANSPARENT_HUGEPAGE_DEFRAG_NEVERa4  transparent hugepage defrag "{0}" is not supported, the supported options are TRANSPARENT_HUGEPAGE_DEFRAG_ALWAYS, TRANSPARENT_HUGEPAGE_DEFRAG_DEFER, TRANSPARENT_HUGEPAGE_DEFRAG_DEFER_WITH_MADVISE, TRANSPARENT_HUGEPAGE_DEFRAG_MADVISE, TRANSPARENT_HUGEPAGE_DEFRAG_NEVER, TRANSPARENT_HUGEPAGE_DEFRAG_UNSPECIFIEDSPEC_RSTACK_OVERFLOW_OFFzPsetting specRstackOverflow as {0} is not supported. The supported options is {1}INIT_ON_ALLOC_OFFzIsetting initOnAlloc as {0} is not supported. The supported options is {1}{0}[{1}])r   loadYAMLParseErrorr   rv   r  NC_KUBELET_CONFIGdictNC_LINUX_CONFIGr  NC_CPU_MANAGER_POLICYstrNC_CPU_CFS_QUOTAr  NC_CPU_CFS_QUOTA_PERIODNC_POD_PIDS_LIMITr{  NC_KUBELET_READONLY_PORTNC_ALLOWED_UNSAFE_SYSCTLSlistNC_CONTAINER_LOG_MAX_SIZENC_CONTAINER_LOG_MAX_FILES"NC_IMAGE_GC_HIGH_THRESHOLD_PERCENT!NC_IMAGE_GC_LOW_THRESHOLD_PERCENTNC_IMAGE_MINIMUM_GC_AGENC_IMAGE_MAXIMUM_GC_AGENC_TOPOLOGY_MANAGERNC_MEMORY_MANAGERNC_SINGLE_PROCESS_OOMKILLNC_NODE_SWAP_SIZE_GIBNC_MAX_PARALLEL_IMAGE_PULLSNC_EVICTION_SOFTNC_EVICTION_SOFT_GRACE_PERIODNC_EVICTION_MINIMUM_RECLAIM(NC_EVICTION_MAX_POD_GRACE_PERIOD_SECONDSNodeKubeletConfigr   r   cpuCfsQuotacpuCfsQuotaPeriodr   r   r   r   r!   r    r"   r#   r2   r$   r%   r  EvictionSignalsra   EvictionGracePeriodrb   EvictionMinimumReclaimrc   rd   MemoryManagerr.   NC_MEMORY_MANAGER_POLICYr/   TopologyManagerr0   NC_TOPOLOGY_MANAGER_POLICYNC_TOPOLOGY_MANAGER_SCOPEr1   r   INVALID_NC_FLAG_CONFIG_OVERLAP	NC_SYSCTLNC_CGROUP_MODENC_HUGEPAGENC_TRANSPARENT_HUGEPAGE_ENABLEDNC_TRANSPARENT_HUGEPAGE_DEFRAGNC_SWAP_CONFIGNC_KERNEL_OVERRIDESNC_ADDITIONAL_ETC_HOSTS'NC_ADDITIONAL_ETC_SYSTEMD_RESOLVED_CONFNC_ADDITIONAL_ETC_RESOLV_CONFNC_TIME_ZONENC_CUSTOM_NODE_INITLinuxNodeConfiglinuxNodeConfigSysctlsValuesysctlssortedsix	iteritems_CheckNodeConfigValueTypeadditionalPropertiesappendAdditionalPropertyhasattrCgroupModeValueValuesEnumr  r  r  r   r   CGROUPV1_DEPRECATED_MSGr(   )TransparentHugepageEnabledValueValuesEnumr  r  r  r  r)   (TransparentHugepageDefragValueValuesEnumr  r  r  r  r  r  r*   HugepagesConfig	hugepagesNC_HUGEPAGE_2MhugepageSize2mNC_HUGEPAGE_1GhugepageSize1g
SwapConfigrG   NC_SWAP_CONFIG_ENABLED NC_SWAP_CONFIG_ENCRYPTION_CONFIG NC_SWAP_CONFIG_BOOT_DISK_PROFILE*NC_SWAP_CONFIG_EPHEMERAL_LOCAL_SSD_PROFILE*NC_SWAP_CONFIG_DEDICATED_LOCAL_SSD_PROFILEr8   EncryptionConfigrH   )NC_SWAP_CONFIG_ENCRYPTION_CONFIG_DISABLEDrI   BootDiskProfileNC_SWAP_CONFIG_SWAP_SIZE_GIB NC_SWAP_CONFIG_SWAP_SIZE_PERCENTrM   rN   rJ   EphemeralLocalSsdProfilerK   DedicatedLocalSsdProfileNC_SWAP_CONFIG_DISK_COUNTrO   rL   KernelOverridesr3   NC_KERNEL_COMMANDLINE_OVERRIDES
NC_LRU_GENNC_KERNEL_SPEC_RSTACK_OVERFLOWNC_KERNEL_INIT_ON_ALLOCKernelCommandlineOverridesr4   !SpecRstackOverflowValueValuesEnumr  r5   InitOnAllocValueValuesEnumr  r6   LRUGenr7   NC_LRU_GEN_ENABLEDNC_LRU_GEN_MIN_TTL_MSr9   r:   	enumerateNC_ETC_HOSTS_ENTRY_IPNC_ETC_HOSTS_ENTRY_HOSTEtcHostsEntryrC   rD   r;   NC_RESOLVED_CONF_ENTRY_KEYNC_RESOLVED_CONF_ENTRY_VALUEResolvedConfEntryrE   rF   r<   r=   CustomNodeInitr>   NC_CUSTOM_NODE_INIT_SCRIPT
InitScriptr?   "NC_CUSTOM_NODE_INIT_SCRIPT_GCS_URI)NC_CUSTOM_NODE_INIT_SCRIPT_GCS_GENERATIONNC_CUSTOM_NODE_INIT_SCRIPT_ARGSr@   rA   rB   )>node_configcontentopt_readonly_port_flagmessagesr  r   kubelet_config_optsconfig_fieldseviction_map_string_fieldsmemory_manager_optsmemory_manager_policytopology_manager_optstopology_manager_policytopology_manager_scoper  	ro_in_cfg
ro_in_flaglinux_config_optssysctl_optsrE   rF   cgroup_mode_optscgroup_mode_mapping!transparent_hugepage_enabled_opts$transparent_hugepage_enabled_mapping transparent_hugepage_defrag_opts#transparent_hugepage_defrag_mappinghugepage_optsr,   r-   swap_config_optsr8   encryption_config_optsrI   boot_disk_profile_optsboot_disk_profile_msgswap_size_gibswap_size_percent ephemeral_local_ssd_profile_optsephemeral_local_ssd_profile_msg dedicated_local_ssd_profile_optsdedicated_local_ssd_profile_msg
disk_countkernel_overrides_optskernel_commandlinespec_rstack_overflowinit_on_allocspec_rstack_overflow_offinit_on_alloc_offlru_genlru_gen_enabled
min_ttl_msadditional_etc_hosts_optsietc_hosts_entry)additional_etc_systemd_resolved_conf_optsresolved_conf_entryadditional_etc_resolv_conf_optstime_zone_optscustom_node_init_optsinit_script_opts	init_argss>                                                                 rp   LoadSystemConfigFromYAMLrL  Z  s   J99WD 

T
4 !23s$ 	  	3	
 	!$ 	"4 	"3 	#C 	+C 	*3 	  	  	T 	4 	"4  	s!" 	$S#$ 	$%t#T0#+M. . !) : : <K1D1H1H2K. -@,C,C-K) 3F2I2I3K/ .A-D-D.K* 	 89 @ 5H4K4K!5K1 6I5L5L"6K2 	 AB 8 	 BC 9 3F2I2I3K/ 3F2I2I3K/ 6I5L5L!6K2 1D0G0G1K- 7J6M6M#7K3  " .C  "	.K* 9N%$$"	9K5 8M#''"	8K4 	 HI >
 .112CD080F0F0Hk-1556NO	9N!!//6/334GH2:2J2J2Lk/ 5 9 9
$! 
!# 	!!118  588
#  
 :P!!117!%%&?@G7>4  

#
#4
/

#
#
F
F  &T1*:
8
99 hh/tC+S*CD#T3T)4#	
$ #+":":"<K#''	2K

%
%
2
2
4 !!) s}}[9:*#u!#uc2##++@@GG''//BBu C 	
 ; ),,^<X--|<<8?? 
 	
 &&@@XX &&@@OO &&@@OO
 
!4	4GGMv H
 	
 //+,/B
0k!!, ):(=(=')% ) &&PPyy &&PPtt &&PPuu &&PPss.* ,56 8 9?19
 	
 // !!<
 (9'<'<&($ ( &&OOww &&OOrr &&OOqq &&OO~~ &&OOss &&OOqq#-)* +45 7 8>v08

 
	
 ..N
O !!; &))+6M.6.F.F.Hk!!+%)).9o	?N##--<%)).9o	?N##--<,00@@@/7/B/B/Dk!!,

$d..8$8$
 !$$%;<g		9@##..6/33
*  
 %%' 	##..? 	,"6=	

 *--5
  
%
%
0
0
A
A
J  033
*  
  ( 8 8 :,",c0#	
 /223OP$.;

+266,
 (2C

/! 	##..> *:)=)=
4*& 
*--/ 	( 	6,,c0#	
 9<<(
 $8E
)
5<@@,
 (<M
)
9+ 	##..G *:)=)=
4*& 
*--/ 	( 	6,&,	

 699%

 !6@
)
3+ 	##..G
 .112EF(4<4L4L4Nk!!1

-t$ 144
) 
	'155* 
 +../FG//1 	##33N  +%?
"!%==33UUnn ''77RRe ",,2F(*B-  $1
//33NN`` ''77RR^ """(&8I"J  &))*5g		=E__=N##33:!++&89[[!67
& 
%
%
5
5
<
<
D ! 
%
%
5
5
<
<
E
 !2 5 56M N57K2 89'!T5q9%s'	
 #002!XX&;<#xx(?@##66==oN : 1B0E0E/1- DFK@0HI'!TEqI*C,d	
 '88:"&((+E"F$(HH-I$J!##DDKK	
 J" '8&;&;%'# ;=K7&>?'!T;Q?*C,d	
 '88:"&((+E"F$(HH-I$J!##;;BB	
 @" '**<8N-;k!!* .112EF3;3J3J3Lk!!0

%t
,
 /223MN



 !!00; 
&2C93/	
   !CD 	##22==D   !JK 	##22==K %(()HI	 GP+
%
%
4
4
?
?
D !# 
 S { 
		 J
>EEaH
IIJs   AS/ S/AT"TATTAT"c                 H   [        U S5      (       a  [        U R                  S5      (       au  U R                  R                  (       aY  U R                  R                  R                  S:X  a4  [        R
                  " [        R                  U R                  5      5        ggggg)zCCheck cgroup mode of the node pool and print a warning if it is V1.r   effectiveCgroupModeEFFECTIVE_CGROUP_MODE_V1N)r  r   rN  r   r   r   CGROUPV1_NODEPOOLS_MSGrv   )pools    rp   CheckForCgroupModeV1rR    sv    T86K!L!L''KK++004NN	kk(//		:; O 	( "Mro   c                     [         R                  " U5      n[        SU[        [        [        [        [        [        05        UR                  [        5      =n(       Ga  [        [        [        [        0n[        [        XV5        UR                  5       U l        UR                  [        5      U R                   l        UR                  [        5      =n(       Ga%  [$        [        [&        [        0n/ U R                   l        [+        U5       H  u  p[        SR	                  [        U5      X5        U	R                  [$        5      n
U
(       d  [        S5      e[        [$        U
[,        [.        05        UR1                  5       nUR3                  5       Ul        U
R                  [,        5      UR4                  l        U	R                  [&        5      Ul        U R                   R(                  R;                  U5        M     UR                  [        5      =n(       aU  [<        [        0n[        [        X5        UR?                  5       U l         UR                  [<        5      U R@                  l        UR                  [        5      nU(       Ga3  / U l!        [+        U5       GH  u  p[        SR	                  [        U5      U[D        [.        [F        [        05        URI                  5       nUR                  [D        5      Ul%        UR                  [F        5      nU(       Ga~  / Ul&        [+        U5       GHg  u  nn[        SR	                  [        U[F        U5      U[N        [.        [P        [        [R        [        [T        [        [V        [.        [X        [        [Z        [        05        UR]                  5       nUR                  [N        5      Ul/        UR                  [P        5      Ul0        UR                  [R        5      nU(       a  UR\                  Rb                  Rd                  UR\                  Rb                  Rf                  UR\                  Rb                  Rh                  UR\                  Rb                  Rj                  S.nU HY  nUU;  a  [        SR	                  U5      5      eURl                  (       d  / Ul6        URl                  R;                  UU   5        M[     UR                  [T        5      nU(       a  / Ul7        U H  n[        S	U[p        [.        [r        [        05        URu                  5       nUR                  [p        5      Ul;        UR                  [r        5      Ul<        URn                  R;                  U5        M     UR                  [V        5      nU(       a  UUl=        UR                  [X        5      nU(       al  / Ul>        U H_  n[        S
U[~        [.        05        UR                  5       nUR                  [~        5      UlA        UR|                  R;                  U5        Ma     UR                  [Z        5      nU(       Ga&  / UlB        U GH  n[        SU[        [        [        [        05        UR                  5       n UR                  [        5      n!U!(       aH  [        SU![~        [.        05        UR                  5       n"U!R                  [~        5      U"lA        U"U lF        UR                  [        5      n#U#(       aH  [        SU#[~        [.        05        UR                  5       n$U#R                  [~        5      U$lA        U$U l;        UR                  R;                  U 5        GM     URL                  R;                  U5        GMj     U RB                  R;                  U5        GM     gg! [         R                   a  n[        SR	                  U5      5      eSnAff = f)af  Load containerd configuration from YAML/JSON file.

Args:
  containerd_config: The containerd config object to be populated (either from
    a node or from node config defaults).
  content: The YAML/JSON string that contains private CR config.
  messages: The message module.

Raises:
  Error: when there's any errors on parsing the YAML/JSON system config.
r  Nr  r  zlprivateRegistryAccessConfig.certificateAuthorityDomainConfig must specify a secret config, none was providedz{0}[{1}].{2}[{3}])HOST_CAPABILITY_UNSPECIFIEDHOST_CAPABILITY_PULLHOST_CAPABILITY_RESOLVEHOST_CAPABILITY_PUSHzcapability "{0}" is not supported, the supported options are HOST_CAPABILITY_PULL, HOST_CAPABILITY_RESOLVE, HOST_CAPABILITY_PUSHrV   rZ   r[   r\   rE   )Gr   r  r  r   rv   r  NC_CC_PRIVATE_CR_CONFIGr  NC_CC_WRITABLE_CGROUPS&NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTSr  r  NC_CC_PRIVATE_CR_CONFIG_ENABLEDr  NC_CC_CA_CONFIGPrivateRegistryAccessConfigrP   r8   NC_CC_GCP_SECRET_CONFIGNC_CC_PRIVATE_CR_FQDNS_CONFIGr]   r
  "NC_CC_GCP_SECRET_CONFIG_SECRET_URIr   CertificateAuthorityDomainConfig!GCPSecretManagerCertificateConfigr^   	secretUrir`   r  NC_CC_WRITABLE_CGROUPS_ENABLEDWritableCgroupsrQ   rR   -NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_SERVER,NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_HOSTSRegistryHostConfigrS   rT   +NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_HOST4NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_OVERRIDE_PATH3NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_CAPABILITIES-NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_HEADER3NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_DIAL_TIMEOUT)NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_CA-NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_CLIENT
HostConfigrD   rU   $CapabilitiesValueListEntryValuesEnumrT  rU  rV  rW  rX   rV   1NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_HEADER_KEY3NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_HEADER_VALUERegistryHeaderrE   rF   rW   rZ   5NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_GCP_SECRET_URICertificateConfigrY   r[   2NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_CLIENT_CERT1NC_CC_PRIVATE_CR_CONFIG_REGISTRY_HOSTS_CLIENT_KEYCertificateConfigPairr\   )%containerd_configr  r  r  r   private_registry_optsr  ca_domain_optsrC  ca_itemgcp_secret_opts	ca_configwritable_cgroups_optsregistry_hosts_optsregistry_host_optregistry_host_msg
hosts_optsjhost_opthost_msgcapabilities_optscapability_mappingcap_optheader_opts
header_opt
header_msgdial_timeout_optca_optsca_optca_msgclient_opts
client_opt
client_msgcert_optcert_msgkey_optkey_msgs%                                        rp   LoadContainerdConfigFromYAMLr    s   J99WD 

!4
 $
0$ #hh'>???'M !6 	,,. 1 	!!"AB 119 /22?CC~C
!4
'm
  33T ".1*!oq17	
 "++&=>A  	#/5	

 ==?	668 	3  BC 	33= "++&CD	55VV]]	
/ 28 #hh'=>>>&M  5 )1(@(@(B%0E0I0I&1%%- !GH&(# )*= >


BA
F
;S:D #557!2!6!6
7" %((
6j 
"$$Z0KAx
 !((8>	 =sFEt?Es;T?$ ((*(",,9(- #+,,B#(
 'llA
  ''LLhh ''LLaa ''LLdd ''LLaa" - 22%,,2F7O 
 **(*%##**+=g+FG - !;+  HO)
$GI4 $224j)~~C jn ",E"j oo$$Z0! *$ &\\A
 #3H LL!JK'HK!$H#N
  113f17G2f. kk  ( " !;+  HO)
$H$G $99;j#Dh &M $5575=\\I62 #+
"Cg &M #4464;KKI51 ")
oo$$Z0c *f 
!
!
(
(
2y 1z %%,,->?a !? [ 
		 J
>EEaH
IIJs   _ _6_11_6c           	      &   [        X[        5        [        UR                  5       5      [        UR                  5       5      -
  nU(       a-  [	        SR                  [        [        U5      5      U 5      5      eU H  n[        XAU   X$   5        M     g)ab  Check whether the children of the config option are valid or not.

Args:
  parent_name: The name of the config option to be checked.
  parent: The config option to be checked.
  spec: The spec defining the expected children and their value type.

Raises:
  NodeConfigError: if there is any unknown fields or any of the fields doesn't
  satisfy the spec.
zunknown fields: {0} in "{1}"N)r  r  setkeysr   rv   r  r  )r  parentspecunknown_fields
field_names        rp   r  r    sy     K6v{{}%DIIK(88.
&--4'(+	
  jj*<d>NO ro   c                 l    [        X5      (       d$  [        SR                  XR                  5      5      eg)a*  Check whether the config option has the expected value type.

Args:
  name: The name of the config option to be checked.
  value: The value of the config option to be checked.
  value_type: The expected value type (e.g., str, bool, dict).

Raises:
  NodeConfigError: if value is not of value_type.
zvalue of "{0}" must be {1}N)
isinstancer   rv   ri   )r   rF   
value_types      rp   r  r    s5     
E	&	&
$++D2E2EF  
'ro   c                      SSSS.$ )NrI   zoutbound-onlybidirectional)#PRIVATE_IPV6_GOOGLE_ACCESS_DISABLED$PRIVATE_IPV6_GOOGLE_ACCESS_TO_GOOGLE(PRIVATE_IPV6_GOOGLE_ACCESS_BIDIRECTIONALrh   rh   ro   rp   _GetPrivateIPv6CustomMappingsr    s    -7.=2A
 ro   c                 n    Sn[         R                  " SU R                  R                  [	        5       UUS9$ )zReturns a mapper from text options to the PrivateIpv6GoogleAccess enum.

Args:
  messages: The message module.
  hidden: Whether the flag should be hidden in the choice_arg
aC  
Sets the type of private access to Google services over IPv6.

PRIVATE_IPV6_GOOGLE_ACCESS_TYPE must be one of:

  bidirectional
    Allows Google services to initiate connections to GKE pods in this
    cluster. This is not intended for common use, and requires previous
    integration with Google services.

  disabled
    Default value. Disables private access to Google services over IPv6.

  outbound-only
    Allows GKE pods to make fast, secure requests to Google services
    over IPv6. This is the most common use of private IPv6 access.

  $ gcloud alpha container clusters create       --private-ipv6-google-access-type=disabled
  $ gcloud alpha container clusters create       --private-ipv6-google-access-type=outbound-only
  $ gcloud alpha container clusters create       --private-ipv6-google-access-type=bidirectional
!--private-ipv6-google-access-typehiddenhelp_str)r
   ChoiceEnumMapperNetworkConfig&PrivateIpv6GoogleAccessValueValuesEnumr  r  r  	help_texts      rp   $GetPrivateIpv6GoogleAccessTypeMapperr     s<    )0 
	#	#)CC#%
 ro   c                 j    [         R                  " SU R                  R                  [	        5       USS9$ )zReturns a mapper from the text options to the PrivateIpv6GoogleAccess enum.

Args:
  messages: The message module.
  hidden: Whether the flag should be hidden in the choice_arg. The choice_arg
    will never actually be used for this mode.
r   r  )r
   r  ClusterUpdate-DesiredPrivateIpv6GoogleAccessValueValuesEnumr  r  r  s     rp   -GetPrivateIpv6GoogleAccessTypeMapperForUpdater  )  s5     
	#	#)JJ#%
 ro   c                      SSS.$ )Nipv4z	ipv4-ipv6)IPV4	IPV4_IPV6rh   rh   ro   rp   _GetStackTypeCustomMappingsr  :  s    
 ro   c                 n    Sn[         R                  " SU R                  R                  [	        5       UUS9$ )zReturns a mapper from text options to the InTransitEncryptionConfig enum.

Args:
  messages: The message module.
  hidden: Whether the flag should be hidden in the choice_arg.
a  
Sets the in-transit encryption type for dataplane v2 clusters.

--in-transit-encryption must be one of:

  inter-node-transparent
    Changes clusters to use transparent, dataplane v2, node-to-node encryption.

  none:
    Disables dataplane v2 in-transit encryption.

  $ gcloud container clusters create       --in-transit-encryption=inter-node-transparent
  $ gcloud container clusters create       --in-transit-encryption=none
--in-transit-encryptionr  )r
   r  r  (InTransitEncryptionConfigValueValuesEnum+_GetInTransitEncryptionConfigCustomMappingsr  s      rp   (GetCreateInTransitEncryptionConfigMapperr  A  s<    )  
	#	#EE13
 ro   c                 n    Sn[         R                  " SU R                  R                  [	        5       UUS9$ )zReturns a mapper from text options to the InTransitEncryptionConfig enum.

Args:
  messages: The message module.
  hidden: Whether the flag should be a hidden flag.
a  
Updates the in-transit encryption type for dataplane v2 clusters.

--in-transit-encryption must be one of:

  inter-node-transparent
    Changes clusters to use transparent, dataplane v2, node-to-node encryption.

  none:
    Disables dataplane v2 in-transit encryption.

  $ gcloud container clusters update       --in-transit-encryption=inter-node-transparent
  $ gcloud container clusters update       --in-transit-encryption=none
r  r  )r
   r  r  /DesiredInTransitEncryptionConfigValueValuesEnumr  r  s      rp   (GetUpdateInTransitEncryptionConfigMapperr  b  s<    )  
	#	#LL13
 ro   c                      SSS.$ )Nzinter-node-transparentnone),IN_TRANSIT_ENCRYPTION_INTER_NODE_TRANSPARENTIN_TRANSIT_ENCRYPTION_DISABLEDrh   rh   ro   rp   r  r    s    6N(.
 ro   c                 n    Sn[         R                  " SU R                  R                  [	        5       UUS9$ )Returns a mapper from text options to the StackType enum.

Args:
  messages: The message module.
  hidden: Whether the flag should be hidden in the choice_arg
a>  
Sets the stack type for the cluster nodes and pods.

STACK_TYPE must be one of:

  ipv4
    Default value. Creates IPv4 single stack clusters.

  ipv4-ipv6
    Creates dual stack clusters.

  $ gcloud container clusters create       --stack-type=ipv4
  $ gcloud container clusters create       --stack-type=ipv4-ipv6
--stack-typer  )r
   r  IPAllocationPolicyStackTypeValueValuesEnumr  r  s      rp   GetCreateStackTypeMapperr    s<    )  
	#	#!!::!#
 ro   c                 n    Sn[         R                  " SU R                  R                  [	        5       UUS9$ )r  aJ  
Updates the stack type for the cluster nodes and pods.

STACK_TYPE must be one of:

  ipv4
    Changes clusters to IPv4 single stack clusters.

  ipv4-ipv6
    Changes clusters to dual stack clusters.

  $ gcloud container clusters update       --stack-type=ipv4
  $ gcloud container clusters update       --stack-type=ipv4-ipv6
r  r  )r
   r  r  DesiredStackTypeValueValuesEnumr  r  s      rp   GetUpdateStackTypeMapperr    s<    )  
	#	#<<!#
 ro   c                      SSS.$ )Ninternalexternal)INTERNALEXTERNALrh   rh   ro   rp    _GetIpv6AccessTypeCustomMappingsr    s    
 ro   c                 n    Sn[         R                  " SU R                  R                  [	        5       UUS9$ )zReturns a mapper from text options to the Ipv6AccessType enum.

Args:
  messages: The message module.
  hidden: Whether the flag should be hidden in the choice_arg
a|  
Sets the IPv6 access type for the subnet created by GKE.

IPV6_ACCESS_TYPE must be one of:

  internal
    Creates a subnet with INTERNAL IPv6 access type.

  external
    Default value. Creates a subnet with EXTERNAL IPv6 access type.

  $ gcloud container clusters create       --ipv6-access-type=internal
  $ gcloud container clusters create       --ipv6-access-type=external
z--ipv6-access-typer  )r
   r  r  Ipv6AccessTypeValueValuesEnumr  r  s      rp   GetIpv6AccessTypeMapperr    s<    )  
	#	#!!??&(
 ro   c                      SSSSS.$ )NrI   z project-singleton-policy-enforcezpolicy-bindingsz4policy-bindings-and-project-singleton-policy-enforce)DISABLED PROJECT_SINGLETON_POLICY_ENFORCEPOLICY_BINDINGS4POLICY_BINDINGS_AND_PROJECT_SINGLETON_POLICY_ENFORCErh   rh   ro   rp   (_GetBinauthzEvaluationModeCustomMappingsr    s    *L*
@
 ro   c                 j    [         R                  " SU R                  R                  [	        5       USS9$ )zReturns a mapper from text options to the evaluation mode enum.

Args:
  messages: The message module.
  hidden: Whether the flag should be hidden in the choice_arg
z--binauthz-evaluation-moder  r  )r
   r  BinaryAuthorizationEvaluationModeValueValuesEnumr  r  s     rp   GetBinauthzEvaluationModeMapperr    s5     
	#	#"""@@.0
 ro   c                     U (       d  g [        U R                  5       5      U-
  (       a:  SR                  SR                  [        U R                  5       5      U-
  5      5      $ g )Nz'following names are not recognised: {0} )r  r  rv   r  )actualknowns     rp   HasUnknownKeysr    sO    	
%4;;V[[]#e+,   ro   c                     [         R                  " U 5      nU(       d  [        S5      e1 Skn[        X5      nU(       a  [        U5      eUR                  S5      (       a1  SS1n[        UR                  S5      U5      nU(       a  [        U5      eUR                  S5      (       a1  S	S
1n[        UR                  S5      U5      nU(       a  [        U5      eUR                  S5      (       a2  SS1n[        UR                  S5      U5      nU(       a  [        U5      egg! [         R                   a  n[        SR	                  U5      5      eSnAff = f)a  Load and Validate Autoprovisioning configuration from YAML/JSON file.

Args:
  nap_config_file: The YAML/JSON string that contains sysctl and kubelet
    options.

Raises:
  Error: when there's any errors on parsing the YAML/JSON system config
  or wrong name are present.
z8autoprovisioning config file is not valid YAML/JSON: {0}Nz,autoprovisioning config file cannot be empty>   scopesdiskType	imageType
diskSizeGb
managementbootDiskKmsKeyminCpuPlatformresourceLimitsserviceAccountupgradeSettingsshieldedInstanceConfigautoprovisioningLocationsr  maxSurgeUpgrademaxUnavailableUpgrader  autoUpgrade
autoRepairr  enableSecureBootenableIntegrityMonitoring)r   r  r  r   rv   r  r  )nap_config_file
nap_configr   
nap_paramserrupgrade_settings_paramsnode_management_paramsshielded_paramss           rp   "ValidateAutoprovisioningConfigFiler    sQ   ?+J
 

%6 * 	z.#
%c
**^^%&&02IJ
()+BC ',,^^L!!+\:
57M
NC
',,^^,--)+FGO
/0/C ',,  .Q 
		 
%BII!L s   D" "E6EEc                     Sn [         R                  " X5      (       d  [        R                  " S5        gg! [        R
                  [        R                  4 a    [        R                  " S5         gf = f)z3Checks if the Container File System API is enabled.z"containerfilesystem.googleapis.coma  Container File System API (containerfilesystem.googleapis.com) has not been enabled on the project. Please enable it for image streaming to fully work. For additional details, please refer to https://cloud.google.com/kubernetes-engine/docs/how-to/image-streaming#requirementsa  Failed to check if Container File System API (containerfilesystem.googleapis.com) has been enabled. Please make sure to enable it for image streaming to work. For additional details, please refer to https://cloud.google.com/kubernetes-engine/docs/how-to/image-streaming#requirementsN)r	   IsServiceEnabledr   r   r   #GetServicePermissionDeniedExceptionapitools_exceptions	HttpError)r   service_names     rp   2CheckForContainerFileSystemApiEnablementWithPromptr  W  sm    5,&&w==	kka > 44##
 
 KK	_	
s   17 :A43A4c                 6   U (       d  [        S5      e[        R                  " U 5      (       d  [        S5      e/ nU  H  nSnU(       d  [        S5      e [        R                  " UR
                  U5      nUR                  (       d  [        S5      eUR                  5       (       a3  [        SR                  UR                  UR                  5       5      5      eUR                  U5        M     UR                  US9$ ! [         a  n[        U5      eSnAff = f)z8Loads json/yaml node affinities from yaml file contents.ziNo node affinity labels specified. You must specify at least one label to create a sole tenancy instance.z3Node affinities must be specified as JSON/YAML listNz"Empty list item in JSON/YAML file.z6A key must be specified for every node affinity label.z,Key [{0}] has invalid field formats for: {1})nodeAffinities)rf   r   	list_liker   PyValueToMessageNodeAffinity	ExceptionrE   all_unrecognized_fieldsrv   r  SoleTenantConfig)affinities_yamlr  node_affinitiesaffinitynode_affinityr   s         rp   (LoadSoleTenantConfigFromNodeAffinityYamlr  p  s    

	3 
 
	(	(
E
FF/!hM677//0E0ExPm JKK,,..
8
?
?!F!F!H 
 =)! "$ 
	"	"/	"	BB  !Hns   !C>>
DDDc                      [         R                  R                  R                  R	                  5       n U SL=(       a    U R                  5       R                  S5      $ )z+Returns a bool noting if User is a Googler.Nz@google.com)r   r,  coreaccountGetlowerendswith)emails    rp   r   r     sC    



 
 
(
(
,
,
.%	d		Du{{}55mDDro   returnc                     [        5       (       d  [        S5      e[        R                  " SSS9n [        R
                  R                  R                  R                  SS9n[        R                  " U5      nSU R                   SU 3$ )a  Generates an IAM token for the current user, if the user is a Googler.

The IAM token consists of three concatenated strings:
1. The `iam-` prefix.
2. The token associated with the credentials from the active account.
3. The authorization token stored in the auth.authorization_token_file
   property.

Returns:
  The IAM token for the current user.

Raises:
  Error: if the user is not a Googler.
zNIAM tokens are only supported for internal users. Please use a Google account.TF)use_google_authallow_account_impersonation)requiredziam-^)r   rf   c_storerh  r   r,  rZ  authorization_token_filer  r   ReadFileContentstoken)credauth_token_file
auth_tokens      rp   rB  rB    s     
	 	 
	 
 
d	N$%%**CCGG H / **?;*

|1ZL	))ro   )F)T)rm   
__future__r   r   r   rs   r  ra  apitools.base.pyr   r   r   googlecloudsdk.api_lib.containerr   r?  googlecloudsdk.api_lib.servicesr	   $googlecloudsdk.command_lib.util.apisr
   googlecloudsdk.corer   core_exceptionsr   r   r   googlecloudsdk.core.credentialsr   r)  googlecloudsdk.core.resourcer   googlecloudsdk.core.updaterr   googlecloudsdk.core.utilr   r   r   r  CLUSTERS_FORMATOPERATIONS_FORMATNODEPOOLS_FORMATHTTP_ERROR_FORMAT*WARN_NODE_VERSION_WITH_AUTOUPGRADE_ENABLEDWARN_BETA_APIS_ENABLEDINVALIID_SURGE_UPGRADE_SETTINGSr  rx  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  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  r  r  r  r  r  r  r  r  r  r  r  rX  r[  rY  rd  rZ  rf  rg  ri  rj  rl  rr  rs  rm  rk  ru  rn  ro  rw  rx  r\  r^  r`  r_  r  r  r  r  rf   r{   r   r   r  rP  CGROUPV1_CHECKING_FAILURE_MSGr   r   r   r   r   r   r   r   r   rN  r   r   r   r   r   r   r   r   r   r   r   objectr   r  r  rL  rR  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  rB  rh   ro   rp   <module>rD     sY   0 &  ' 	 	 	 % > B 6 6 : & = # * $ < 9 6 8 . 
   B 
3 +N   '   !#  " # *   - " ? 2 1 3 %B "$@ !- - ) 5 	"> !< ""# # ' % # 2 ' "> !5 ' 
 " . *L ' 9 & ) %- ",; )"(    " & " #5  ,6 )#4  -G *-G *, #4  ' 7 "+ * !* )8 &08 -/6 ,.4 +7E 408 -49 16= 36C 36D 3 6 -1 )08 -5; 249 14= %0 " ' !  9 6 +M (7O!! 7  $ O O ? ;1D30*8v- e E e u 5 U % Pe P%  % q;F q;h	5<0T	Qn<M@`P6$&R"BBBBB <-~2CDE*3 *ro   