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,44 @@
# -*- 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 Container Registry to Artifact Registry upgrade."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.BETA, base.ReleaseTrack.GA)
class Upgrade(base.Group):
r"""Commands to support Container Registry to Artifact Registry upgrade.
To print an equivalent Artifact Registry IAM policy for 'gcr.io/my-project':
$ {command} print-iam-policy gcr.io --project=my-project
To migrate a project from Container Registry to Artifact Registry using gcr.io
repos:
$ {command} migrate --projects=my-project
To migrate a project from Container Registry to Artifact Registry using
pkg.dev repos:
$ {command} migrate --from-gcr-io=gcr.io/from-project \
--to-pkg-dev=to-project/to-repo
"""
category = base.CI_CD_CATEGORY

View File

@@ -0,0 +1,83 @@
- release_tracks: [GA]
help_text:
brief: |
Migrate projects from Container Registry to Artifact Registry
description: |
Migrate projects from Container Registry to Artifact Registry
examples: |
To migrate a project `my-project` using gcr.io repositories:
$ {command} --projects=my-project
To migrate several projects using gcr.io repositories:
$ {command} --projects=my-project1,my-project2,my-project3
To migrate a project using pkg.dev repositories:
$ {command} --from-gcr=gcr.io/project1 --to-pkg-dev=project2/repo_name
arguments:
params:
- arg_name: projects
help_text: >
Comma seperated list of Container Registry projects to migrate to Artifact Registry gcr.io repositories.
- arg_name: recent-images
metavar: NUM_DAYS
type: int
help_text: Only copy images pulled or pushed in the last NUM_DAYS days. NUM_DAYS must be between 30 and 90 inclusive.
- arg_name: from-gcr
metavar: GCR_HOST/PROJECT_ID
help_text: >
Container Registry host + project to copy from. This flag is only used when migrating to pkg.dev repos. Example: gcr.io/my-project
- arg_name: to-pkg-dev
metavar: PROJECT_ID/REPOSITORY_ID
help_text: >
Artifact Registry pkg.dev project ID and repository ID to copy to. Example: my-project/my-repo
- arg_name: copy-only
type: bool
help_text: "Only perform image copying"
- arg_name: canary-reads
metavar: PERCENT
type: int
help_text: "Send only a percent of reads to Artifact Registry. The rest of reads and all writes are sent to Container Registry."
- arg_name: max-threads
type: int
default: 8
help_text: "Max number of images to copy simultaneously. Consider quota usage when increasing this"
- arg_name: skip-iam-update
type: bool
help_text: >
Migrate without changing iam-policy. Users without Artifact Registry permissions will not have access to migrated images.
- arg_name: last-uploaded-versions
metavar: N
type: int
help_text: >
Only copy the N most recently uploaded versions of each image. More than N images may be copied if new images are uploaded during migration.
- arg_name: output-iam-policy-dir
metavar: DIRECTORY
help_text: >
Outputs Artifact Registry-equivalent bindings to this directory during IAM update step and then exits the tool. After any neccesary modifications are made, the tool can be rerun with --input-iam-policy-dir to continue migration with the generated bindings.
- arg_name: input-iam-policy-dir
metavar: DIRECTORY
help_text: >
During the IAM update step, the tool applies all iam policies in the given directory.
- arg_name: pkg-dev-location
help_text: >
The location of the pkg-dev repository you are migrating to. If not specified, migration is always done to the same multi-region as GCR. Setting this flag can cause cross-regional copying and lead to billing charges.
- arg_name: skip-pre-copy
type: bool
help_text: >
Skip the initial copy of recent images before enabling redirection.
- arg_name: use-analyze-iam
type: bool
default: true
help_text: >
Use analyzeIAMPolicy to get IAM bindings. If false, tooling iterates through IAM bindings itself, which is slower, but doesn't require anlayzeIAMPolicy quota.
request:
api_version: v1
disable_resource_check: true
collection: artifactregistry.projects
method: updateProjectSettings
issue_request_hook: googlecloudsdk.command_lib.artifacts.util:MigrateToArtifactRegistry

View File

@@ -0,0 +1,64 @@
# -*- 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.
"""Print an Artifact Registry IAM policy for Container Registry to Artifact Registry upgrade."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.artifacts import flags
from googlecloudsdk.command_lib.artifacts import upgrade_util
from googlecloudsdk.command_lib.artifacts import util
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class PrintIamPolicy(base.Command):
"""Print an Artifact Registry IAM policy for Container Registry to Artifact Registry upgrade.
Print an Artifact Registry IAM policy that is equivalent to the IAM policy
applied to the storage bucket for the specified Container Registry hostname.
Apply the returned policy to the Artifact Registry repository that will
replace the specified host. If the project has an organization, this command
analyzes IAM policies at the organization level. Otherwise, this command
analyzes IAM policies at the project level. See required permissions at
https://cloud.google.com/policy-intelligence/docs/analyze-iam-policies#required-permissions.
"""
detailed_help = {
'DESCRIPTION': '{description}',
'EXAMPLES': """\
To print an equivalent Artifact Registry IAM policy for 'gcr.io/my-project':
$ {command} upgrade print-iam-policy gcr.io --project=my-project
""",
}
@staticmethod
def Args(parser):
flags.GetGCRDomainArg().AddToParser(parser)
def Run(self, args):
"""Runs the command.
Args:
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
An iam.Policy.
"""
domain = args.DOMAIN
project = util.GetProject(args)
return upgrade_util.iam_policy(domain, project)