From 760b0905674fb2cfa4ac089bf8d6db5869fb6b6c Mon Sep 17 00:00:00 2001 From: Timothy Messier Date: Thu, 31 Mar 2022 08:56:53 -0400 Subject: [PATCH] feat(proto): Add new option for proto files to set domain This allows for associating all of the messages in a file with a domain. This will be used by the global subtype registry to group subtypes within a domain. When registering a subtype, it must be unique within a domain. This allows for cases where two domains have the same subtypes, such as two domains both having a "plugin" subtype. --- .../custom_options/v1/options.proto | 7 ++- sdk/pbs/controller/protooptions/options.pb.go | 47 ++++++++++++++----- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/internal/proto/controller/custom_options/v1/options.proto b/internal/proto/controller/custom_options/v1/options.proto index 0aad5f61d..90d3fa040 100644 --- a/internal/proto/controller/custom_options/v1/options.proto +++ b/internal/proto/controller/custom_options/v1/options.proto @@ -22,7 +22,12 @@ extend google.protobuf.FieldOptions { string subtype = 85555; } +extend google.protobuf.FileOptions { + // domain is used to associate the messages in a file with a domain package. + string domain = 85556; +} + message MaskMapping { string this = 1; string that = 2; -} \ No newline at end of file +} diff --git a/sdk/pbs/controller/protooptions/options.pb.go b/sdk/pbs/controller/protooptions/options.pb.go index dba44c336..f0e563f9d 100644 --- a/sdk/pbs/controller/protooptions/options.pb.go +++ b/sdk/pbs/controller/protooptions/options.pb.go @@ -101,6 +101,14 @@ var file_controller_custom_options_v1_options_proto_extTypes = []protoimpl.Exten Tag: "bytes,85555,opt,name=subtype", Filename: "controller/custom_options/v1/options.proto", }, + { + ExtendedType: (*descriptorpb.FileOptions)(nil), + ExtensionType: (*string)(nil), + Field: 85556, + Name: "controller.custom_options.v1.domain", + Tag: "bytes,85556,opt,name=domain", + Filename: "controller/custom_options/v1/options.proto", + }, } // Extension fields to descriptorpb.FieldOptions. @@ -125,6 +133,14 @@ var ( E_Subtype = &file_controller_custom_options_v1_options_proto_extTypes[2] ) +// Extension fields to descriptorpb.FileOptions. +var ( + // domain is used to associate the messages in a file with a domain package. + // + // optional string domain = 85556; + E_Domain = &file_controller_custom_options_v1_options_proto_extTypes[3] +) + var File_controller_custom_options_v1_options_proto protoreflect.FileDescriptor var file_controller_custom_options_v1_options_proto_rawDesc = []byte{ @@ -153,13 +169,16 @@ var file_controller_custom_options_v1_options_proto_rawDesc = []byte{ 0x69, 0x6f, 0x6e, 0x3a, 0x39, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb3, 0x9c, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x74, 0x79, 0x70, 0x65, 0x42, 0x4c, - 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, - 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, - 0x73, 0x64, 0x6b, 0x2f, 0x70, 0x62, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3b, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x36, + 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb4, 0x9c, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x73, 0x64, 0x6b, 0x2f, 0x70, 0x62, 0x73, 0x2f, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -178,16 +197,18 @@ var file_controller_custom_options_v1_options_proto_msgTypes = make([]protoimpl. var file_controller_custom_options_v1_options_proto_goTypes = []interface{}{ (*MaskMapping)(nil), // 0: controller.custom_options.v1.MaskMapping (*descriptorpb.FieldOptions)(nil), // 1: google.protobuf.FieldOptions + (*descriptorpb.FileOptions)(nil), // 2: google.protobuf.FileOptions } var file_controller_custom_options_v1_options_proto_depIdxs = []int32{ 1, // 0: controller.custom_options.v1.mask_mapping:extendee -> google.protobuf.FieldOptions 1, // 1: controller.custom_options.v1.generate_sdk_option:extendee -> google.protobuf.FieldOptions 1, // 2: controller.custom_options.v1.subtype:extendee -> google.protobuf.FieldOptions - 0, // 3: controller.custom_options.v1.mask_mapping:type_name -> controller.custom_options.v1.MaskMapping - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 3, // [3:4] is the sub-list for extension type_name - 0, // [0:3] is the sub-list for extension extendee + 2, // 3: controller.custom_options.v1.domain:extendee -> google.protobuf.FileOptions + 0, // 4: controller.custom_options.v1.mask_mapping:type_name -> controller.custom_options.v1.MaskMapping + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 4, // [4:5] is the sub-list for extension type_name + 0, // [0:4] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } @@ -217,7 +238,7 @@ func file_controller_custom_options_v1_options_proto_init() { RawDescriptor: file_controller_custom_options_v1_options_proto_rawDesc, NumEnums: 0, NumMessages: 1, - NumExtensions: 3, + NumExtensions: 4, NumServices: 0, }, GoTypes: file_controller_custom_options_v1_options_proto_goTypes,