Skip to content

Commit e01944b

Browse files
committed
feat(generator): allow Any to Struct/Value migration and update compute protos
1 parent 363529b commit e01944b

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

generator/internal/discovery_type_vertex.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,13 @@ StatusOr<int> DiscoveryTypeVertex::GetFieldNumber(
547547
}
548548

549549
if (field_descriptor->name() == field_name && type_name != field_type) {
550+
// Allow migration of google.protobuf.Any to google.protobuf.Struct or
551+
// google.protobuf.Value.
552+
if (absl::StrContains(type_name, "google.protobuf.Any") &&
553+
(absl::StrContains(field_type, "google.protobuf.Struct") ||
554+
absl::StrContains(field_type, "google.protobuf.Value"))) {
555+
return field_descriptor->number();
556+
}
550557
// Existing field type has changed. This is a breaking change.
551558
return internal::InvalidArgumentError(absl::StrFormat(
552559
"Message: %s has field: %s whose type has changed "

protos/google/cloud/compute/v1/internal/common_019.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ syntax = "proto3";
2121

2222
package google.cloud.cpp.compute.v1;
2323

24-
import "google/protobuf/any.proto";
24+
import "google/protobuf/struct.proto";
2525

2626
message BulkInsertOperationStatus {
2727
// [Output Only] Count of VMs successfully created so far.
@@ -524,7 +524,7 @@ message Status {
524524

525525
// A list of messages that carry the error details. There is a common set of
526526
// message types for APIs to use.
527-
repeated google.protobuf.Any details = 2 [json_name = "details"];
527+
repeated google.protobuf.Struct details = 2 [json_name = "details"];
528528

529529
// A developer-facing error message, which should be in English. Any
530530
// user-facing error message should be localized and sent in the

0 commit comments

Comments
 (0)