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,30 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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.
"""Command group for Service Mesh Feature."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base as calliope_base
@calliope_base.ReleaseTracks(calliope_base.ReleaseTrack.ALPHA,
calliope_base.ReleaseTrack.BETA,
calliope_base.ReleaseTrack.GA)
class ServiceMesh(calliope_base.Group):
"""Manage Service Mesh Feature."""
category = calliope_base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Command group for Debugging Service Mesh Membership."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base as calliope_base
@calliope_base.ReleaseTracks(
calliope_base.ReleaseTrack.ALPHA, calliope_base.ReleaseTrack.BETA
)
class Debug(calliope_base.Group):
"""Debug Service Mesh memberships."""
category = calliope_base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Capture cluster information and logs into archive to help diagnose problems."""
from googlecloudsdk.api_lib.container.fleet import debug_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet import resources
from googlecloudsdk.command_lib.container.fleet.mesh import istioctl_backend
from googlecloudsdk.core import properties
class BugReport(base.BinaryBackedCommand):
"""Capture cluster information and logs into archive to help diagnose problems.
Example: ${command} --project=projectId
--membership=membershipId
--location=location
"""
@staticmethod
def Args(parser):
resources.AddMembershipResourceArg(
parser, plural=False,
membership_required=True,
membership_help='Name of the membership to troubleshoot against.'
)
def Run(self, args):
command_executor = istioctl_backend.IstioctlWrapper()
context = debug_util.ContextGenerator(args)
auth_cred = istioctl_backend.GetAuthToken(
account=properties.VALUES.core.account.Get(), operation='apply'
)
response = command_executor(
command='bug-report',
context=context,
env=istioctl_backend.GetEnvArgsForCommand(
extra_vars={'GCLOUD_AUTH_PLUGIN': 'true'}
),
stdin=auth_cred,
)
return response

View File

@@ -0,0 +1,127 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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.
"""A group of commands used to retrieve information about proxy configuration from the Envoy config dump."""
from googlecloudsdk.api_lib.container.fleet import debug_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet import resources
from googlecloudsdk.command_lib.container.fleet.mesh import istioctl_backend
from googlecloudsdk.core import properties
EXAMPLES = r"""
To retrieve the type cluster config dump for Pod instance pn.default.
${command} pn.default
--type=cluster
--project=projectId
--membership=membershipId
--location=us-central1
--ouput=yaml
"""
@base.DefaultUniverseOnly
class ProxyConfig(base.BinaryBackedCommand):
"""Retrieve a configuration summary for a given Envoy instance.
"""
detailed_help = {'EXAMPLES': EXAMPLES}
@staticmethod
def Args(parser):
resources.AddMembershipResourceArg(
parser,
plural=False,
membership_required=True,
membership_help='Name of the membership to troubleshoot against.',
)
parser.add_argument(
'pod_name_namespace',
help='Pod to check against. Use in format of <pod-name[.Namespace]>',
)
proxy_config_type = base.ChoiceArgument(
'--type',
required=True,
choices=[
'bootstrap',
'cluster',
'clusters',
'endpoint',
'endpoints',
'listener',
'listeners',
'log',
'route',
'routes',
'secret',
'secrets',
],
help_str=(
'Proxy configuration type to retrieve. \n\n '
' bootstrap Retrieves bootstrap configuration for the'
' Envoy in the specified pod \n clusters/cluster Retrieves'
' cluster configuration for the Envoy in the specified pod \n'
' endpoints/endpoint Retrieves endpoint configuration for the'
' Envoy in the specified pod \n listeners/listener Retrieves'
' listener configuration for the Envoy in the specified pod \n log '
' Retrieves logging levels of the Envoy in the'
' specified pod \n routes/route Retrieves route'
' configuration for the Envoy in the specified pod \n'
' secrets/secret Retrieves secret configuration for the Envoy'
' in the specified pod \n'
),
)
proxy_config_type.AddToParser(parser)
parser.add_argument(
'--output',
choices=['json', 'yaml'],
required=False,
help=(
'Return the detailed proxy config. The output format is either json'
' or yaml.'
),
)
parser.add_argument(
'--fqdn',
required=False,
help=(
'Filter clusters by substring of Service FQDN field. If'
' unspecified, all clusters will be included in the output"'
),
)
def Run(self, args):
command_executor = istioctl_backend.IstioctlWrapper()
# Generate kubecontext
context = debug_util.ContextGenerator(args)
auth_cred = istioctl_backend.GetAuthToken(
account=properties.VALUES.core.account.Get(), operation='apply'
)
response = command_executor(
command='proxy-config',
context=context,
env=istioctl_backend.GetEnvArgsForCommand(
extra_vars={'GCLOUD_AUTH_PLUGIN': 'true'}
),
proxy_config_type=args.type,
pod_name_namespace=args.pod_name_namespace,
output_format=args.output,
fqdn=args.fqdn,
stdin=auth_cred,
)
return response

View File

@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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.
"""Capture client sync status."""
from googlecloudsdk.api_lib.container.fleet import debug_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet import resources
from googlecloudsdk.command_lib.container.fleet.mesh import istioctl_backend
from googlecloudsdk.core import log
from googlecloudsdk.core import properties
# Pull out the example text so the example command can be one line without the
# py linter complaining. The docgen tool properly breaks it into multiple lines.
EXAMPLES = r"""
Retrieve the configuration sync status of all the proxies with the control plane.
Example: ${command} --project=projectId --membership=membershipId --location=us-central1
"""
class ProxyStatus(base.BinaryBackedCommand):
"""Retrieve the envoy configuration sync status.
"""
detailed_help = {'EXAMPLES': EXAMPLES}
@staticmethod
def Args(parser):
resources.AddMembershipResourceArg(
parser,
plural=False,
membership_required=True,
membership_help='Name of the membership to troubleshoot against.',
)
parser.add_argument(
'pod_name',
nargs='?',
hidden=True,
help=(
'If applied, capture the config dump differences between control'
' plane and Envoy.'
),
)
def Run(self, args):
command_executor = istioctl_backend.IstioctlWrapper()
# Generate kubecontext
context = debug_util.ContextGenerator(args)
# Generate meshname for the target membership
mesh_name, project_number = debug_util.MeshInfoGenerator(args)
if mesh_name:
log.status.Print('Found MeshName = ' + mesh_name)
if project_number:
log.status.Print('Found project number = ' + project_number)
auth_cred = istioctl_backend.GetAuthToken(
account=properties.VALUES.core.account.Get(), operation='apply'
)
# pod_name = args.pod_name if args.pod_name else ''
response = command_executor(
command='proxy-status',
pod_name=args.pod_name,
context=context,
mesh_name=mesh_name,
project_number=project_number,
env=istioctl_backend.GetEnvArgsForCommand(
extra_vars={'GCLOUD_AUTH_PLUGIN': 'true'}
),
stdin=auth_cred,
)
return response

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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 command to get the status of Service Mesh Feature."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.command_lib.container.fleet.features import base
class Describe(base.DescribeCommand):
"""Describe the status of Service Mesh Feature resource.
Describe the status of Service Mesh Feature resource in a fleet.
## EXAMPLES
To describe the Service Mesh Feature, run:
$ {command}
"""
feature_name = 'servicemesh'

View File

@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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 command to disable the Service Mesh Feature."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.features import base as features_base
@base.DefaultUniverseOnly
class Disable(features_base.DisableCommand):
"""Disable Service Mesh Feature.
Disable the Service Mesh Feature in a fleet.
## EXAMPLES
To disable the Service Mesh Feature, run:
$ {command}
To delete the fleet-level default Membership configuration, run:
$ {command} --fleet-default-member-config
"""
feature_name = 'servicemesh'
@classmethod
def Args(cls, parser):
parser.add_argument(
'--fleet-default-member-config',
action='store_true',
help="""If specified, deletes the default membership
configuration present in your fleet.
To delete the fleet-level default Membership configuration present in
your fleet, run:
$ {command} --fleet-default-member-config""",
)
parser.add_argument(
'--force',
action='store_true',
help=(
'Disable this feature, even if it is currently in use. '
'Force disablement may result in unexpected behavior.'
),
)
def Run(self, args):
# Clear the fleet_default_member_config if the
# fleet_default_member_config flag is set to true.
if args.fleet_default_member_config:
patch = self.messages.Feature(name=self.FeatureResourceName())
self.Update(['fleet_default_member_config'], patch)
else:
self.Disable(force=args.force)

View File

@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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 command to enable Service Mesh Feature."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.command_lib.anthos.common import file_parsers
from googlecloudsdk.command_lib.container.fleet.features import base
from googlecloudsdk.command_lib.container.fleet.mesh import utils
class Enable(base.EnableCommand):
"""Enable Service Mesh Feature.
Enable the Service Mesh Feature in a fleet.
## EXAMPLES
To enable the Service Mesh Feature, run:
$ {command}
To enable the Service Mesh Feature with a fleet-level default Membership
configuration, run:
$ {command} --fleet-default-member-config=/path/to/service-mesh.yaml
"""
feature_name = 'servicemesh'
@classmethod
def Args(cls, parser):
parser.add_argument(
'--fleet-default-member-config',
type=str,
help="""The path to a service-mesh.yaml configuration file.
To enable the Service Mesh Feature with a fleet-level default
membership configuration, run:
$ {command} --fleet-default-member-config=/path/to/service-mesh.yaml""",
)
def Run(self, args):
empty_feature = self.messages.Feature()
# Run enable with an empty feature if the fleet_default_member_config
# is not specified
if not args.fleet_default_member_config:
return self.Enable(empty_feature)
# Load config YAML file.
loaded_config = file_parsers.YamlConfigFile(
file_path=args.fleet_default_member_config,
item_type=utils.FleetDefaultMemberConfigObject,
)
# Create new service mesh feature spec.
member_config = utils.ParseFleetDefaultMemberConfig(
loaded_config, self.messages
)
# Create a feature object that has a default fleet member config
feature = self.messages.Feature(
fleetDefaultMemberConfig=self.messages.CommonFleetDefaultMemberConfigSpec(
mesh=member_config
)
)
return self.Enable(feature)

View File

@@ -0,0 +1,487 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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 command to update Service Mesh Feature."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from apitools.base.py import exceptions as apitools_exceptions
from googlecloudsdk.api_lib.container.fleet import util
from googlecloudsdk.calliope import actions
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.anthos.common import file_parsers
from googlecloudsdk.command_lib.container.fleet import resources
from googlecloudsdk.command_lib.container.fleet.features import base as features_base
from googlecloudsdk.command_lib.container.fleet.membershipfeatures import base as mf_base
from googlecloudsdk.command_lib.container.fleet.mesh import utils
# LINT.IfChange(update_v2)
def _RunUpdateV2(cmd, args):
"""Runs the update command implementation that is common across release tracks.
For membership level spec update, we will use v2alpha API to directly update
the membership feature resource.
Args:
cmd: the release track specific command
args: the args passed to the command
"""
memberships = []
resource = False
update_mask = []
# Deprecated non-resource arg
if args.IsKnownAndSpecified('membership'):
resource = False
memberships = utils.ParseMemberships(args)
elif args.fleet_default_member_config is None:
resource = True
memberships = features_base.ParseMembershipsPlural(
args, prompt=True, search=True
)
for membership in memberships:
if not resource:
membership = cmd.MembershipResourceName(membership)
patch_v2 = cmd.messages_v2.FeatureSpec()
try:
existing_membership_feature = cmd.GetMembershipFeature(membership)
except apitools_exceptions.HttpNotFoundError:
existing_membership_feature = cmd.messages_v2.MembershipFeature()
if existing_membership_feature.spec:
patch_v2 = existing_membership_feature.spec
if not patch_v2.servicemesh:
patch_v2.servicemesh = cmd.messages_v2.ServiceMeshSpec()
if hasattr(args, 'origin') and args.origin is not None:
if args.origin == 'fleet':
patch_v2.origin = cmd.messages_v2.Origin(
type=cmd.messages_v2.Origin.TypeValueValuesEnum('FLEET')
)
if hasattr(args, 'management') and args.management is not None:
management_v2 = (
cmd.messages_v2.ServiceMeshSpec.ManagementValueValuesEnum(
'MANAGEMENT_MANUAL'))
if args.management == 'automatic':
management_v2 = (
cmd.messages_v2.ServiceMeshSpec.ManagementValueValuesEnum(
'MANAGEMENT_AUTOMATIC'))
if args.management == 'not_installed':
management_v2 = (
cmd.messages_v2.ServiceMeshSpec.ManagementValueValuesEnum(
'MANAGEMENT_NOT_INSTALLED'))
patch_v2.servicemesh.management = management_v2
if args.control_plane is not None:
control_plane_v2 = (
cmd.messages_v2.ServiceMeshSpec.ControlPlaneValueValuesEnum(
'MANUAL'))
if args.control_plane == 'automatic':
control_plane_v2 = (
cmd.messages_v2.ServiceMeshSpec.ControlPlaneValueValuesEnum(
'AUTOMATIC'))
elif args.control_plane == 'unspecified':
control_plane_v2 = (
cmd.messages_v2.ServiceMeshSpec.ControlPlaneValueValuesEnum(
'CONTROL_PLANE_MANAGEMENT_UNSPECIFIED'))
patch_v2.servicemesh.controlPlane = control_plane_v2
if hasattr(args, 'config_api') and args.config_api is not None:
config_api = (
cmd.messages_v2.ServiceMeshSpec.ConfigApiValueValuesEnum(
'CONFIG_API_UNSPECIFIED'
)
)
if args.config_api == 'istio':
config_api = (
cmd.messages_v2.ServiceMeshSpec.ConfigApiValueValuesEnum(
'CONFIG_API_ISTIO'
)
)
if args.config_api == 'gateway':
config_api = (
cmd.messages_v2.ServiceMeshSpec.ConfigApiValueValuesEnum(
'CONFIG_API_GATEWAY'
)
)
patch_v2.servicemesh.configApi = config_api
cmd.UpdateV2(
membership, ['spec'], cmd.messages_v2.MembershipFeature(spec=patch_v2)
)
f = cmd.messages.Feature()
if args.fleet_default_member_config:
# Load config YAML file.
loaded_config = file_parsers.YamlConfigFile(
file_path=args.fleet_default_member_config,
item_type=utils.FleetDefaultMemberConfigObject,
)
# Create new service mesh feature spec.
member_config = utils.ParseFleetDefaultMemberConfigV2(
loaded_config, cmd.messages
)
f.fleetDefaultMemberConfig = (
cmd.messages.CommonFleetDefaultMemberConfigSpec(mesh=member_config)
)
update_mask.append('fleet_default_member_config')
if update_mask:
cmd.Update(update_mask, f)
# LINT.ThenChange(:update_v1)
# LINT.IfChange(update_v1)
def _RunUpdate(cmd, args):
"""Runs the update command implementation that is common across release tracks.
Args:
cmd: the release track specific command
args: the args passed to the command
"""
memberships = []
resource = False
update_mask = []
# Deprecated non-resource arg
if args.IsKnownAndSpecified('membership'):
resource = False
memberships = utils.ParseMemberships(args)
update_mask = ['membershipSpecs']
elif args.fleet_default_member_config is None:
resource = True
memberships = features_base.ParseMembershipsPlural(
args, prompt=True, search=True
)
update_mask = ['membershipSpecs']
f = cmd.GetFeature()
membership_specs = {}
for membership in memberships:
if not resource:
membership = cmd.MembershipResourceName(membership)
patch = cmd.messages.MembershipFeatureSpec()
for name, spec in cmd.hubclient.ToPyDict(f.membershipSpecs).items():
if (
util.MembershipShortname(name) == util.MembershipShortname(membership)
and spec
):
patch = spec
if not patch.mesh:
patch.mesh = cmd.messages.ServiceMeshMembershipSpec()
if hasattr(args, 'origin') and args.origin is not None:
if args.origin == 'fleet':
patch.origin = cmd.messages.Origin(
type=cmd.messages.Origin.TypeValueValuesEnum('FLEET')
)
if hasattr(args, 'management') and args.management is not None:
management = (
cmd.messages.ServiceMeshMembershipSpec.ManagementValueValuesEnum(
'MANAGEMENT_MANUAL'
)
)
if args.management == 'automatic':
management = (
cmd.messages.ServiceMeshMembershipSpec.ManagementValueValuesEnum(
'MANAGEMENT_AUTOMATIC'
)
)
if args.management == 'not_installed':
management = (
cmd.messages_v2.ServiceMeshSpec.ManagementValueValuesEnum(
'MANAGEMENT_NOT_INSTALLED'))
patch.mesh.management = management
if args.control_plane is not None:
control_plane = (
cmd.messages.ServiceMeshMembershipSpec.ControlPlaneValueValuesEnum(
'MANUAL'
)
)
if args.control_plane == 'automatic':
control_plane = (
cmd.messages.ServiceMeshMembershipSpec.ControlPlaneValueValuesEnum(
'AUTOMATIC'
)
)
elif args.control_plane == 'unspecified':
control_plane = (
cmd.messages.ServiceMeshMembershipSpec.ControlPlaneValueValuesEnum(
'CONTROL_PLANE_MANAGEMENT_UNSPECIFIED'
)
)
patch.mesh.controlPlane = control_plane
if hasattr(args, 'config_api') and args.config_api is not None:
config_api = (
cmd.messages.ServiceMeshMembershipSpec.ConfigApiValueValuesEnum(
'CONFIG_API_UNSPECIFIED'
)
)
if args.config_api == 'istio':
config_api = (
cmd.messages.ServiceMeshMembershipSpec.ConfigApiValueValuesEnum(
'CONFIG_API_ISTIO'
)
)
if args.config_api == 'gateway':
config_api = (
cmd.messages.ServiceMeshMembershipSpec.ConfigApiValueValuesEnum(
'CONFIG_API_GATEWAY'
)
)
patch.mesh.configApi = config_api
membership_specs[membership] = patch
f = cmd.messages.Feature(
membershipSpecs=cmd.hubclient.ToMembershipSpecs(membership_specs)
)
if args.fleet_default_member_config:
# Load config YAML file.
loaded_config = file_parsers.YamlConfigFile(
file_path=args.fleet_default_member_config,
item_type=utils.FleetDefaultMemberConfigObject,
)
# Create new service mesh feature spec.
member_config = utils.ParseFleetDefaultMemberConfig(
loaded_config, cmd.messages
)
f.fleetDefaultMemberConfig = (
cmd.messages.CommonFleetDefaultMemberConfigSpec(mesh=member_config)
)
update_mask.append('fleet_default_member_config')
cmd.Update(update_mask, f)
# LINT.ThenChange(:update_v2)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(features_base.UpdateCommand, mf_base.UpdateCommand):
"""Update the configuration of the Service Mesh Feature.
Update the Service Mesh Feature Spec of a membership.
## EXAMPLES
To update the control plane management of comma separated memberships like
`MEMBERSHIP1,MEMBERSHIP2`, run:
$ {command} --memberships=MEMBERSHIP1,MEMBERSHIP2
--control-plane=CONTROL_PLANE
"""
feature_name = 'servicemesh'
mf_name = 'servicemesh'
@staticmethod
def Args(parser):
args_group = parser.add_mutually_exclusive_group(required=True)
args_group.add_argument(
'--fleet-default-member-config',
type=str,
help="""The path to a service-mesh.yaml configuration file.
To enable the Service Mesh Feature with a fleet-level default
membership configuration, run:
$ {command} --fleet-default-member-config=/path/to/service-mesh.yaml""",
)
membership_group = args_group.add_group(
'Component options',
)
membership_names_group = membership_group.add_mutually_exclusive_group()
resources.AddMembershipResourceArg(
membership_names_group,
plural=True,
membership_help=(
'Membership names to update, separated by commas if '
'multiple are supplied.'
),
)
membership_names_group.add_argument(
'--membership',
type=str,
help='Membership name to update.',
action=actions.DeprecationAction(
'--membership',
warn=(
'The {flag_name} flag is now '
'deprecated. Please use `--memberships` '
'instead.'
),
),
)
membership_config_group = membership_group.add_group(required=True)
membership_config_group.add_argument(
'--origin',
choices=['fleet'],
help='Changing the origin of the membership.',
)
membership_controlplane_group = (
membership_config_group.add_mutually_exclusive_group()
)
membership_controlplane_group.add_argument(
'--config-api',
choices=['istio', 'gateway'],
help='The API to use for mesh configuration.',
)
membership_controlplane_group.add_argument(
'--management',
choices=['automatic', 'manual', 'not_installed'],
help='The management mode to update to.',
)
membership_controlplane_group.add_argument(
'--control-plane',
choices=['automatic', 'manual', 'unspecified'],
help='Control plane management to update to.',
action=actions.DeprecationAction(
'--control-plane',
warn=(
'The {flag_name} flag is now '
'deprecated. Please use `--management` '
'instead. '
'See https://cloud.google.com/service-mesh/docs/managed/provision-managed-anthos-service-mesh'
),
),
)
def Run(self, args):
# If the user is using the fleet default config, we will still use the v1
# Feature API for the update.
use_fleet_default_config = (
hasattr(args, 'origin')
and args.origin == 'fleet'
)
if not use_fleet_default_config:
_RunUpdateV2(self, args)
else:
_RunUpdate(self, args)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA, base.ReleaseTrack.GA)
class UpdateGA(features_base.UpdateCommand, mf_base.UpdateCommand):
"""Update the configuration of the Service Mesh Feature.
Update the Service Mesh Feature Spec of a Membership.
## EXAMPLES
To update the control plane management of comma separated Memberships like
`membership1,membership2`, run:
$ {command} --memberships=membership1,membership2
--control-plane=CONTROL_PLANE
"""
feature_name = 'servicemesh'
mf_name = 'servicemesh'
@staticmethod
def Args(parser):
args_group = parser.add_mutually_exclusive_group(required=True)
args_group.add_argument(
'--fleet-default-member-config',
type=str,
help="""The path to a service-mesh.yaml configuration file.
To enable the Service Mesh Feature with a fleet-level default
membership configuration, run:
$ {command} --fleet-default-member-config=/path/to/service-mesh.yaml""",
)
membership_group = args_group.add_group()
membership_names_group = membership_group.add_mutually_exclusive_group()
resources.AddMembershipResourceArg(
membership_names_group,
plural=True,
membership_help=(
'Membership names to update, separated by commas if '
'multiple are supplied.'
),
)
membership_configs_group = membership_group.add_group(required=True)
membership_configs_group.add_argument(
'--origin',
choices=['fleet'],
help='Changing the origin of the membership.',
)
membership_controlplane_group = (
membership_configs_group.add_mutually_exclusive_group()
)
membership_controlplane_group.add_argument(
'--config-api',
choices=['istio', 'gateway'],
help='The API to use for mesh configuration.',
)
membership_controlplane_group.add_argument(
'--management',
choices=['automatic', 'manual'],
help='The management mode to update to.',
)
membership_controlplane_group.add_argument(
'--control-plane',
choices=['automatic', 'manual', 'unspecified'],
help='Control plane management to update to.',
action=actions.DeprecationAction(
'--control-plane',
warn=(
'The {flag_name} flag is now '
'deprecated. Please use `--management` '
'instead. '
'See https://cloud.google.com/service-mesh/docs/managed/provision-managed-anthos-service-mesh'
),
),
)
def Run(self, args):
# If the user is using the fleet default config, we will still use the v1
# Feature API for the update.
use_fleet_default_config = (
hasattr(args, 'origin')
and args.origin == 'fleet'
)
if not use_fleet_default_config:
_RunUpdateV2(self, args)
else:
_RunUpdate(self, args)