From 8a3a6d61b63ce4321e8c9e94511010a7245e3d40 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 18:57:07 +0000 Subject: [PATCH] feat: [google-cloud-build] Add GoModule to Artifact and Results messages and new GO_MODULE_H1 hash type (#13416) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 713355615 Source-Link: https://github.com/googleapis/googleapis/commit/16db8020109a5fb90130261bd1b923e69f675154 Source-Link: https://github.com/googleapis/googleapis-gen/commit/998323131456ec0eae5131ee673a964cac69708b Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJ1aWxkLy5Pd2xCb3QueWFtbCIsImgiOiI5OTgzMjMxMzE0NTZlYzBlYWU1MTMxZWU2NzNhOTY0Y2FjNjk3MDhiIn0= --------- Co-authored-by: Owl Bot Co-authored-by: Victor Chudnovsky --- .../cloud/devtools/cloudbuild/__init__.py | 2 + .../devtools/cloudbuild/gapic_version.py | 2 +- .../cloud/devtools/cloudbuild_v1/__init__.py | 2 + .../devtools/cloudbuild_v1/gapic_version.py | 2 +- .../devtools/cloudbuild_v1/types/__init__.py | 2 + .../cloudbuild_v1/types/cloudbuild.py | 118 ++++++++++++++++++ .../devtools/cloudbuild_v2/gapic_version.py | 2 +- ...etadata_google.devtools.cloudbuild.v1.json | 2 +- ...etadata_google.devtools.cloudbuild.v2.json | 2 +- .../gapic/cloudbuild_v1/test_cloud_build.py | 37 ++++++ 10 files changed, 166 insertions(+), 5 deletions(-) diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild/__init__.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild/__init__.py index 8dc4cefb7d4c..ec010bed1b50 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild/__init__.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild/__init__.py @@ -85,6 +85,7 @@ UpdateBuildTriggerRequest, UpdateWorkerPoolOperationMetadata, UpdateWorkerPoolRequest, + UploadedGoModule, UploadedMavenArtifact, UploadedNpmPackage, UploadedPythonPackage, @@ -156,6 +157,7 @@ "UpdateBuildTriggerRequest", "UpdateWorkerPoolOperationMetadata", "UpdateWorkerPoolRequest", + "UploadedGoModule", "UploadedMavenArtifact", "UploadedNpmPackage", "UploadedPythonPackage", diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild/gapic_version.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild/gapic_version.py index 32cacc95a964..558c8aab67c5 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild/gapic_version.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.28.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/__init__.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/__init__.py index af6a17f24651..ba562f8613dd 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/__init__.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/__init__.py @@ -80,6 +80,7 @@ UpdateBuildTriggerRequest, UpdateWorkerPoolOperationMetadata, UpdateWorkerPoolRequest, + UploadedGoModule, UploadedMavenArtifact, UploadedNpmPackage, UploadedPythonPackage, @@ -151,6 +152,7 @@ "UpdateBuildTriggerRequest", "UpdateWorkerPoolOperationMetadata", "UpdateWorkerPoolRequest", + "UploadedGoModule", "UploadedMavenArtifact", "UploadedNpmPackage", "UploadedPythonPackage", diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/gapic_version.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/gapic_version.py index 32cacc95a964..558c8aab67c5 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/gapic_version.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.28.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/types/__init__.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/types/__init__.py index ae459a63007c..bbe931345c88 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/types/__init__.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/types/__init__.py @@ -74,6 +74,7 @@ UpdateBuildTriggerRequest, UpdateWorkerPoolOperationMetadata, UpdateWorkerPoolRequest, + UploadedGoModule, UploadedMavenArtifact, UploadedNpmPackage, UploadedPythonPackage, @@ -143,6 +144,7 @@ "UpdateBuildTriggerRequest", "UpdateWorkerPoolOperationMetadata", "UpdateWorkerPoolRequest", + "UploadedGoModule", "UploadedMavenArtifact", "UploadedNpmPackage", "UploadedPythonPackage", diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py index f2c8afd90148..b684f5c3dbf8 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py @@ -36,6 +36,7 @@ "BuiltImage", "UploadedPythonPackage", "UploadedMavenArtifact", + "UploadedGoModule", "UploadedNpmPackage", "BuildStep", "Volume", @@ -530,6 +531,37 @@ class UploadedMavenArtifact(proto.Message): ) +class UploadedGoModule(proto.Message): + r"""A Go module artifact uploaded to Artifact Registry using the + GoModule directive. + + Attributes: + uri (str): + URI of the uploaded artifact. + file_hashes (google.cloud.devtools.cloudbuild_v1.types.FileHashes): + Hash types and values of the Go Module + Artifact. + push_timing (google.cloud.devtools.cloudbuild_v1.types.TimeSpan): + Output only. Stores timing information for + pushing the specified artifact. + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + file_hashes: "FileHashes" = proto.Field( + proto.MESSAGE, + number=2, + message="FileHashes", + ) + push_timing: "TimeSpan" = proto.Field( + proto.MESSAGE, + number=3, + message="TimeSpan", + ) + + class UploadedNpmPackage(proto.Message): r"""An npm package uploaded to Artifact Registry using the NpmPackage directive. @@ -835,6 +867,9 @@ class Results(proto.Message): maven_artifacts (MutableSequence[google.cloud.devtools.cloudbuild_v1.types.UploadedMavenArtifact]): Maven artifacts uploaded to Artifact Registry at the end of the build. + go_modules (MutableSequence[google.cloud.devtools.cloudbuild_v1.types.UploadedGoModule]): + Optional. Go module artifacts uploaded to + Artifact Registry at the end of the build. npm_packages (MutableSequence[google.cloud.devtools.cloudbuild_v1.types.UploadedNpmPackage]): Npm packages uploaded to Artifact Registry at the end of the build. @@ -876,6 +911,11 @@ class Results(proto.Message): number=9, message="UploadedMavenArtifact", ) + go_modules: MutableSequence["UploadedGoModule"] = proto.RepeatedField( + proto.MESSAGE, + number=10, + message="UploadedGoModule", + ) npm_packages: MutableSequence["UploadedNpmPackage"] = proto.RepeatedField( proto.MESSAGE, number=12, @@ -1368,6 +1408,13 @@ class Artifacts(proto.Message): If any artifacts fail to be pushed, the build is marked FAILURE. + go_modules (MutableSequence[google.cloud.devtools.cloudbuild_v1.types.Artifacts.GoModule]): + Optional. A list of Go modules to be uploaded + to Artifact Registry upon successful completion + of all build steps. + + If any objects fail to be pushed, the build is + marked FAILURE. python_packages (MutableSequence[google.cloud.devtools.cloudbuild_v1.types.Artifacts.PythonPackage]): A list of Python packages to be uploaded to Artifact Registry upon successful completion of @@ -1478,6 +1525,68 @@ class MavenArtifact(proto.Message): number=5, ) + class GoModule(proto.Message): + r"""Go module to upload to Artifact Registry upon successful + completion of all build steps. A module refers to all + dependencies in a go.mod file. + + Attributes: + repository_name (str): + Optional. Artifact Registry repository name. + + Specified Go modules will be zipped and uploaded + to Artifact Registry with this location as a + prefix. + e.g. my-go-repo + repository_location (str): + Optional. Location of the Artifact Registry + repository. i.e. us-east1 Defaults to the + build’s location. + repository_project_id (str): + Optional. Project ID of the Artifact Registry + repository. Defaults to the build project. + source_path (str): + Optional. Source path of the go.mod file in + the build's workspace. If not specified, this + will default to the current directory. e.g. + ~/code/go/mypackage + module_path (str): + Optional. The Go module's "module path". + e.g. example.com/foo/v2 + module_version (str): + Optional. The Go module's semantic version in + the form vX.Y.Z. e.g. v0.1.1 Pre-release + identifiers can also be added by appending a + dash and dot separated ASCII alphanumeric + characters and hyphens. e.g. + v0.2.3-alpha.x.12m.5 + """ + + repository_name: str = proto.Field( + proto.STRING, + number=1, + ) + repository_location: str = proto.Field( + proto.STRING, + number=2, + ) + repository_project_id: str = proto.Field( + proto.STRING, + number=3, + ) + source_path: str = proto.Field( + proto.STRING, + number=4, + ) + module_path: str = proto.Field( + proto.STRING, + number=5, + ) + module_version: str = proto.Field( + proto.STRING, + number=6, + ) + class PythonPackage(proto.Message): r"""Python package to upload to Artifact Registry upon successful completion of all build steps. A package can encapsulate @@ -1546,6 +1655,11 @@ class NpmPackage(proto.Message): number=3, message=MavenArtifact, ) + go_modules: MutableSequence[GoModule] = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=GoModule, + ) python_packages: MutableSequence[PythonPackage] = proto.RepeatedField( proto.MESSAGE, number=5, @@ -1685,12 +1799,16 @@ class HashType(proto.Enum): Use a sha256 hash. MD5 (2): Use a md5 hash. + GO_MODULE_H1 (3): + Dirhash of a Go module's source code which is + then hex-encoded. SHA512 (4): Use a sha512 hash. """ NONE = 0 SHA256 = 1 MD5 = 2 + GO_MODULE_H1 = 3 SHA512 = 4 type_: HashType = proto.Field( diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/gapic_version.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/gapic_version.py index 32cacc95a964..558c8aab67c5 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/gapic_version.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.28.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v1.json b/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v1.json index 4bb604454cc6..48df7a914e6e 100644 --- a/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v1.json +++ b/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-build", - "version": "3.28.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v2.json b/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v2.json index 972c4df91f39..b384db6d11b0 100644 --- a/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v2.json +++ b/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-build", - "version": "3.28.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-build/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py b/packages/google-cloud-build/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py index 71c4b3109603..13ca7f02f7b7 100644 --- a/packages/google-cloud-build/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py +++ b/packages/google-cloud-build/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py @@ -12776,6 +12776,7 @@ def test_create_build_rest_call_success(request_type): "maven_artifacts": [ {"uri": "uri_value", "file_hashes": {}, "push_timing": {}} ], + "go_modules": [{"uri": "uri_value", "file_hashes": {}, "push_timing": {}}], "npm_packages": [ {"uri": "uri_value", "file_hashes": {}, "push_timing": {}} ], @@ -12802,6 +12803,16 @@ def test_create_build_rest_call_success(request_type): "version": "version_value", } ], + "go_modules": [ + { + "repository_name": "repository_name_value", + "repository_location": "repository_location_value", + "repository_project_id": "repository_project_id_value", + "source_path": "source_path_value", + "module_path": "module_path_value", + "module_version": "module_version_value", + } + ], "python_packages": [ { "repository": "repository_value", @@ -13786,6 +13797,9 @@ def test_create_build_trigger_rest_call_success(request_type): "maven_artifacts": [ {"uri": "uri_value", "file_hashes": {}, "push_timing": {}} ], + "go_modules": [ + {"uri": "uri_value", "file_hashes": {}, "push_timing": {}} + ], "npm_packages": [ {"uri": "uri_value", "file_hashes": {}, "push_timing": {}} ], @@ -13812,6 +13826,16 @@ def test_create_build_trigger_rest_call_success(request_type): "version": "version_value", } ], + "go_modules": [ + { + "repository_name": "repository_name_value", + "repository_location": "repository_location_value", + "repository_project_id": "repository_project_id_value", + "source_path": "source_path_value", + "module_path": "module_path_value", + "module_version": "module_version_value", + } + ], "python_packages": [ { "repository": "repository_value", @@ -14604,6 +14628,9 @@ def test_update_build_trigger_rest_call_success(request_type): "maven_artifacts": [ {"uri": "uri_value", "file_hashes": {}, "push_timing": {}} ], + "go_modules": [ + {"uri": "uri_value", "file_hashes": {}, "push_timing": {}} + ], "npm_packages": [ {"uri": "uri_value", "file_hashes": {}, "push_timing": {}} ], @@ -14630,6 +14657,16 @@ def test_update_build_trigger_rest_call_success(request_type): "version": "version_value", } ], + "go_modules": [ + { + "repository_name": "repository_name_value", + "repository_location": "repository_location_value", + "repository_project_id": "repository_project_id_value", + "source_path": "source_path_value", + "module_path": "module_path_value", + "module_version": "module_version_value", + } + ], "python_packages": [ { "repository": "repository_value",