From af217d09a4888878e170182ffc6abcb85b843bc9 Mon Sep 17 00:00:00 2001 From: "update-envoy[bot]" <135279899+update-envoy[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:55:36 +0000 Subject: [PATCH] Mirrored from envoyproxy/envoy @ 520d88e4cb4e8c5014531281a88dcc8076e18bfd Signed-off-by: update-envoy[bot] <135279899+update-envoy[bot]@users.noreply.github.com> --- envoy/COMMIT | 2 +- .../network/v3/network_inputs.pb.go | 256 +++++++++++++-- .../network/v3/network_inputs.pb.validate.go | 303 ++++++++++++++++++ .../network/v3/network_inputs_vtproto.pb.go | 149 +++++++++ .../input_matchers/metadata/v3/metadata.pb.go | 185 +++++++++++ .../metadata/v3/metadata.pb.validate.go | 178 ++++++++++ .../metadata/v3/metadata_vtproto.pb.go | 108 +++++++ 7 files changed, 1151 insertions(+), 30 deletions(-) create mode 100755 envoy/extensions/matching/input_matchers/metadata/v3/metadata.pb.go create mode 100755 envoy/extensions/matching/input_matchers/metadata/v3/metadata.pb.validate.go create mode 100755 envoy/extensions/matching/input_matchers/metadata/v3/metadata_vtproto.pb.go diff --git a/envoy/COMMIT b/envoy/COMMIT index 45c9778bfd..3798979b25 100644 --- a/envoy/COMMIT +++ b/envoy/COMMIT @@ -1 +1 @@ -b5bbfba79379eaf4824c3a96c4d9d19bd498a31a +520d88e4cb4e8c5014531281a88dcc8076e18bfd diff --git a/envoy/extensions/matching/common_inputs/network/v3/network_inputs.pb.go b/envoy/extensions/matching/common_inputs/network/v3/network_inputs.pb.go index 9fd0b4a561..cf9fd5ec85 100755 --- a/envoy/extensions/matching/common_inputs/network/v3/network_inputs.pb.go +++ b/envoy/extensions/matching/common_inputs/network/v3/network_inputs.pb.go @@ -473,6 +473,159 @@ func (x *FilterStateInput) GetKey() string { return "" } +// Input that matches dynamic metadata by key. +// DynamicMetadataInput provides a general interface using “filter“ and “path“ to retrieve value from +// :ref:`Metadata `. +// +// For example, for the following Metadata: +// +// .. code-block:: yaml +// +// filter_metadata: +// envoy.xxx: +// prop: +// foo: bar +// xyz: +// hello: envoy +// +// The following DynamicMetadataInput will retrieve a string value "bar" from the Metadata. +// +// .. code-block:: yaml +// +// filter: envoy.xxx +// path: +// - key: prop +// - key: foo +// +// [#extension: envoy.matching.inputs.dynamic_metadata] +type DynamicMetadataInput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The filter name to retrieve the Struct from the Metadata. + Filter string `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` + // The path to retrieve the Value from the Struct. + Path []*DynamicMetadataInput_PathSegment `protobuf:"bytes,2,rep,name=path,proto3" json:"path,omitempty"` +} + +func (x *DynamicMetadataInput) Reset() { + *x = DynamicMetadataInput{} + if protoimpl.UnsafeEnabled { + mi := &file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DynamicMetadataInput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DynamicMetadataInput) ProtoMessage() {} + +func (x *DynamicMetadataInput) ProtoReflect() protoreflect.Message { + mi := &file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_msgTypes[10] + 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 DynamicMetadataInput.ProtoReflect.Descriptor instead. +func (*DynamicMetadataInput) Descriptor() ([]byte, []int) { + return file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_rawDescGZIP(), []int{10} +} + +func (x *DynamicMetadataInput) GetFilter() string { + if x != nil { + return x.Filter + } + return "" +} + +func (x *DynamicMetadataInput) GetPath() []*DynamicMetadataInput_PathSegment { + if x != nil { + return x.Path + } + return nil +} + +// Specifies the segment in a path to retrieve value from Metadata. +// Note: Currently it's not supported to retrieve a value from a list in Metadata. This means that +// if the segment key refers to a list, it has to be the last segment in a path. +type DynamicMetadataInput_PathSegment struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Segment: + // + // *DynamicMetadataInput_PathSegment_Key + Segment isDynamicMetadataInput_PathSegment_Segment `protobuf_oneof:"segment"` +} + +func (x *DynamicMetadataInput_PathSegment) Reset() { + *x = DynamicMetadataInput_PathSegment{} + if protoimpl.UnsafeEnabled { + mi := &file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DynamicMetadataInput_PathSegment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DynamicMetadataInput_PathSegment) ProtoMessage() {} + +func (x *DynamicMetadataInput_PathSegment) ProtoReflect() protoreflect.Message { + mi := &file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_msgTypes[11] + 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 DynamicMetadataInput_PathSegment.ProtoReflect.Descriptor instead. +func (*DynamicMetadataInput_PathSegment) Descriptor() ([]byte, []int) { + return file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_rawDescGZIP(), []int{10, 0} +} + +func (m *DynamicMetadataInput_PathSegment) GetSegment() isDynamicMetadataInput_PathSegment_Segment { + if m != nil { + return m.Segment + } + return nil +} + +func (x *DynamicMetadataInput_PathSegment) GetKey() string { + if x, ok := x.GetSegment().(*DynamicMetadataInput_PathSegment_Key); ok { + return x.Key + } + return "" +} + +type isDynamicMetadataInput_PathSegment_Segment interface { + isDynamicMetadataInput_PathSegment_Segment() +} + +type DynamicMetadataInput_PathSegment_Key struct { + // If specified, use the key to retrieve the value in a Struct. + Key string `protobuf:"bytes,1,opt,name=key,proto3,oneof"` +} + +func (*DynamicMetadataInput_PathSegment_Key) isDynamicMetadataInput_PathSegment_Segment() {} + var File_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto protoreflect.FileDescriptor var file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_rawDesc = []byte{ @@ -502,20 +655,35 @@ var file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x22, 0x2d, 0x0a, 0x10, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x19, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, - 0x72, 0x02, 0x10, 0x01, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x42, 0xc5, 0x01, 0xba, 0x80, 0xc8, 0xd1, - 0x06, 0x02, 0x10, 0x02, 0x0a, 0x40, 0x69, 0x6f, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, + 0x72, 0x02, 0x10, 0x01, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0xe7, 0x01, 0x0a, 0x14, 0x44, 0x79, + 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x49, 0x6e, 0x70, + 0x75, 0x74, 0x12, 0x1f, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x06, 0x66, 0x69, 0x6c, + 0x74, 0x65, 0x72, 0x12, 0x72, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x54, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x2e, 0x6e, 0x65, 0x74, 0x77, - 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x33, 0x42, 0x12, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, - 0x6e, 0x70, 0x75, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x63, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, - 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x6e, - 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x63, - 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x2f, 0x6e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x76, 0x33, 0x3b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x76, - 0x33, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x33, 0x2e, 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x2e, 0x50, 0x61, 0x74, 0x68, + 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x92, 0x01, 0x02, 0x08, + 0x01, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x1a, 0x3a, 0x0a, 0x0b, 0x50, 0x61, 0x74, 0x68, 0x53, + 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x48, 0x00, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x42, 0x0e, 0x0a, 0x07, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x03, + 0xf8, 0x42, 0x01, 0x42, 0xc5, 0x01, 0xba, 0x80, 0xc8, 0xd1, 0x06, 0x02, 0x10, 0x02, 0x0a, 0x40, + 0x69, 0x6f, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x65, 0x6e, + 0x76, 0x6f, 0x79, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x6d, + 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x5f, 0x69, + 0x6e, 0x70, 0x75, 0x74, 0x73, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x33, + 0x42, 0x12, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x63, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, + 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x65, + 0x6e, 0x76, 0x6f, 0x79, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, + 0x6d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x5f, + 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x76, + 0x33, 0x3b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x76, 0x33, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -530,25 +698,28 @@ func file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_prot return file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_rawDescData } -var file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_goTypes = []interface{}{ - (*DestinationIPInput)(nil), // 0: envoy.extensions.matching.common_inputs.network.v3.DestinationIPInput - (*DestinationPortInput)(nil), // 1: envoy.extensions.matching.common_inputs.network.v3.DestinationPortInput - (*SourceIPInput)(nil), // 2: envoy.extensions.matching.common_inputs.network.v3.SourceIPInput - (*SourcePortInput)(nil), // 3: envoy.extensions.matching.common_inputs.network.v3.SourcePortInput - (*DirectSourceIPInput)(nil), // 4: envoy.extensions.matching.common_inputs.network.v3.DirectSourceIPInput - (*SourceTypeInput)(nil), // 5: envoy.extensions.matching.common_inputs.network.v3.SourceTypeInput - (*ServerNameInput)(nil), // 6: envoy.extensions.matching.common_inputs.network.v3.ServerNameInput - (*TransportProtocolInput)(nil), // 7: envoy.extensions.matching.common_inputs.network.v3.TransportProtocolInput - (*ApplicationProtocolInput)(nil), // 8: envoy.extensions.matching.common_inputs.network.v3.ApplicationProtocolInput - (*FilterStateInput)(nil), // 9: envoy.extensions.matching.common_inputs.network.v3.FilterStateInput + (*DestinationIPInput)(nil), // 0: envoy.extensions.matching.common_inputs.network.v3.DestinationIPInput + (*DestinationPortInput)(nil), // 1: envoy.extensions.matching.common_inputs.network.v3.DestinationPortInput + (*SourceIPInput)(nil), // 2: envoy.extensions.matching.common_inputs.network.v3.SourceIPInput + (*SourcePortInput)(nil), // 3: envoy.extensions.matching.common_inputs.network.v3.SourcePortInput + (*DirectSourceIPInput)(nil), // 4: envoy.extensions.matching.common_inputs.network.v3.DirectSourceIPInput + (*SourceTypeInput)(nil), // 5: envoy.extensions.matching.common_inputs.network.v3.SourceTypeInput + (*ServerNameInput)(nil), // 6: envoy.extensions.matching.common_inputs.network.v3.ServerNameInput + (*TransportProtocolInput)(nil), // 7: envoy.extensions.matching.common_inputs.network.v3.TransportProtocolInput + (*ApplicationProtocolInput)(nil), // 8: envoy.extensions.matching.common_inputs.network.v3.ApplicationProtocolInput + (*FilterStateInput)(nil), // 9: envoy.extensions.matching.common_inputs.network.v3.FilterStateInput + (*DynamicMetadataInput)(nil), // 10: envoy.extensions.matching.common_inputs.network.v3.DynamicMetadataInput + (*DynamicMetadataInput_PathSegment)(nil), // 11: envoy.extensions.matching.common_inputs.network.v3.DynamicMetadataInput.PathSegment } var file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 11, // 0: envoy.extensions.matching.common_inputs.network.v3.DynamicMetadataInput.path:type_name -> envoy.extensions.matching.common_inputs.network.v3.DynamicMetadataInput.PathSegment + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_init() } @@ -677,6 +848,33 @@ func file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_prot return nil } } + file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DynamicMetadataInput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DynamicMetadataInput_PathSegment); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_msgTypes[11].OneofWrappers = []interface{}{ + (*DynamicMetadataInput_PathSegment_Key)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -684,7 +882,7 @@ func file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_prot GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_envoy_extensions_matching_common_inputs_network_v3_network_inputs_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 12, NumExtensions: 0, NumServices: 0, }, diff --git a/envoy/extensions/matching/common_inputs/network/v3/network_inputs.pb.validate.go b/envoy/extensions/matching/common_inputs/network/v3/network_inputs.pb.validate.go index bc4bef0b87..13a541f0ef 100755 --- a/envoy/extensions/matching/common_inputs/network/v3/network_inputs.pb.validate.go +++ b/envoy/extensions/matching/common_inputs/network/v3/network_inputs.pb.validate.go @@ -1056,3 +1056,306 @@ var _ interface { Cause() error ErrorName() string } = FilterStateInputValidationError{} + +// Validate checks the field values on DynamicMetadataInput with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DynamicMetadataInput) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DynamicMetadataInput with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DynamicMetadataInputMultiError, or nil if none found. +func (m *DynamicMetadataInput) ValidateAll() error { + return m.validate(true) +} + +func (m *DynamicMetadataInput) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if utf8.RuneCountInString(m.GetFilter()) < 1 { + err := DynamicMetadataInputValidationError{ + field: "Filter", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(m.GetPath()) < 1 { + err := DynamicMetadataInputValidationError{ + field: "Path", + reason: "value must contain at least 1 item(s)", + } + if !all { + return err + } + errors = append(errors, err) + } + + for idx, item := range m.GetPath() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DynamicMetadataInputValidationError{ + field: fmt.Sprintf("Path[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DynamicMetadataInputValidationError{ + field: fmt.Sprintf("Path[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DynamicMetadataInputValidationError{ + field: fmt.Sprintf("Path[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return DynamicMetadataInputMultiError(errors) + } + + return nil +} + +// DynamicMetadataInputMultiError is an error wrapping multiple validation +// errors returned by DynamicMetadataInput.ValidateAll() if the designated +// constraints aren't met. +type DynamicMetadataInputMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DynamicMetadataInputMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DynamicMetadataInputMultiError) AllErrors() []error { return m } + +// DynamicMetadataInputValidationError is the validation error returned by +// DynamicMetadataInput.Validate if the designated constraints aren't met. +type DynamicMetadataInputValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DynamicMetadataInputValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DynamicMetadataInputValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DynamicMetadataInputValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DynamicMetadataInputValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DynamicMetadataInputValidationError) ErrorName() string { + return "DynamicMetadataInputValidationError" +} + +// Error satisfies the builtin error interface +func (e DynamicMetadataInputValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDynamicMetadataInput.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DynamicMetadataInputValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DynamicMetadataInputValidationError{} + +// Validate checks the field values on DynamicMetadataInput_PathSegment with +// the rules defined in the proto definition for this message. If any rules +// are violated, the first error encountered is returned, or nil if there are +// no violations. +func (m *DynamicMetadataInput_PathSegment) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DynamicMetadataInput_PathSegment with +// the rules defined in the proto definition for this message. If any rules +// are violated, the result is a list of violation errors wrapped in +// DynamicMetadataInput_PathSegmentMultiError, or nil if none found. +func (m *DynamicMetadataInput_PathSegment) ValidateAll() error { + return m.validate(true) +} + +func (m *DynamicMetadataInput_PathSegment) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + oneofSegmentPresent := false + switch v := m.Segment.(type) { + case *DynamicMetadataInput_PathSegment_Key: + if v == nil { + err := DynamicMetadataInput_PathSegmentValidationError{ + field: "Segment", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofSegmentPresent = true + + if utf8.RuneCountInString(m.GetKey()) < 1 { + err := DynamicMetadataInput_PathSegmentValidationError{ + field: "Key", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + default: + _ = v // ensures v is used + } + if !oneofSegmentPresent { + err := DynamicMetadataInput_PathSegmentValidationError{ + field: "Segment", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return DynamicMetadataInput_PathSegmentMultiError(errors) + } + + return nil +} + +// DynamicMetadataInput_PathSegmentMultiError is an error wrapping multiple +// validation errors returned by +// DynamicMetadataInput_PathSegment.ValidateAll() if the designated +// constraints aren't met. +type DynamicMetadataInput_PathSegmentMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DynamicMetadataInput_PathSegmentMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DynamicMetadataInput_PathSegmentMultiError) AllErrors() []error { return m } + +// DynamicMetadataInput_PathSegmentValidationError is the validation error +// returned by DynamicMetadataInput_PathSegment.Validate if the designated +// constraints aren't met. +type DynamicMetadataInput_PathSegmentValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DynamicMetadataInput_PathSegmentValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DynamicMetadataInput_PathSegmentValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DynamicMetadataInput_PathSegmentValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DynamicMetadataInput_PathSegmentValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DynamicMetadataInput_PathSegmentValidationError) ErrorName() string { + return "DynamicMetadataInput_PathSegmentValidationError" +} + +// Error satisfies the builtin error interface +func (e DynamicMetadataInput_PathSegmentValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDynamicMetadataInput_PathSegment.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DynamicMetadataInput_PathSegmentValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DynamicMetadataInput_PathSegmentValidationError{} diff --git a/envoy/extensions/matching/common_inputs/network/v3/network_inputs_vtproto.pb.go b/envoy/extensions/matching/common_inputs/network/v3/network_inputs_vtproto.pb.go index 4f2c8534a1..b2976b755b 100755 --- a/envoy/extensions/matching/common_inputs/network/v3/network_inputs_vtproto.pb.go +++ b/envoy/extensions/matching/common_inputs/network/v3/network_inputs_vtproto.pb.go @@ -355,6 +355,112 @@ func (m *FilterStateInput) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *DynamicMetadataInput_PathSegment) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DynamicMetadataInput_PathSegment) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *DynamicMetadataInput_PathSegment) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if msg, ok := m.Segment.(*DynamicMetadataInput_PathSegment_Key); ok { + size, err := msg.MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + } + return len(dAtA) - i, nil +} + +func (m *DynamicMetadataInput_PathSegment_Key) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *DynamicMetadataInput_PathSegment_Key) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + i := len(dAtA) + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} +func (m *DynamicMetadataInput) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DynamicMetadataInput) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *DynamicMetadataInput) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Path) > 0 { + for iNdEx := len(m.Path) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Path[iNdEx].MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Filter) > 0 { + i -= len(m.Filter) + copy(dAtA[i:], m.Filter) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Filter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *DestinationIPInput) SizeVT() (n int) { if m == nil { return 0 @@ -458,3 +564,46 @@ func (m *FilterStateInput) SizeVT() (n int) { n += len(m.unknownFields) return n } + +func (m *DynamicMetadataInput_PathSegment) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if vtmsg, ok := m.Segment.(interface{ SizeVT() int }); ok { + n += vtmsg.SizeVT() + } + n += len(m.unknownFields) + return n +} + +func (m *DynamicMetadataInput_PathSegment_Key) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + return n +} +func (m *DynamicMetadataInput) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Filter) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.Path) > 0 { + for _, e := range m.Path { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} diff --git a/envoy/extensions/matching/input_matchers/metadata/v3/metadata.pb.go b/envoy/extensions/matching/input_matchers/metadata/v3/metadata.pb.go new file mode 100755 index 0000000000..f2bd3804ce --- /dev/null +++ b/envoy/extensions/matching/input_matchers/metadata/v3/metadata.pb.go @@ -0,0 +1,185 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v5.26.1 +// source: envoy/extensions/matching/input_matchers/metadata/v3/metadata.proto + +package metadatav3 + +import ( + _ "github.com/cncf/xds/go/udpa/annotations" + v3 "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" + _ "github.com/envoyproxy/protoc-gen-validate/validate" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Metadata matcher for metadata from http matching input data. +type Metadata struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The Metadata is matched if the value retrieved by metadata matching input is matched to this value. + Value *v3.ValueMatcher `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + // If true, the match result will be inverted. + Invert bool `protobuf:"varint,4,opt,name=invert,proto3" json:"invert,omitempty"` +} + +func (x *Metadata) Reset() { + *x = Metadata{} + if protoimpl.UnsafeEnabled { + mi := &file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Metadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Metadata) ProtoMessage() {} + +func (x *Metadata) ProtoReflect() protoreflect.Message { + mi := &file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_msgTypes[0] + 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 Metadata.ProtoReflect.Descriptor instead. +func (*Metadata) Descriptor() ([]byte, []int) { + return file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDescGZIP(), []int{0} +} + +func (x *Metadata) GetValue() *v3.ValueMatcher { + if x != nil { + return x.Value + } + return nil +} + +func (x *Metadata) GetInvert() bool { + if x != nil { + return x.Invert + } + return false +} + +var File_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto protoreflect.FileDescriptor + +var file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDesc = []byte{ + 0x0a, 0x43, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x2f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x69, 0x6e, 0x70, 0x75, + 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x2f, 0x76, 0x33, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x34, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x65, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, + 0x2e, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x73, 0x2e, + 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x33, 0x1a, 0x21, 0x65, 0x6e, 0x76, + 0x6f, 0x79, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2f, + 0x76, 0x33, 0x2f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1d, + 0x75, 0x64, 0x70, 0x61, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x67, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x43, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x23, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x6d, + 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4d, + 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x6e, 0x76, 0x65, 0x72, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x42, + 0xc5, 0x01, 0xba, 0x80, 0xc8, 0xd1, 0x06, 0x02, 0x10, 0x02, 0x0a, 0x42, 0x69, 0x6f, 0x2e, 0x65, + 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, + 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, + 0x69, 0x6e, 0x67, 0x2e, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, + 0x72, 0x73, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x33, 0x42, 0x0d, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x66, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, + 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2f, 0x65, 0x78, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, + 0x67, 0x2f, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x73, + 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x76, 0x33, 0x3b, 0x6d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x76, 0x33, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDescOnce sync.Once + file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDescData = file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDesc +) + +func file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDescGZIP() []byte { + file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDescOnce.Do(func() { + file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDescData = protoimpl.X.CompressGZIP(file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDescData) + }) + return file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDescData +} + +var file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_goTypes = []interface{}{ + (*Metadata)(nil), // 0: envoy.extensions.matching.input_matchers.metadata.v3.Metadata + (*v3.ValueMatcher)(nil), // 1: envoy.type.matcher.v3.ValueMatcher +} +var file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_depIdxs = []int32{ + 1, // 0: envoy.extensions.matching.input_matchers.metadata.v3.Metadata.value:type_name -> envoy.type.matcher.v3.ValueMatcher + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_init() } +func file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_init() { + if File_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Metadata); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_goTypes, + DependencyIndexes: file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_depIdxs, + MessageInfos: file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_msgTypes, + }.Build() + File_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto = out.File + file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_rawDesc = nil + file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_goTypes = nil + file_envoy_extensions_matching_input_matchers_metadata_v3_metadata_proto_depIdxs = nil +} diff --git a/envoy/extensions/matching/input_matchers/metadata/v3/metadata.pb.validate.go b/envoy/extensions/matching/input_matchers/metadata/v3/metadata.pb.validate.go new file mode 100755 index 0000000000..7c2e0e7bd8 --- /dev/null +++ b/envoy/extensions/matching/input_matchers/metadata/v3/metadata.pb.validate.go @@ -0,0 +1,178 @@ +//go:build !disable_pgv +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: envoy/extensions/matching/input_matchers/metadata/v3/metadata.proto + +package metadatav3 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on Metadata with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Metadata) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Metadata with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in MetadataMultiError, or nil +// if none found. +func (m *Metadata) ValidateAll() error { + return m.validate(true) +} + +func (m *Metadata) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetValue() == nil { + err := MetadataValidationError{ + field: "Value", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetValue()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MetadataValidationError{ + field: "Value", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MetadataValidationError{ + field: "Value", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetValue()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MetadataValidationError{ + field: "Value", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Invert + + if len(errors) > 0 { + return MetadataMultiError(errors) + } + + return nil +} + +// MetadataMultiError is an error wrapping multiple validation errors returned +// by Metadata.ValidateAll() if the designated constraints aren't met. +type MetadataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m MetadataMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m MetadataMultiError) AllErrors() []error { return m } + +// MetadataValidationError is the validation error returned by +// Metadata.Validate if the designated constraints aren't met. +type MetadataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e MetadataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e MetadataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e MetadataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e MetadataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e MetadataValidationError) ErrorName() string { return "MetadataValidationError" } + +// Error satisfies the builtin error interface +func (e MetadataValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sMetadata.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = MetadataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = MetadataValidationError{} diff --git a/envoy/extensions/matching/input_matchers/metadata/v3/metadata_vtproto.pb.go b/envoy/extensions/matching/input_matchers/metadata/v3/metadata_vtproto.pb.go new file mode 100755 index 0000000000..64ad1ca30e --- /dev/null +++ b/envoy/extensions/matching/input_matchers/metadata/v3/metadata_vtproto.pb.go @@ -0,0 +1,108 @@ +//go:build vtprotobuf +// +build vtprotobuf + +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// source: envoy/extensions/matching/input_matchers/metadata/v3/metadata.proto + +package metadatav3 + +import ( + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *Metadata) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Metadata) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *Metadata) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Invert { + i-- + if m.Invert { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if m.Value != nil { + if vtmsg, ok := interface{}(m.Value).(interface { + MarshalToSizedBufferVTStrict([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Value) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Metadata) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != nil { + if size, ok := interface{}(m.Value).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Value) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Invert { + n += 2 + } + n += len(m.unknownFields) + return n +}