From 34316c77cf9327fae02c17452ca3f79b8996088e Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Fri, 8 Nov 2024 11:32:42 +1000 Subject: [PATCH] add helper Empty message --- internal/machine/api/pb/common.pb.go | 143 +++++++++++++++++++-------- internal/machine/api/pb/common.proto | 6 ++ 2 files changed, 110 insertions(+), 39 deletions(-) diff --git a/internal/machine/api/pb/common.pb.go b/internal/machine/api/pb/common.pb.go index 6563e75e..506b0543 100644 --- a/internal/machine/api/pb/common.pb.go +++ b/internal/machine/api/pb/common.pb.go @@ -89,6 +89,54 @@ func (x *Metadata) GetStatus() *status.Status { return nil } +// A helper message for marshalling the metadata field and injecting it into the response by the gRPC proxy. +type Empty struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (x *Empty) Reset() { + *x = Empty{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_machine_api_pb_common_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Empty) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Empty) ProtoMessage() {} + +func (x *Empty) ProtoReflect() protoreflect.Message { + mi := &file_internal_machine_api_pb_common_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Empty.ProtoReflect.Descriptor instead. +func (*Empty) Descriptor() ([]byte, []int) { + return file_internal_machine_api_pb_common_proto_rawDescGZIP(), []int{1} +} + +func (x *Empty) GetMetadata() *Metadata { + if x != nil { + return x.Metadata + } + return nil +} + type IP struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -100,7 +148,7 @@ type IP struct { func (x *IP) Reset() { *x = IP{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_common_proto_msgTypes[1] + mi := &file_internal_machine_api_pb_common_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -113,7 +161,7 @@ func (x *IP) String() string { func (*IP) ProtoMessage() {} func (x *IP) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_common_proto_msgTypes[1] + mi := &file_internal_machine_api_pb_common_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -126,7 +174,7 @@ func (x *IP) ProtoReflect() protoreflect.Message { // Deprecated: Use IP.ProtoReflect.Descriptor instead. func (*IP) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_common_proto_rawDescGZIP(), []int{1} + return file_internal_machine_api_pb_common_proto_rawDescGZIP(), []int{2} } func (x *IP) GetIp() []byte { @@ -148,7 +196,7 @@ type IPPort struct { func (x *IPPort) Reset() { *x = IPPort{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_common_proto_msgTypes[2] + mi := &file_internal_machine_api_pb_common_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -161,7 +209,7 @@ func (x *IPPort) String() string { func (*IPPort) ProtoMessage() {} func (x *IPPort) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_common_proto_msgTypes[2] + mi := &file_internal_machine_api_pb_common_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -174,7 +222,7 @@ func (x *IPPort) ProtoReflect() protoreflect.Message { // Deprecated: Use IPPort.ProtoReflect.Descriptor instead. func (*IPPort) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_common_proto_rawDescGZIP(), []int{2} + return file_internal_machine_api_pb_common_proto_rawDescGZIP(), []int{3} } func (x *IPPort) GetIp() *IP { @@ -203,7 +251,7 @@ type IPPrefix struct { func (x *IPPrefix) Reset() { *x = IPPrefix{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_common_proto_msgTypes[3] + mi := &file_internal_machine_api_pb_common_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -216,7 +264,7 @@ func (x *IPPrefix) String() string { func (*IPPrefix) ProtoMessage() {} func (x *IPPrefix) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_common_proto_msgTypes[3] + mi := &file_internal_machine_api_pb_common_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -229,7 +277,7 @@ func (x *IPPrefix) ProtoReflect() protoreflect.Message { // Deprecated: Use IPPrefix.ProtoReflect.Descriptor instead. func (*IPPrefix) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_common_proto_rawDescGZIP(), []int{3} + return file_internal_machine_api_pb_common_proto_rawDescGZIP(), []int{4} } func (x *IPPrefix) GetIp() *IP { @@ -259,20 +307,23 @@ var file_internal_machine_api_pb_common_proto_rawDesc = []byte{ 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x14, 0x0a, 0x02, - 0x49, 0x50, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, - 0x69, 0x70, 0x22, 0x35, 0x0a, 0x06, 0x49, 0x50, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x17, 0x0a, 0x02, - 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, - 0x50, 0x52, 0x02, 0x69, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x37, 0x0a, 0x08, 0x49, 0x50, 0x50, - 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x07, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x50, 0x52, 0x02, 0x69, 0x70, 0x12, 0x12, - 0x0a, 0x04, 0x62, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x62, 0x69, - 0x74, 0x73, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x70, 0x73, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x6b, 0x69, 0x2f, 0x75, 0x6e, 0x63, 0x6c, - 0x6f, 0x75, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6d, 0x61, 0x63, - 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x32, 0x0a, 0x05, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x29, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x22, 0x14, 0x0a, 0x02, 0x49, 0x50, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x02, 0x69, 0x70, 0x22, 0x35, 0x0a, 0x06, 0x49, 0x50, 0x50, 0x6f, 0x72, 0x74, + 0x12, 0x17, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x49, 0x50, 0x52, 0x02, 0x69, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x37, 0x0a, + 0x08, 0x49, 0x50, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x70, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x50, 0x52, 0x02, + 0x69, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x04, 0x62, 0x69, 0x74, 0x73, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x73, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x6b, 0x69, 0x2f, + 0x75, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -287,23 +338,25 @@ func file_internal_machine_api_pb_common_proto_rawDescGZIP() []byte { return file_internal_machine_api_pb_common_proto_rawDescData } -var file_internal_machine_api_pb_common_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_internal_machine_api_pb_common_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_internal_machine_api_pb_common_proto_goTypes = []any{ (*Metadata)(nil), // 0: api.Metadata - (*IP)(nil), // 1: api.IP - (*IPPort)(nil), // 2: api.IPPort - (*IPPrefix)(nil), // 3: api.IPPrefix - (*status.Status)(nil), // 4: google.rpc.Status + (*Empty)(nil), // 1: api.Empty + (*IP)(nil), // 2: api.IP + (*IPPort)(nil), // 3: api.IPPort + (*IPPrefix)(nil), // 4: api.IPPrefix + (*status.Status)(nil), // 5: google.rpc.Status } var file_internal_machine_api_pb_common_proto_depIdxs = []int32{ - 4, // 0: api.Metadata.status:type_name -> google.rpc.Status - 1, // 1: api.IPPort.ip:type_name -> api.IP - 1, // 2: api.IPPrefix.ip:type_name -> api.IP - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 5, // 0: api.Metadata.status:type_name -> google.rpc.Status + 0, // 1: api.Empty.metadata:type_name -> api.Metadata + 2, // 2: api.IPPort.ip:type_name -> api.IP + 2, // 3: api.IPPrefix.ip:type_name -> api.IP + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_internal_machine_api_pb_common_proto_init() } @@ -325,7 +378,7 @@ func file_internal_machine_api_pb_common_proto_init() { } } file_internal_machine_api_pb_common_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*IP); i { + switch v := v.(*Empty); i { case 0: return &v.state case 1: @@ -337,7 +390,7 @@ func file_internal_machine_api_pb_common_proto_init() { } } file_internal_machine_api_pb_common_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*IPPort); i { + switch v := v.(*IP); i { case 0: return &v.state case 1: @@ -349,6 +402,18 @@ func file_internal_machine_api_pb_common_proto_init() { } } file_internal_machine_api_pb_common_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*IPPort); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_machine_api_pb_common_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*IPPrefix); i { case 0: return &v.state @@ -367,7 +432,7 @@ func file_internal_machine_api_pb_common_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_internal_machine_api_pb_common_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/machine/api/pb/common.proto b/internal/machine/api/pb/common.proto index 6ba34b4d..bd387f1c 100644 --- a/internal/machine/api/pb/common.proto +++ b/internal/machine/api/pb/common.proto @@ -18,6 +18,12 @@ message Metadata { google.rpc.Status status = 3; } +// A helper message for marshalling the metadata field and injecting it into the response by the gRPC proxy. +message Empty { + Metadata metadata = 1; +} + + message IP { bytes ip = 1; }