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,28 @@
# -*- 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.
"""The command group for the Package Rollouts CLI."""
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class ConfigDelivery(base.Group):
"""Manage Fleet Packages resources."""
# See third_party/py/googlecloudsdk/calliope/base.py for a list of categories.
category = base.MANAGEMENT_TOOLS_CATEGORY

View File

@@ -0,0 +1,91 @@
# -*- 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.
"""Command to create Fleet Package."""
from googlecloudsdk.api_lib.container.fleet.packages import fleet_packages as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
from googlecloudsdk.command_lib.container.fleet.packages import utils
from googlecloudsdk.command_lib.export import util as export_util
from googlecloudsdk.core.console import console_io
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To create Fleet Package `cert-manager-app`, run:
$ {command} cert-manager-app --source=source.yaml
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create Package Rollouts Fleet Package."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
flags.AddSourceFlag(parser)
flags.AddNameFlag(parser)
flags.AddLocationFlag(parser)
def Run(self, args):
"""Run the create command."""
client = apis.FleetPackagesClient(self._api_version)
data = console_io.ReadFromFileOrStdin(
utils.ExpandPathForUser(args.source), binary=False
)
fleet_package = export_util.Import(
message_type=client.messages.FleetPackage,
stream=data,
)
if not fleet_package.variantSelector:
fleet_package.variantSelector = client.messages.VariantSelector(
variantNameTemplate='default'
)
parent = (
f'projects/{flags.GetProject(args)}/locations/{flags.GetLocation(args)}'
)
fully_qualified_name = f'{parent}/fleetPackages/{args.name}'
fleet_package = utils.UpsertFleetPackageName(
fleet_package, fully_qualified_name
)
fleet_package = utils.FixFleetPackagePathForCloudBuild(fleet_package)
return client.Create(
fleet_package=fleet_package, fleet_package_id=args.name, parent=parent
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create Package Rollouts Fleet Package."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(Create):
"""Create Package Rollouts Fleet Package."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,75 @@
# -*- 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.
"""Command to delete a Fleet Package."""
from googlecloudsdk.api_lib.container.fleet.packages import fleet_packages as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To delete Fleet Package `cert-manager-app` in `us-central1`, run:
$ {command} cert-manager-app --location=us-central1
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete Package Rollouts Fleet Package."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
flags.AddForceDeleteFlag(parser, 'Fleet Package')
concept_parsers.ConceptParser.ForResource(
'fleet_package',
flags.GetFleetPackageResourceSpec(),
'The Fleet Package to create.',
required=True,
prefixes=False,
).AddToParser(parser)
def Run(self, args):
"""Run the delete command."""
client = apis.FleetPackagesClient(self._api_version)
return client.Delete(
project=flags.GetProject(args),
location=flags.GetLocation(args),
name=args.fleet_package,
force=args.force,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete Package Rollouts Fleet Package."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DeleteAlpha(Delete):
"""Delete Package Rollouts Fleet Package."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,104 @@
# -*- 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.
"""Command to list all Fleet Packages in project."""
from googlecloudsdk.api_lib.container.fleet.packages import fleet_packages as apis
from googlecloudsdk.api_lib.container.fleet.packages import rollouts as rollouts_apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
from googlecloudsdk.command_lib.container.fleet.packages import utils
from googlecloudsdk.command_lib.util.concepts import concept_parsers
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To view Fleet Package `cert-manager-app` in `us-central1`, run:
$ {command} cert-manager-app --location=us-central1
""",
}
_ROLLOUT_BASENAME_INDEX = 7
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe Package Rollouts Fleet Package."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
concept_parsers.ConceptParser.ForResource(
'fleet_package',
flags.GetFleetPackageResourceSpec(),
'The Fleet Package to describe.',
required=True,
prefixes=False,
).AddToParser(parser)
parser.display_info.AddTransforms(
{'all_messages': utils.TransformAllClusterLevelMessages}
)
parser.add_argument(
'--show-cluster-status',
required=False,
action='store_true',
help='Show more information about the Fleet Package.',
)
def Run(self, args):
"""Run the describe command."""
client = apis.FleetPackagesClient(self._api_version)
rollouts_client = rollouts_apis.RolloutsClient(self._api_version)
result = client.Describe(
project=flags.GetProject(args),
location=flags.GetLocation(args),
name=args.fleet_package,
)
if args.show_cluster_status:
info = result.info
target_rollout = getattr(info, 'activeRollout', None)
if target_rollout is None:
target_rollout = getattr(info, 'lastCompletedRollout', None)
if target_rollout is not None:
described_rollout = rollouts_client.Describe(
project=flags.GetProject(args),
location=flags.GetLocation(args),
fleet_package=args.fleet_package,
rollout=target_rollout.split('/')[_ROLLOUT_BASENAME_INDEX],
)
if not args.format:
utils.FormatForRolloutsDescribe(described_rollout, args)
return described_rollout
return result
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe Package Rollouts Fleet Package."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(Describe):
"""Describe Package Rollouts Fleet Package."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,83 @@
# -*- 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.
"""Command to list all Fleet Packages."""
from googlecloudsdk.api_lib.container.fleet.packages import fleet_packages as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
from googlecloudsdk.command_lib.container.fleet.packages import utils
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To list all Fleet Packages in `us-central1`, run:
$ {command} --location=us-central1
""",
}
# For more formatting options see:
# http://cloud/sdk/gcloud/reference/topic/formats
_FORMAT = """table(name.basename():label=NAME,
info.State:label=STATE,
createTime.date(tz=LOCAL):label=CREATE_TIME,
info.activeRollout.basename():label=ACTIVE_ROLLOUT,
info.lastCompletedRollout.basename():label=LAST_COMPLETED_ROLLOUT,
fleet_package_errors():label=MESSAGES)"""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Package Rollouts Fleet Packages."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@classmethod
def Args(cls, parser):
parser.display_info.AddFormat(_FORMAT)
parser.display_info.AddTransforms(
{'fleet_package_errors': utils.TransformListFleetPackageErrors}
)
flags.AddUriFlags(parser, apis.FLEET_PACKAGE_COLLECTION, cls._api_version)
flags.AddLocationFlag(parser)
def Run(self, args):
"""Run the list command."""
client = apis.FleetPackagesClient(self._api_version)
return client.List(
project=flags.GetProject(args),
location=flags.GetLocation(args),
limit=args.limit,
page_size=args.page_size,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Package Rollouts Fleet Packages."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(List):
"""List Package Rollouts Fleet Packages."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,44 @@
# -*- 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.
"""The resource-bundles command group for the Package Rollouts CLI."""
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ResourceBundles(base.Group):
"""Commands for managing Package Rollouts Resource Bundles.
See `gcloud container fleet packages resource-bundles --help` for help.
"""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ResourceBundlesBeta(ResourceBundles):
"""Commands for managing Package Rollouts Resource Bundles.
See `gcloud beta container fleet packages resource-bundles --help` for help.
"""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ResourceBundlesAlpha(ResourceBundles):
"""Commands for managing Package Rollouts Resource Bundles.
See `gcloud alpha container fleet packages resource-bundles --help` for help.
"""

View File

@@ -0,0 +1,66 @@
# -*- 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.
"""Command to create Resource Bundle."""
from googlecloudsdk.api_lib.container.fleet.packages import resource_bundles as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To create Resource Bundle `cert-manager` in `us-central1`, run:
$ {command} cert-manager --location=us-central1
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create Package Rollouts Resource Bundle."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
flags.AddNameFlag(parser)
flags.AddLocationFlag(parser)
flags.AddDescriptionFlag(parser)
def Run(self, args):
"""Run the create command."""
client = apis.ResourceBundlesClient(self._api_version)
project = flags.GetProject(args)
location = flags.GetLocation(args)
return client.Create(project=project, location=location, name=args.name)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create Package Rollouts Resource Bundle."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(Create):
"""Create Package Rollouts Resource Bundle."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,69 @@
# -*- 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.
"""Command to delete a Resource Bundle."""
from googlecloudsdk.api_lib.container.fleet.packages import resource_bundles as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To delete Resource Bundle `cert-manager` in `us-central1`, run:
$ {command} cert-manager --location=us-central1
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete Package Rollouts Resource Bundle."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
flags.AddNameFlag(parser)
flags.AddLocationFlag(parser)
flags.AddForceDeleteFlag(parser, 'Resource Bundle')
def Run(self, args):
"""Run the delete command."""
client = apis.ResourceBundlesClient(self._api_version)
project = flags.GetProject(args)
location = flags.GetLocation(args)
return client.Delete(
project=project, location=location, name=args.name, force=args.force
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete Package Rollouts Resource Bundle."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DeleteAlpha(Delete):
"""Delete Package Rollouts Resource Bundle."""
detailed_help = _DETAILED_HELP
_api_version = 'v1alpha'

View File

@@ -0,0 +1,66 @@
# -*- 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.
"""Command to list all Resource Bundles in project."""
from googlecloudsdk.api_lib.container.fleet.packages import resource_bundles as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To describe Resource Bundle `cert-manager` in `us-central1`, run:
$ {command} cert-manager --location=us-central1
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe Package Rollouts Resource Bundle."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
flags.AddNameFlag(parser)
flags.AddLocationFlag(parser)
def Run(self, args):
"""Run the describe command."""
client = apis.ResourceBundlesClient(self._api_version)
project = flags.GetProject(args)
location = flags.GetLocation(args)
return client.Describe(project=project, location=location, name=args.name)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe Package Rollouts Resource Bundle."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(Describe):
"""Describe Package Rollouts Resource Bundle."""
detailed_help = _DETAILED_HELP
_api_version = 'v1alpha'

View File

@@ -0,0 +1,75 @@
# -*- 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.
"""Command to list all Resource Bundles in project."""
from googlecloudsdk.api_lib.container.fleet.packages import resource_bundles as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To list Resource Bundles in `us-central1`, run:
$ {command} --location=us-central1
""",
}
# For more formatting options see:
# http://cloud/sdk/gcloud/reference/topic/formats
_FORMAT = 'table(name.basename(), createTime)'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Package Rollouts Resource Bundles."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@classmethod
def Args(cls, parser):
parser.display_info.AddFormat(_FORMAT)
flags.AddLocationFlag(parser)
flags.AddUriFlags(parser, apis.RESOURCE_BUNDLE_COLLECTION, cls._api_version)
def Run(self, args):
"""Run the list command."""
client = apis.ResourceBundlesClient(self._api_version)
project = flags.GetProject(args)
location = flags.GetLocation(args)
return client.List(
project=project,
location=location,
limit=args.limit,
page_size=args.page_size,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Package Rollouts Resource Bundles."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(List):
"""List Package Rollouts Resource Bundles."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,47 @@
# -*- 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.
"""The releases command group for the Package Rollouts CLI."""
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Releases(base.Group):
"""Commands for managing Package Rollouts Releases.
See `gcloud container fleet packages resource-bundles releases
--help` for help.
"""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ReleasesBeta(Releases):
"""Commands for managing Package Rollouts Releases.
See `gcloud beta container fleet packages resource-bundles releases
--help` for help.
"""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ReleasesAlpha(Releases):
"""Commands for managing Package Rollouts Releases.
See `gcloud alpha container fleet packages resource-bundles releases
--help` for help.
"""

View File

@@ -0,0 +1,100 @@
# -*- 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.
"""Command to create Release."""
from googlecloudsdk.api_lib.container.fleet.packages import releases as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
from googlecloudsdk.command_lib.container.fleet.packages import utils
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To create Release `v1.0.0` for Resource Bundle `my-bundle` in `us-central1`, run:
$ {command} --version=v1.0.0 --resource-bundle=my-bundle --source=manifest.yaml
To create a Release with multiple variants in one directory, run:
$ {command} --version=v1.0.0 --resource-bundle=my-bundle --source=/manifests/ --variants-pattern=manifest-*.yaml
To create a Release with multiple variants across multiple directories, ex:
$ {command} --version=v1.0.0 --resource-bundle=my-bundle --source=/manifests/ --variants-pattern=dir-*/
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create Package Rollouts Release."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
flags.AddResourceBundleFlag(parser)
flags.AddLocationFlag(parser)
parser.add_argument(
'--version', required=True, help='Version of the Release to create.'
)
flags.AddLifecycleFlag(parser)
flags.AddVariantsPatternFlag(parser)
parser.add_argument(
'--source',
required=True,
help="""Source file or directory to create the Release from.
e.g. ``--source=manifest.yaml'', ``--source=/manifests-dir/''
Can optionally be paired with the ``--variants-pattern'' arg to create
multiple variants of a Release.""",
)
flags.AddSkipCreatingVariantResourcesFlag(parser)
def Run(self, args):
"""Run the create command."""
client = apis.ReleasesClient(self._api_version)
utils.ValidateSource(args.source)
glob_pattern = utils.GlobPatternFromSourceAndVariantsPattern(
args.source, args.variants_pattern
)
variants = utils.VariantsFromGlobPattern(glob_pattern)
return client.Create(
resource_bundle=args.resource_bundle,
version=args.version,
project=flags.GetProject(args),
location=flags.GetLocation(args),
lifecycle=args.lifecycle,
variants=variants,
skip_creating_variant_resources=args.skip_creating_variant_resources,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create Package Rollouts Release."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(Create):
"""Create Package Rollouts Release."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,71 @@
# -*- 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.
"""Command to delete a Release."""
from googlecloudsdk.api_lib.container.fleet.packages import releases as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To delete Release `v1.0.0` of `cert-manager` in `us-central1`, run:
$ {command} v1.0.0 --location=us-central1 --resource-bundle=cert-manager
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete Package Rollouts Release."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
flags.AddReleaseFlag(parser)
flags.AddLocationFlag(parser)
flags.AddResourceBundleFlag(parser)
flags.AddForceDeleteFlag(parser, 'Release')
def Run(self, args):
"""Run the delete command."""
client = apis.ReleasesClient(self._api_version)
return client.Delete(
release=args.release,
project=flags.GetProject(args),
location=flags.GetLocation(args),
resource_bundle=args.resource_bundle,
force=args.force,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete Package Rollouts Release."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DeleteAlpha(Delete):
"""Delete Package Rollouts Release."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,73 @@
# -*- 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.
"""Command to describe Release of a Resource Bundle."""
from googlecloudsdk.api_lib.container.fleet.packages import releases as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To view release `v1.0.0` of `cert-manager` in `us-central1`, run:
$ {command} v1.0.0 --location=us-central1 --resource-bundle=cert-manager
""",
}
_VARIANT_STORAGE_STRATEGY_LABEL_KEY = 'configdelivery-variant-storage-strategy'
_VARIANT_STORAGE_STRATEGY_LABEL_VALUE_NESTED = 'nested'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe Package Rollouts Release."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
flags.AddReleaseFlag(parser)
flags.AddLocationFlag(parser)
flags.AddResourceBundleFlag(parser)
def Run(self, args):
"""Run the describe command."""
client = apis.ReleasesClient(self._api_version)
release = client.Describe(
release=args.release,
project=flags.GetProject(args),
location=flags.GetLocation(args),
resource_bundle=args.resource_bundle,
)
return release
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe Package Rollouts Release."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(Describe):
"""Describe Package Rollouts Release."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,75 @@
# -*- 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.
"""Command to list all Releases of a Resource Bundle."""
from googlecloudsdk.api_lib.container.fleet.packages import releases as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To list all Releases for bundle `cert-manager` in `us-central1`, run:
$ {command} --resource-bundle=cert-manager --location=us-central1
""",
}
# For more formatting options see:
# http://cloud/sdk/gcloud/reference/topic/formats
_FORMAT = 'table(name.basename(), lifecycle, createTime)'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Releases of a Resource Bundle."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@classmethod
def Args(cls, parser):
parser.display_info.AddFormat(_FORMAT)
flags.AddLocationFlag(parser)
flags.AddResourceBundleFlag(parser)
flags.AddUriFlags(parser, apis.RELEASE_COLLECTION, cls._api_version)
def Run(self, args):
"""Run the list command."""
client = apis.ReleasesClient(self._api_version)
return client.List(
project=flags.GetProject(args),
location=flags.GetLocation(args),
parent_bundle=args.resource_bundle,
limit=args.limit,
page_size=args.page_size,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Releases of a Resource Bundle."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(List):
"""List Releases of a Resource Bundle."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,78 @@
# -*- 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.
"""Command to update Release."""
from googlecloudsdk.api_lib.container.fleet.packages import releases as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To update Release `v1.0.0` for Resource Bundle `my-bundle` in `us-central1`, run:
$ {command} --version=v1.0.0 --resource-bundle=my-bundle --lifecycle=PUBLISHED
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update Package Rollouts Release."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
flags.AddReleaseFlag(parser)
flags.AddLocationFlag(parser)
flags.AddResourceBundleFlag(parser)
flags.AddLifecycleFlag(parser)
def Run(self, args):
"""Run the update command."""
client = apis.ReleasesClient(self._api_version)
update_mask_attrs = []
if args.lifecycle:
update_mask_attrs.append('lifecycle')
update_mask = ','.join(update_mask_attrs)
return client.Update(
release=args.release,
project=flags.GetProject(args),
location=flags.GetLocation(args),
resource_bundle=args.resource_bundle,
lifecycle=args.lifecycle,
update_mask=update_mask,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update Package Rollouts Release."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(Update):
"""Update Package Rollouts Release."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,71 @@
# -*- 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.
"""Command to update Resource Bundle."""
from googlecloudsdk.api_lib.container.fleet.packages import resource_bundles as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To update Resource Bundle `cert-manager` in `us-central1`, run:
$ {command} cert-manager --location=us-central1 ...
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update Package Rollouts Resource Bundle."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
flags.AddNameFlag(parser)
flags.AddLocationFlag(parser)
flags.AddDescriptionFlag(parser)
def Run(self, args):
"""Run the update command."""
client = apis.ResourceBundlesClient(self._api_version)
project = flags.GetProject(args)
location = flags.GetLocation(args)
return client.Update(
project=project,
location=location,
name=args.name,
description=args.description,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update Package Rollouts Resource Bundle."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(Update):
"""Update Package Rollouts Resource Bundle."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,44 @@
# -*- 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.
"""The rollouts command group for the Package Rollouts CLI."""
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Rollouts(base.Group):
"""Commands for managing Rollouts.
See `gcloud container fleet packages rollouts --help` for help.
"""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class RolloutsBeta(Rollouts):
"""Commands for managing Rollouts.
See `gcloud beta container fleet packages rollouts --help` for help.
"""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class RolloutsAlpha(Rollouts):
"""Commands for managing Rollouts.
See `gcloud alpha container fleet packages rollouts --help` for help.
"""

View File

@@ -0,0 +1,78 @@
# -*- 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.
"""Command to abort an in-progress Rollout."""
from googlecloudsdk.api_lib.container.fleet.packages import rollouts as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To abort Rollout `20240318` for `cert-manager-app` in `us-central1`, run:
$ {command} 20240318 --fleet-package=cert-manager-app --location=us-central1
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Abort(base.Command):
"""Abort Rollout resource."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
concept_parsers.ConceptParser.ForResource(
'rollout',
flags.GetRolloutResourceSpec(),
'The rollout to abort.',
required=True,
prefixes=False,
).AddToParser(parser)
parser.add_argument(
'--reason', required=False, help='Reason for aborting rollout.'
)
def Run(self, args):
"""Run the abort command."""
client = apis.RolloutsClient(self._api_version)
return client.Abort(
project=flags.GetProject(args),
location=flags.GetLocation(args),
fleet_package=args.fleet_package,
rollout=args.rollout,
reason=args.reason,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class AbortBeta(Abort):
"""Abort Rollout resource."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class AbortAlpha(Abort):
"""Abort Rollout resource."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,90 @@
# -*- 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.
"""Command to describe Rollout in a project."""
from googlecloudsdk.api_lib.container.fleet.packages import rollouts as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
from googlecloudsdk.command_lib.container.fleet.packages import utils
from googlecloudsdk.core import log
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To view Rollout `20240318` for `cert-manager-app` in `us-central1`, run:
$ {command} 20240318 --fleet-package=cert-manager-app --location=us-central1
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe Rollout resource."""
detailed_help = _DETAILED_HELP
show_less = False
_api_version = 'v1'
def Epilog(self, resources_were_displayed):
if resources_were_displayed and self.show_less:
log.status.Print('\nRollout messages too long? Try --less.')
@staticmethod
def Args(parser):
parser.display_info.AddTransforms(
{'all_messages': utils.TransformAllClusterLevelMessages}
)
parser.display_info.AddTransforms(
{'trim_message': utils.TransformTrimClusterLevelMessages}
)
flags.AddNameFlag(parser)
flags.AddFleetPackageFlag(parser)
flags.AddLocationFlag(parser)
flags.AddLessFlag(parser)
def Run(self, args):
"""Run the describe command."""
client = apis.RolloutsClient(self._api_version)
output = client.Describe(
fleet_package=args.fleet_package,
project=flags.GetProject(args),
location=flags.GetLocation(args),
rollout=args.name,
)
if not args.format:
utils.FormatForRolloutsDescribe(output, args, args.less)
if output.info and output.info.message:
if not args.less:
self.show_less = True
return output
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe Rollout resource."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(Describe):
"""Describe Rollout resource."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,95 @@
# -*- 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.
"""Command to list all Rollouts of a Fleet Package."""
from googlecloudsdk.api_lib.container.fleet.packages import rollouts as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
from googlecloudsdk.command_lib.container.fleet.packages import utils
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To list all Rollouts for Fleet Package `cert-manager-app` in `us-central1`, run:
$ {command} --fleet-package=cert-manager-app --location=us-central1
""",
}
# For more formatting options see:
# http://cloud/sdk/gcloud/reference/topic/formats
_FORMAT = """table(name.basename():label=ROLLOUT,
release.basename():label=RELEASE,
info.startTime:label=START_TIME,
info.endTime:label=END_TIME,
info.state:label=STATE,
info.message:label=MESSAGE)"""
_FORMAT_TRUNCATED_MESSAGES = """table(name.basename():label=ROLLOUT,
release.basename():label=RELEASE,
info.startTime:label=START_TIME,
info.endTime:label=END_TIME,
info.state:label=STATE,
trim_message():label=MESSAGE)"""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Rollouts of a Fleet Package."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@classmethod
def Args(cls, parser):
parser.display_info.AddFormat(_FORMAT)
parser.display_info.AddTransforms(
{'trim_message': utils.TransformTrimRolloutLevelMessage}
)
flags.AddUriFlags(parser, apis.ROLLOUT_COLLECTION, cls._api_version)
flags.AddLocationFlag(parser)
flags.AddFleetPackageFlag(parser)
flags.AddLessFlag(parser)
def Run(self, args):
"""Run the list command."""
client = apis.RolloutsClient(self._api_version)
if args.less:
args.format = _FORMAT_TRUNCATED_MESSAGES
return client.List(
project=flags.GetProject(args),
location=flags.GetLocation(args),
fleet_package=args.fleet_package,
limit=args.limit,
page_size=args.page_size,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Rollouts of a Fleet Package."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(List):
"""List Rollouts of a Fleet Package."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,78 @@
# -*- 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.
"""Command to resume a suspended Rollout."""
from googlecloudsdk.api_lib.container.fleet.packages import rollouts as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To resume Rollout `20240318` for `cert-manager-app` in `us-central1`, run:
$ {command} 20240318 --fleet-package=cert-manager-app --location=us-central1
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Resume(base.Command):
"""Resume suspended Rollout."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
concept_parsers.ConceptParser.ForResource(
'rollout',
flags.GetRolloutResourceSpec(),
'The rollout to resume.',
required=True,
prefixes=False,
).AddToParser(parser)
parser.add_argument(
'--reason', required=False, help='Reason for resuming rollout.'
)
def Run(self, args):
"""Run the resume command."""
client = apis.RolloutsClient(self._api_version)
return client.Resume(
project=flags.GetProject(args),
location=flags.GetLocation(args),
fleet_package=args.fleet_package,
rollout=args.rollout,
reason=args.reason,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ResumeBeta(Resume):
"""Resume suspended Rollout."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ResumeAlpha(Resume):
"""Resume suspended Rollout."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,78 @@
# -*- 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.
"""Command to suspend an in-progress Rollout."""
from googlecloudsdk.api_lib.container.fleet.packages import rollouts as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To suspend Rollout `20240318` for `cert-manager-app` in `us-central1`, run:
$ {command} 20240318 --fleet-package=cert-manager-app --location=us-central1
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Suspend(base.Command):
"""Suspend in-progress Rollout."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
concept_parsers.ConceptParser.ForResource(
'rollout',
flags.GetRolloutResourceSpec(),
'The rollout to suspend.',
required=True,
prefixes=False,
).AddToParser(parser)
parser.add_argument(
'--reason', required=False, help='Reason for suspending rollout.'
)
def Run(self, args):
"""Run the suspend command."""
client = apis.RolloutsClient(self._api_version)
return client.Suspend(
project=flags.GetProject(args),
location=flags.GetLocation(args),
fleet_package=args.fleet_package,
rollout=args.rollout,
reason=args.reason,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class SuspendBeta(Suspend):
"""Suspend in-progress Rollout."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class SuspendAlpha(Suspend):
"""Suspend in-progress Rollout."""
_api_version = 'v1alpha'

View File

@@ -0,0 +1,106 @@
# -*- 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.
"""Command to create Fleet Package."""
from googlecloudsdk.api_lib.container.fleet.packages import fleet_packages as apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet.packages import flags
from googlecloudsdk.command_lib.container.fleet.packages import utils
from googlecloudsdk.command_lib.export import util as export_util
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core.console import console_io
_DETAILED_HELP = {
'DESCRIPTION': '{description}',
'EXAMPLES': """ \
To update Fleet Package `cert-manager-app`, run:
$ {command} cert-manager-app --source=my_source.yaml
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update Package Rollouts Fleet Package."""
detailed_help = _DETAILED_HELP
_api_version = 'v1'
@staticmethod
def Args(parser):
flags.AddSourceFlag(parser)
concept_parsers.ConceptParser.ForResource(
'fleet_package',
flags.GetFleetPackageResourceSpec(),
'The Fleet Package to create.',
required=True,
prefixes=False,
).AddToParser(parser)
def Run(self, args):
"""Run the update command."""
client = apis.FleetPackagesClient(self._api_version)
data = console_io.ReadFromFileOrStdin(
utils.ExpandPathForUser(args.source), binary=False
)
fleet_package = export_util.Import(
message_type=client.messages.FleetPackage,
stream=data,
)
possible_attributes = [
'resourceBundleSelector',
'target',
'variantSelector',
'rolloutStrategy',
'deletionPropagationPolicy',
'state',
]
update_mask_attrs = []
for attr in possible_attributes:
attr_value = getattr(fleet_package, attr, None)
if attr_value is not None:
update_mask_attrs.append(attr)
update_mask = ','.join(update_mask_attrs)
fully_qualified_name = f'projects/{flags.GetProject(args)}/locations/{flags.GetLocation(args)}/fleetPackages/{args.fleet_package}'
fleet_package = utils.UpsertFleetPackageName(
fleet_package, fully_qualified_name
)
fleet_package = utils.FixFleetPackagePathForCloudBuild(fleet_package)
return client.Update(
fleet_package=fleet_package,
name=fully_qualified_name,
update_mask=update_mask,
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update Package Rollouts Fleet Package."""
_api_version = 'v1beta'
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(Update):
"""Update Package Rollouts Fleet Package."""
_api_version = 'v1alpha'