Skip to content

Commit

Permalink
pandaproxy/sr: Add support for extention custom options
Browse files Browse the repository at this point in the history
(cherry picked from commit f8c11ae)
  • Loading branch information
IoannisRP committed Jan 21, 2025
1 parent 7662a0c commit 2757777
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/v/pandaproxy/schema_registry/protobuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,12 @@ struct protobuf_schema_definition::impl {
boost::combine(from.enum_type(), *to.mutable_enum_type())) {
copy_uninterpreted_options(enum_from, enum_to);
}

// nested extentions
for (auto&& [extension_from, extension_to] :
boost::combine(from.extension(), *to.mutable_extension())) {
copy_uninterpreted_options(extension_from, extension_to);
}
}

void copy_uninterpreted_options(
Expand Down Expand Up @@ -680,6 +686,11 @@ struct protobuf_schema_definition::impl {
copy_uninterpreted_options(enum_from, enum_to);
}

for (auto&& [extension_from, extension_to] :
boost::combine(from.extension(), *to.mutable_extension())) {
copy_uninterpreted_options(extension_from, extension_to);
}

for (auto&& [service_from, service_to] :
boost::combine(from.service(), *to.mutable_service())) {
copy_uninterpreted_options(service_from, service_to);
Expand Down
12 changes: 9 additions & 3 deletions src/v/pandaproxy/schema_registry/test/compatibility_protobuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ SEASTAR_THREAD_TEST_CASE(test_protobuf_normalize_custom_options) {
auto schema = R"(import "google/protobuf/descriptor.proto";
extend google.protobuf.FileOptions {
optional string my_file_option_b = 50008;
optional string my_file_option_b = 50008 [(my_field_option_b) = 5.5, (my_field_option_a) = 4.5];
optional string my_file_option_a = 50000;
repeated uint32 my_repeated_file_option = 60000;
}
Expand Down Expand Up @@ -721,7 +721,10 @@ enum MyEnum {
BAR = 2;
}
extend google.protobuf.FileOptions {
optional string my_file_option_b = 50008;
optional string my_file_option_b = 50008 [
(my_field_option_b) = 5.5,
(my_field_option_a) = 4.5
];
optional string my_file_option_a = 50000;
repeated uint32 my_repeated_file_option = 60000;
}
Expand Down Expand Up @@ -819,7 +822,10 @@ extend .google.protobuf.FieldOptions {
}
extend .google.protobuf.FileOptions {
optional string my_file_option_a = 50000;
optional string my_file_option_b = 50008;
optional string my_file_option_b = 50008 [
(my_field_option_a) = 4.5,
(my_field_option_b) = 5.5
];
optional string my_file_option_c = 50015;
repeated uint32 my_repeated_file_option = 60000;
}
Expand Down

0 comments on commit 2757777

Please sign in to comment.