feat: Add new gcloud commands, API clients, and third-party libraries across various services.

This commit is contained in:
2026-01-01 20:26:35 +01:00
parent 5e23cbece0
commit a19e592eb7
25221 changed files with 8324611 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The gcloud anthos auth command group."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Auth(base.Group):
"""Authenticate clusters using the Anthos client.
Authenticate clusters using the Anthos client.
For more details on Anthos, see https://cloud.google.com/anthos/.
"""
category = base.ANTHOS_AUTH_CATEGORY

View File

@@ -0,0 +1,139 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Authenticate clusters using the Anthos client.."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.anthos import anthoscli_backend
from googlecloudsdk.command_lib.anthos import flags
from googlecloudsdk.command_lib.anthos.common import kube_flags
from googlecloudsdk.command_lib.anthos.common import messages
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
class Login(base.BinaryBackedCommand):
"""Authenticate clusters using the Anthos client."""
detailed_help = {
'EXAMPLES': """
To add credentials to default kubeconfig file:
$ {command} --cluster=testcluster --login-config=kubectl-anthos-config.yaml
To add credentials to custom kubeconfig file:
$ {command} --cluster=testcluster --login-config=kubectl-anthos-config.yaml --kubeconfig=my.kubeconfig
To generate the commands without executing them:
$ {command} --cluster=testcluster --login-config=kubectl-anthos-config.yaml --dry-run
To add credentials to default kubeconfig file using server side login:
$ {command} --cluster=testcluster --server=<server-url>
To add credentials to custom kubeconfig file using server side login:
$ {command} --cluster=testcluster --server=<server-url> --kubeconfig=my.kubeconfig
To add credentials to custom kubeconfig file with server side login using a remote-device for login:
$ {command} --cluster=testcluster --server=<server-url> --kubeconfig=my.kubeconfig --no-browser
""",
}
@staticmethod
def Args(parser):
kube_flags.GetKubeConfigFlag(
'Specifies the destination kubeconfig file '
'where credentials will be stored.').AddToParser(parser)
flags.GetUserFlag().AddToParser(parser)
flags.GetClusterFlag().AddToParser(parser)
flags.GetLoginConfigFlag().AddToParser(parser)
flags.GetLoginConfigCertFlag().AddToParser(parser)
flags.GetDryRunFlag('Print out the generated kubectl commands '
'but do not execute them.').AddToParser(parser)
flags.GetSetPreferredAuthenticationFlag().AddToParser(parser)
flags.GetServerFlag().AddToParser(parser)
flags.GetNoBrowserFlag().AddToParser(parser)
flags.GetRemoteBootstrapFlag().AddToParser(parser)
def Run(self, args):
command_executor = anthoscli_backend.AnthosAuthWrapper()
cluster = args.CLUSTER
# If "server" flag is used, skip reading local config file.
if args.server:
# Log and execute binary command with flags.
log.status.Print(messages.LOGIN_CONFIG_MESSAGE)
response = command_executor(
command='login',
cluster=cluster,
kube_config=args.kubeconfig,
login_config_cert=args.login_config_cert,
dry_run=args.dry_run,
server_url=args.server,
no_browser=args.no_browser,
remote_bootstrap=args.remote_bootstrap,
env=anthoscli_backend.GetEnvArgsForCommand(
extra_vars={'GCLOUD_AUTH_PLUGIN': 'true'}
),
)
return anthoscli_backend.LoginResponseHandler(response)
# Get Default Path if flag not provided.
login_config = args.login_config or command_executor.default_config_path
# Get contents of config, parsing either URL or File.
login_config, config_contents, is_url = anthoscli_backend.GetFileOrURL(
login_config, args.login_config_cert)
# Get Preferred Auth Method and handle prompting.
force_update = args.set_preferred_auth
authmethod, ldapuser, ldappass = (
anthoscli_backend.GetPreferredAuthForCluster(
cluster=cluster,
login_config=login_config,
config_contents=config_contents,
force_update=force_update,
is_url=is_url,
)
)
# Log and execute binary command with flags.
log.status.Print(messages.LOGIN_CONFIG_MESSAGE)
response = command_executor(
command='login',
cluster=cluster,
kube_config=args.kubeconfig,
user=args.user,
login_config=login_config,
login_config_cert=args.login_config_cert,
dry_run=args.dry_run,
show_exec_error=args.show_exec_error,
ldap_user=ldapuser,
ldap_pass=ldappass,
preferred_auth=authmethod,
env=anthoscli_backend.GetEnvArgsForCommand(
extra_vars={'GCLOUD_AUTH_PLUGIN': 'true'}
),
)
return anthoscli_backend.LoginResponseHandler(
response, list_clusters_only=(cluster is None))

View File

@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Authenticate clusters using the Anthos client."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.anthos import anthoscli_backend
from googlecloudsdk.command_lib.anthos import flags
@base.Hidden
class Token(base.BinaryBackedCommand):
"""Creates a token for authentication."""
@staticmethod
def Args(parser):
flags.GetTypeFlag().AddToParser(parser)
flags.GetAwsStsRegionFlag().AddToParser(parser)
flags.GetTokenClusterFlag().AddToParser(parser)
flags.GetIdTokenFlag().AddToParser(parser)
flags.GetAccessTokenFlag().AddToParser(parser)
flags.GetAccessTokenExpiryFlag().AddToParser(parser)
flags.GetRefreshTokenFlag().AddToParser(parser)
flags.GetClientIdFlag().AddToParser(parser)
flags.GetClientSecretFlag().AddToParser(parser)
flags.GetIdpCertificateAuthorityDataFlag().AddToParser(parser)
flags.GetIdpIssuerUrlFlag().AddToParser(parser)
flags.GetKubeconfigPathFlag().AddToParser(parser)
flags.GetTokenUserFlag().AddToParser(parser)
def Run(self, args):
command_executor = anthoscli_backend.AnthosAuthWrapper()
# Log and execute binary command with flags.
response = command_executor(
command="token",
token_type=args.type,
cluster=args.cluster,
aws_sts_region=args.aws_sts_region,
id_token=args.id_token,
access_token=args.access_token,
access_token_expiry=args.access_token_expiry,
refresh_token=args.refresh_token,
client_id=args.client_id,
client_secret=args.client_secret,
idp_certificate_authority_data=args.idp_certificate_authority_data,
idp_issuer_url=args.idp_issuer_url,
kubeconfig_path=args.kubeconfig_path,
user=args.user,
env=anthoscli_backend.GetEnvArgsForCommand())
return self._DefaultOperationResponseHandler(response)

View File

@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Authenticate clusters using the Anthos client.."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.anthos import anthoscli_backend
@base.Hidden
class Version(base.BinaryBackedCommand):
"""Get version info for the Anthos Auth client."""
detailed_help = {
'EXAMPLES': """
To display version info:
$ {command}
""",
}
def Run(self, args):
command_executor = anthoscli_backend.AnthosAuthWrapper()
response = command_executor(
command='version',
show_exec_error=args.show_exec_error,
env=anthoscli_backend.GetEnvArgsForCommand())
return self._DefaultOperationResponseHandler(response)