From 3df698968cd422dd34ffdc6e94d71560e5270c17 Mon Sep 17 00:00:00 2001 From: "update-envoy[bot]" <135279899+update-envoy[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 14:57:49 +0000 Subject: [PATCH] Mirrored from envoyproxy/envoy @ 70ba63a2e676f8676ab65840066729667c0af9bb Signed-off-by: update-envoy[bot] <135279899+update-envoy[bot]@users.noreply.github.com> --- .../kafka_broker/v3/kafka_broker.pb.go | 264 +++++++++++++-- .../v3/kafka_broker.pb.validate.go | 317 ++++++++++++++++++ envoy/COMMIT | 2 +- .../kafka_broker/v2alpha1/kafka_broker.pb.go | 272 +++++++++++++-- .../v2alpha1/kafka_broker.pb.validate.go | 317 ++++++++++++++++++ 5 files changed, 1117 insertions(+), 55 deletions(-) diff --git a/contrib/envoy/extensions/filters/network/kafka_broker/v3/kafka_broker.pb.go b/contrib/envoy/extensions/filters/network/kafka_broker/v3/kafka_broker.pb.go index 0b435524fc..d052310e9b 100755 --- a/contrib/envoy/extensions/filters/network/kafka_broker/v3/kafka_broker.pb.go +++ b/contrib/envoy/extensions/filters/network/kafka_broker/v3/kafka_broker.pb.go @@ -33,6 +33,18 @@ type KafkaBroker struct { // upstream broker instead of passing received bytes as is. // Disabled by default. ForceResponseRewrite bool `protobuf:"varint,2,opt,name=force_response_rewrite,json=forceResponseRewrite,proto3" json:"force_response_rewrite,omitempty"` + // Optional broker address rewrite specification. + // Allows the broker filter to rewrite Kafka responses so that all connections established by + // the Kafka clients point to Envoy. + // This allows Kafka cluster not to configure its 'advertised.listeners' property + // (as the necessary re-pointing will be done by this filter). + // This collection of rules should cover all brokers in the cluster that is being proxied, + // otherwise some nodes' addresses might leak to the downstream clients. + // + // Types that are assignable to BrokerAddressRewriteSpec: + // + // *KafkaBroker_IdBasedBrokerAddressRewriteSpec + BrokerAddressRewriteSpec isKafkaBroker_BrokerAddressRewriteSpec `protobuf_oneof:"broker_address_rewrite_spec"` } func (x *KafkaBroker) Reset() { @@ -81,6 +93,150 @@ func (x *KafkaBroker) GetForceResponseRewrite() bool { return false } +func (m *KafkaBroker) GetBrokerAddressRewriteSpec() isKafkaBroker_BrokerAddressRewriteSpec { + if m != nil { + return m.BrokerAddressRewriteSpec + } + return nil +} + +func (x *KafkaBroker) GetIdBasedBrokerAddressRewriteSpec() *IdBasedBrokerRewriteSpec { + if x, ok := x.GetBrokerAddressRewriteSpec().(*KafkaBroker_IdBasedBrokerAddressRewriteSpec); ok { + return x.IdBasedBrokerAddressRewriteSpec + } + return nil +} + +type isKafkaBroker_BrokerAddressRewriteSpec interface { + isKafkaBroker_BrokerAddressRewriteSpec() +} + +type KafkaBroker_IdBasedBrokerAddressRewriteSpec struct { + // Broker address rewrite rules that match by broker ID. + IdBasedBrokerAddressRewriteSpec *IdBasedBrokerRewriteSpec `protobuf:"bytes,3,opt,name=id_based_broker_address_rewrite_spec,json=idBasedBrokerAddressRewriteSpec,proto3,oneof"` +} + +func (*KafkaBroker_IdBasedBrokerAddressRewriteSpec) isKafkaBroker_BrokerAddressRewriteSpec() {} + +// Collection of rules matching by broker ID. +type IdBasedBrokerRewriteSpec struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rules []*IdBasedBrokerRewriteRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` +} + +func (x *IdBasedBrokerRewriteSpec) Reset() { + *x = IdBasedBrokerRewriteSpec{} + if protoimpl.UnsafeEnabled { + mi := &file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IdBasedBrokerRewriteSpec) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IdBasedBrokerRewriteSpec) ProtoMessage() {} + +func (x *IdBasedBrokerRewriteSpec) ProtoReflect() protoreflect.Message { + mi := &file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_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 IdBasedBrokerRewriteSpec.ProtoReflect.Descriptor instead. +func (*IdBasedBrokerRewriteSpec) Descriptor() ([]byte, []int) { + return file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_rawDescGZIP(), []int{1} +} + +func (x *IdBasedBrokerRewriteSpec) GetRules() []*IdBasedBrokerRewriteRule { + if x != nil { + return x.Rules + } + return nil +} + +// Defines a rule to rewrite broker address data. +type IdBasedBrokerRewriteRule struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Broker ID to match. + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The host value to use (resembling the host part of Kafka's advertised.listeners). + // The value should point to the Envoy (not Kafka) listener, so that all client traffic goes + // through Envoy. + Host string `protobuf:"bytes,2,opt,name=host,proto3" json:"host,omitempty"` + // The port value to use (resembling the port part of Kafka's advertised.listeners). + // The value should point to the Envoy (not Kafka) listener, so that all client traffic goes + // through Envoy. + Port uint32 `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"` +} + +func (x *IdBasedBrokerRewriteRule) Reset() { + *x = IdBasedBrokerRewriteRule{} + if protoimpl.UnsafeEnabled { + mi := &file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IdBasedBrokerRewriteRule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IdBasedBrokerRewriteRule) ProtoMessage() {} + +func (x *IdBasedBrokerRewriteRule) ProtoReflect() protoreflect.Message { + mi := &file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_msgTypes[2] + 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 IdBasedBrokerRewriteRule.ProtoReflect.Descriptor instead. +func (*IdBasedBrokerRewriteRule) Descriptor() ([]byte, []int) { + return file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_rawDescGZIP(), []int{2} +} + +func (x *IdBasedBrokerRewriteRule) GetId() uint32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *IdBasedBrokerRewriteRule) GetHost() string { + if x != nil { + return x.Host + } + return "" +} + +func (x *IdBasedBrokerRewriteRule) GetPort() uint32 { + if x != nil { + return x.Port + } + return 0 +} + var File_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto protoreflect.FileDescriptor var file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_rawDesc = []byte{ @@ -97,31 +253,58 @@ var file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_p 0x75, 0x64, 0x70, 0x61, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 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, 0xb3, 0x01, 0x0a, 0x0b, 0x4b, + 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf0, 0x02, 0x0a, 0x0b, 0x4b, 0x61, 0x66, 0x6b, 0x61, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x34, 0x0a, 0x16, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x72, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x52, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x3a, 0x44, 0x9a, 0xc5, 0x88, 0x1e, - 0x3f, 0x0a, 0x3d, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6b, - 0x61, 0x66, 0x6b, 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4b, 0x61, 0x66, 0x6b, 0x61, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, - 0x42, 0xc4, 0x01, 0xba, 0x80, 0xc8, 0xd1, 0x06, 0x02, 0x10, 0x02, 0x0a, 0x3e, 0x69, 0x6f, 0x2e, - 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, + 0x6e, 0x73, 0x65, 0x52, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x12, 0x9b, 0x01, 0x0a, 0x24, 0x69, + 0x64, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x64, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x5f, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x72, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x73, + 0x70, 0x65, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x4a, 0x2e, 0x65, 0x6e, 0x76, 0x6f, + 0x79, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x69, 0x6c, + 0x74, 0x65, 0x72, 0x73, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6b, 0x61, 0x66, + 0x6b, 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x64, 0x42, + 0x61, 0x73, 0x65, 0x64, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x52, 0x65, 0x77, 0x72, 0x69, 0x74, + 0x65, 0x53, 0x70, 0x65, 0x63, 0x48, 0x00, 0x52, 0x1f, 0x69, 0x64, 0x42, 0x61, 0x73, 0x65, 0x64, + 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x77, + 0x72, 0x69, 0x74, 0x65, 0x53, 0x70, 0x65, 0x63, 0x3a, 0x44, 0x9a, 0xc5, 0x88, 0x1e, 0x3f, 0x0a, + 0x3d, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x66, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6b, 0x61, 0x66, + 0x6b, 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x4b, 0x61, 0x66, 0x6b, 0x61, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x42, 0x1d, + 0x0a, 0x1b, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x5f, 0x72, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x22, 0x7c, 0x0a, + 0x18, 0x49, 0x64, 0x42, 0x61, 0x73, 0x65, 0x64, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x52, 0x65, + 0x77, 0x72, 0x69, 0x74, 0x65, 0x53, 0x70, 0x65, 0x63, 0x12, 0x60, 0x0a, 0x05, 0x72, 0x75, 0x6c, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4a, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6b, 0x61, 0x66, 0x6b, - 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x42, 0x10, 0x4b, 0x61, 0x66, - 0x6b, 0x61, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 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, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, - 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x6b, 0x61, 0x66, 0x6b, 0x61, 0x5f, 0x62, - 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2f, 0x76, 0x33, 0x3b, 0x6b, 0x61, 0x66, 0x6b, 0x61, 0x5f, 0x62, - 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x76, 0x33, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x64, 0x42, 0x61, + 0x73, 0x65, 0x64, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x52, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, + 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x6f, 0x0a, 0x18, 0x49, + 0x64, 0x42, 0x61, 0x73, 0x65, 0x64, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x52, 0x65, 0x77, 0x72, + 0x69, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0d, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x2a, 0x02, 0x28, 0x00, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x1b, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, + 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x1d, 0x0a, + 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x09, 0xfa, 0x42, 0x06, + 0x2a, 0x04, 0x18, 0xff, 0xff, 0x03, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x42, 0xc4, 0x01, 0xba, + 0x80, 0xc8, 0xd1, 0x06, 0x02, 0x10, 0x02, 0x0a, 0x3e, 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, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x2e, + 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6b, 0x61, 0x66, 0x6b, 0x61, 0x5f, 0x62, 0x72, + 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x42, 0x10, 0x4b, 0x61, 0x66, 0x6b, 0x61, 0x42, 0x72, + 0x6f, 0x6b, 0x65, 0x72, 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, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x2f, 0x6e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x6b, 0x61, 0x66, 0x6b, 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, + 0x72, 0x2f, 0x76, 0x33, 0x3b, 0x6b, 0x61, 0x66, 0x6b, 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, + 0x72, 0x76, 0x33, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -136,16 +319,20 @@ func file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_ return file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_rawDescData } -var file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_goTypes = []interface{}{ - (*KafkaBroker)(nil), // 0: envoy.extensions.filters.network.kafka_broker.v3.KafkaBroker + (*KafkaBroker)(nil), // 0: envoy.extensions.filters.network.kafka_broker.v3.KafkaBroker + (*IdBasedBrokerRewriteSpec)(nil), // 1: envoy.extensions.filters.network.kafka_broker.v3.IdBasedBrokerRewriteSpec + (*IdBasedBrokerRewriteRule)(nil), // 2: envoy.extensions.filters.network.kafka_broker.v3.IdBasedBrokerRewriteRule } var file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_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 + 1, // 0: envoy.extensions.filters.network.kafka_broker.v3.KafkaBroker.id_based_broker_address_rewrite_spec:type_name -> envoy.extensions.filters.network.kafka_broker.v3.IdBasedBrokerRewriteSpec + 2, // 1: envoy.extensions.filters.network.kafka_broker.v3.IdBasedBrokerRewriteSpec.rules:type_name -> envoy.extensions.filters.network.kafka_broker.v3.IdBasedBrokerRewriteRule + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_init() } @@ -166,6 +353,33 @@ func file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_ return nil } } + file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IdBasedBrokerRewriteSpec); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IdBasedBrokerRewriteRule); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*KafkaBroker_IdBasedBrokerAddressRewriteSpec)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -173,7 +387,7 @@ func file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_contrib_envoy_extensions_filters_network_kafka_broker_v3_kafka_broker_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/contrib/envoy/extensions/filters/network/kafka_broker/v3/kafka_broker.pb.validate.go b/contrib/envoy/extensions/filters/network/kafka_broker/v3/kafka_broker.pb.validate.go index 61c06eb7a5..222007f82f 100755 --- a/contrib/envoy/extensions/filters/network/kafka_broker/v3/kafka_broker.pb.validate.go +++ b/contrib/envoy/extensions/filters/network/kafka_broker/v3/kafka_broker.pb.validate.go @@ -70,6 +70,52 @@ func (m *KafkaBroker) validate(all bool) error { // no validation rules for ForceResponseRewrite + switch v := m.BrokerAddressRewriteSpec.(type) { + case *KafkaBroker_IdBasedBrokerAddressRewriteSpec: + if v == nil { + err := KafkaBrokerValidationError{ + field: "BrokerAddressRewriteSpec", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetIdBasedBrokerAddressRewriteSpec()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, KafkaBrokerValidationError{ + field: "IdBasedBrokerAddressRewriteSpec", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, KafkaBrokerValidationError{ + field: "IdBasedBrokerAddressRewriteSpec", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetIdBasedBrokerAddressRewriteSpec()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return KafkaBrokerValidationError{ + field: "IdBasedBrokerAddressRewriteSpec", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + if len(errors) > 0 { return KafkaBrokerMultiError(errors) } @@ -146,3 +192,274 @@ var _ interface { Cause() error ErrorName() string } = KafkaBrokerValidationError{} + +// Validate checks the field values on IdBasedBrokerRewriteSpec 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 *IdBasedBrokerRewriteSpec) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on IdBasedBrokerRewriteSpec 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 +// IdBasedBrokerRewriteSpecMultiError, or nil if none found. +func (m *IdBasedBrokerRewriteSpec) ValidateAll() error { + return m.validate(true) +} + +func (m *IdBasedBrokerRewriteSpec) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRules() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, IdBasedBrokerRewriteSpecValidationError{ + field: fmt.Sprintf("Rules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, IdBasedBrokerRewriteSpecValidationError{ + field: fmt.Sprintf("Rules[%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 IdBasedBrokerRewriteSpecValidationError{ + field: fmt.Sprintf("Rules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return IdBasedBrokerRewriteSpecMultiError(errors) + } + + return nil +} + +// IdBasedBrokerRewriteSpecMultiError is an error wrapping multiple validation +// errors returned by IdBasedBrokerRewriteSpec.ValidateAll() if the designated +// constraints aren't met. +type IdBasedBrokerRewriteSpecMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m IdBasedBrokerRewriteSpecMultiError) 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 IdBasedBrokerRewriteSpecMultiError) AllErrors() []error { return m } + +// IdBasedBrokerRewriteSpecValidationError is the validation error returned by +// IdBasedBrokerRewriteSpec.Validate if the designated constraints aren't met. +type IdBasedBrokerRewriteSpecValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e IdBasedBrokerRewriteSpecValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e IdBasedBrokerRewriteSpecValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e IdBasedBrokerRewriteSpecValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e IdBasedBrokerRewriteSpecValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e IdBasedBrokerRewriteSpecValidationError) ErrorName() string { + return "IdBasedBrokerRewriteSpecValidationError" +} + +// Error satisfies the builtin error interface +func (e IdBasedBrokerRewriteSpecValidationError) 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 %sIdBasedBrokerRewriteSpec.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = IdBasedBrokerRewriteSpecValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = IdBasedBrokerRewriteSpecValidationError{} + +// Validate checks the field values on IdBasedBrokerRewriteRule 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 *IdBasedBrokerRewriteRule) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on IdBasedBrokerRewriteRule 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 +// IdBasedBrokerRewriteRuleMultiError, or nil if none found. +func (m *IdBasedBrokerRewriteRule) ValidateAll() error { + return m.validate(true) +} + +func (m *IdBasedBrokerRewriteRule) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetId() < 0 { + err := IdBasedBrokerRewriteRuleValidationError{ + field: "Id", + reason: "value must be greater than or equal to 0", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetHost()) < 1 { + err := IdBasedBrokerRewriteRuleValidationError{ + field: "Host", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if m.GetPort() > 65535 { + err := IdBasedBrokerRewriteRuleValidationError{ + field: "Port", + reason: "value must be less than or equal to 65535", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return IdBasedBrokerRewriteRuleMultiError(errors) + } + + return nil +} + +// IdBasedBrokerRewriteRuleMultiError is an error wrapping multiple validation +// errors returned by IdBasedBrokerRewriteRule.ValidateAll() if the designated +// constraints aren't met. +type IdBasedBrokerRewriteRuleMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m IdBasedBrokerRewriteRuleMultiError) 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 IdBasedBrokerRewriteRuleMultiError) AllErrors() []error { return m } + +// IdBasedBrokerRewriteRuleValidationError is the validation error returned by +// IdBasedBrokerRewriteRule.Validate if the designated constraints aren't met. +type IdBasedBrokerRewriteRuleValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e IdBasedBrokerRewriteRuleValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e IdBasedBrokerRewriteRuleValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e IdBasedBrokerRewriteRuleValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e IdBasedBrokerRewriteRuleValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e IdBasedBrokerRewriteRuleValidationError) ErrorName() string { + return "IdBasedBrokerRewriteRuleValidationError" +} + +// Error satisfies the builtin error interface +func (e IdBasedBrokerRewriteRuleValidationError) 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 %sIdBasedBrokerRewriteRule.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = IdBasedBrokerRewriteRuleValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = IdBasedBrokerRewriteRuleValidationError{} diff --git a/envoy/COMMIT b/envoy/COMMIT index 34cf2c67c9..4eff9908d7 100644 --- a/envoy/COMMIT +++ b/envoy/COMMIT @@ -1 +1 @@ -a33cde6cea0cf4bfb700a9002175e74553dc52a4 +70ba63a2e676f8676ab65840066729667c0af9bb diff --git a/envoy/config/filter/network/kafka_broker/v2alpha1/kafka_broker.pb.go b/envoy/config/filter/network/kafka_broker/v2alpha1/kafka_broker.pb.go index 272c3ef540..340f33010a 100755 --- a/envoy/config/filter/network/kafka_broker/v2alpha1/kafka_broker.pb.go +++ b/envoy/config/filter/network/kafka_broker/v2alpha1/kafka_broker.pb.go @@ -33,6 +33,18 @@ type KafkaBroker struct { // upstream broker instead of passing received bytes as is. // Disabled by default. ForceResponseRewrite bool `protobuf:"varint,2,opt,name=force_response_rewrite,json=forceResponseRewrite,proto3" json:"force_response_rewrite,omitempty"` + // Optional broker address rewrite specification. + // Allows the broker filter to rewrite Kafka responses so that all connections established by + // the Kafka clients point to Envoy. + // This allows Kafka cluster not to configure its 'advertised.listeners' property + // (as the necessary re-pointing will be done by this filter). + // This collection of rules should cover all brokers in the cluster that is being proxied, + // otherwise some nodes' addresses might leak to the downstream clients. + // + // Types that are assignable to BrokerAddressRewriteSpec: + // + // *KafkaBroker_IdBasedBrokerAddressRewriteSpec + BrokerAddressRewriteSpec isKafkaBroker_BrokerAddressRewriteSpec `protobuf_oneof:"broker_address_rewrite_spec"` } func (x *KafkaBroker) Reset() { @@ -81,6 +93,150 @@ func (x *KafkaBroker) GetForceResponseRewrite() bool { return false } +func (m *KafkaBroker) GetBrokerAddressRewriteSpec() isKafkaBroker_BrokerAddressRewriteSpec { + if m != nil { + return m.BrokerAddressRewriteSpec + } + return nil +} + +func (x *KafkaBroker) GetIdBasedBrokerAddressRewriteSpec() *IdBasedBrokerRewriteSpec { + if x, ok := x.GetBrokerAddressRewriteSpec().(*KafkaBroker_IdBasedBrokerAddressRewriteSpec); ok { + return x.IdBasedBrokerAddressRewriteSpec + } + return nil +} + +type isKafkaBroker_BrokerAddressRewriteSpec interface { + isKafkaBroker_BrokerAddressRewriteSpec() +} + +type KafkaBroker_IdBasedBrokerAddressRewriteSpec struct { + // Broker address rewrite rules that match by broker ID. + IdBasedBrokerAddressRewriteSpec *IdBasedBrokerRewriteSpec `protobuf:"bytes,3,opt,name=id_based_broker_address_rewrite_spec,json=idBasedBrokerAddressRewriteSpec,proto3,oneof"` +} + +func (*KafkaBroker_IdBasedBrokerAddressRewriteSpec) isKafkaBroker_BrokerAddressRewriteSpec() {} + +// Collection of rules matching by broker ID. +type IdBasedBrokerRewriteSpec struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rules []*IdBasedBrokerRewriteRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` +} + +func (x *IdBasedBrokerRewriteSpec) Reset() { + *x = IdBasedBrokerRewriteSpec{} + if protoimpl.UnsafeEnabled { + mi := &file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IdBasedBrokerRewriteSpec) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IdBasedBrokerRewriteSpec) ProtoMessage() {} + +func (x *IdBasedBrokerRewriteSpec) ProtoReflect() protoreflect.Message { + mi := &file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_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 IdBasedBrokerRewriteSpec.ProtoReflect.Descriptor instead. +func (*IdBasedBrokerRewriteSpec) Descriptor() ([]byte, []int) { + return file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_rawDescGZIP(), []int{1} +} + +func (x *IdBasedBrokerRewriteSpec) GetRules() []*IdBasedBrokerRewriteRule { + if x != nil { + return x.Rules + } + return nil +} + +// Defines a rule to rewrite broker address data. +type IdBasedBrokerRewriteRule struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Broker ID to match. + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The host value to use (resembling the host part of Kafka's advertised.listeners). + // The value should point to the Envoy (not Kafka) listener, so that all client traffic goes + // through Envoy. + Host string `protobuf:"bytes,2,opt,name=host,proto3" json:"host,omitempty"` + // The port value to use (resembling the port part of Kafka's advertised.listeners). + // The value should point to the Envoy (not Kafka) listener, so that all client traffic goes + // through Envoy. + Port uint32 `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"` +} + +func (x *IdBasedBrokerRewriteRule) Reset() { + *x = IdBasedBrokerRewriteRule{} + if protoimpl.UnsafeEnabled { + mi := &file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IdBasedBrokerRewriteRule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IdBasedBrokerRewriteRule) ProtoMessage() {} + +func (x *IdBasedBrokerRewriteRule) ProtoReflect() protoreflect.Message { + mi := &file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_msgTypes[2] + 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 IdBasedBrokerRewriteRule.ProtoReflect.Descriptor instead. +func (*IdBasedBrokerRewriteRule) Descriptor() ([]byte, []int) { + return file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_rawDescGZIP(), []int{2} +} + +func (x *IdBasedBrokerRewriteRule) GetId() uint32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *IdBasedBrokerRewriteRule) GetHost() string { + if x != nil { + return x.Host + } + return "" +} + +func (x *IdBasedBrokerRewriteRule) GetPort() uint32 { + if x != nil { + return x.Port + } + return 0 +} + var File_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto protoreflect.FileDescriptor var file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_rawDesc = []byte{ @@ -97,29 +253,56 @@ var file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_ra 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, 0x6d, 0x0a, 0x0b, 0x4b, 0x61, 0x66, 0x6b, 0x61, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, - 0x12, 0x28, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x20, 0x01, 0x52, 0x0a, - 0x73, 0x74, 0x61, 0x74, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x34, 0x0a, 0x16, 0x66, 0x6f, - 0x72, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x72, 0x65, 0x77, - 0x72, 0x69, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x66, 0x6f, 0x72, 0x63, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, - 0x42, 0xef, 0x01, 0xf2, 0x98, 0xfe, 0x8f, 0x05, 0x32, 0x12, 0x30, 0x65, 0x6e, 0x76, 0x6f, 0x79, - 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x69, 0x6c, 0x74, - 0x65, 0x72, 0x73, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6b, 0x61, 0x66, 0x6b, - 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x76, 0x33, 0xba, 0x80, 0xc8, 0xd1, 0x06, - 0x02, 0x10, 0x01, 0x0a, 0x3f, 0x69, 0x6f, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x6f, 0x22, 0xab, 0x02, 0x0a, 0x0b, 0x4b, 0x61, 0x66, 0x6b, 0x61, 0x42, 0x72, 0x6f, 0x6b, 0x65, + 0x72, 0x12, 0x28, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x20, 0x01, 0x52, + 0x0a, 0x73, 0x74, 0x61, 0x74, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x34, 0x0a, 0x16, 0x66, + 0x6f, 0x72, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x72, 0x65, + 0x77, 0x72, 0x69, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x66, 0x6f, 0x72, + 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x65, 0x77, 0x72, 0x69, 0x74, + 0x65, 0x12, 0x9c, 0x01, 0x0a, 0x24, 0x69, 0x64, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x64, 0x5f, 0x62, + 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x72, 0x65, + 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x4b, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6b, 0x61, 0x66, 0x6b, 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x42, 0x10, 0x4b, 0x61, 0x66, 0x6b, 0x61, 0x42, 0x72, 0x6f, 0x6b, 0x65, - 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x58, 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, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x66, 0x69, - 0x6c, 0x74, 0x65, 0x72, 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x6b, 0x61, 0x66, - 0x6b, 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x49, 0x64, 0x42, 0x61, 0x73, 0x65, 0x64, 0x42, 0x72, 0x6f, 0x6b, + 0x65, 0x72, 0x52, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x53, 0x70, 0x65, 0x63, 0x48, 0x00, 0x52, + 0x1f, 0x69, 0x64, 0x42, 0x61, 0x73, 0x65, 0x64, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x53, 0x70, 0x65, 0x63, + 0x42, 0x1d, 0x0a, 0x1b, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x5f, 0x72, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x22, + 0x7d, 0x0a, 0x18, 0x49, 0x64, 0x42, 0x61, 0x73, 0x65, 0x64, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, + 0x52, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x53, 0x70, 0x65, 0x63, 0x12, 0x61, 0x0a, 0x05, 0x72, + 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4b, 0x2e, 0x65, 0x6e, 0x76, + 0x6f, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, + 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6b, 0x61, 0x66, 0x6b, 0x61, 0x5f, 0x62, + 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x49, + 0x64, 0x42, 0x61, 0x73, 0x65, 0x64, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x52, 0x65, 0x77, 0x72, + 0x69, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x6f, + 0x0a, 0x18, 0x49, 0x64, 0x42, 0x61, 0x73, 0x65, 0x64, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x52, + 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x2a, 0x02, 0x28, 0x00, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, + 0x12, 0x1d, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x09, + 0xfa, 0x42, 0x06, 0x2a, 0x04, 0x18, 0xff, 0xff, 0x03, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x42, + 0xef, 0x01, 0xf2, 0x98, 0xfe, 0x8f, 0x05, 0x32, 0x12, 0x30, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, + 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x69, 0x6c, 0x74, 0x65, + 0x72, 0x73, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6b, 0x61, 0x66, 0x6b, 0x61, + 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x76, 0x33, 0xba, 0x80, 0xc8, 0xd1, 0x06, 0x02, + 0x10, 0x01, 0x0a, 0x3f, 0x69, 0x6f, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x66, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6b, 0x61, + 0x66, 0x6b, 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x42, 0x10, 0x4b, 0x61, 0x66, 0x6b, 0x61, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x58, 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, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x66, 0x69, 0x6c, + 0x74, 0x65, 0x72, 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x6b, 0x61, 0x66, 0x6b, + 0x61, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -134,16 +317,20 @@ func file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_r return file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_rawDescData } -var file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_goTypes = []interface{}{ - (*KafkaBroker)(nil), // 0: envoy.config.filter.network.kafka_broker.v2alpha1.KafkaBroker + (*KafkaBroker)(nil), // 0: envoy.config.filter.network.kafka_broker.v2alpha1.KafkaBroker + (*IdBasedBrokerRewriteSpec)(nil), // 1: envoy.config.filter.network.kafka_broker.v2alpha1.IdBasedBrokerRewriteSpec + (*IdBasedBrokerRewriteRule)(nil), // 2: envoy.config.filter.network.kafka_broker.v2alpha1.IdBasedBrokerRewriteRule } var file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_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 + 1, // 0: envoy.config.filter.network.kafka_broker.v2alpha1.KafkaBroker.id_based_broker_address_rewrite_spec:type_name -> envoy.config.filter.network.kafka_broker.v2alpha1.IdBasedBrokerRewriteSpec + 2, // 1: envoy.config.filter.network.kafka_broker.v2alpha1.IdBasedBrokerRewriteSpec.rules:type_name -> envoy.config.filter.network.kafka_broker.v2alpha1.IdBasedBrokerRewriteRule + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_init() } @@ -164,6 +351,33 @@ func file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_i return nil } } + file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IdBasedBrokerRewriteSpec); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IdBasedBrokerRewriteRule); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*KafkaBroker_IdBasedBrokerAddressRewriteSpec)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -171,7 +385,7 @@ func file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_i GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_envoy_config_filter_network_kafka_broker_v2alpha1_kafka_broker_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/envoy/config/filter/network/kafka_broker/v2alpha1/kafka_broker.pb.validate.go b/envoy/config/filter/network/kafka_broker/v2alpha1/kafka_broker.pb.validate.go index 91fec3f552..970de63257 100755 --- a/envoy/config/filter/network/kafka_broker/v2alpha1/kafka_broker.pb.validate.go +++ b/envoy/config/filter/network/kafka_broker/v2alpha1/kafka_broker.pb.validate.go @@ -70,6 +70,52 @@ func (m *KafkaBroker) validate(all bool) error { // no validation rules for ForceResponseRewrite + switch v := m.BrokerAddressRewriteSpec.(type) { + case *KafkaBroker_IdBasedBrokerAddressRewriteSpec: + if v == nil { + err := KafkaBrokerValidationError{ + field: "BrokerAddressRewriteSpec", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetIdBasedBrokerAddressRewriteSpec()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, KafkaBrokerValidationError{ + field: "IdBasedBrokerAddressRewriteSpec", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, KafkaBrokerValidationError{ + field: "IdBasedBrokerAddressRewriteSpec", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetIdBasedBrokerAddressRewriteSpec()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return KafkaBrokerValidationError{ + field: "IdBasedBrokerAddressRewriteSpec", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + if len(errors) > 0 { return KafkaBrokerMultiError(errors) } @@ -146,3 +192,274 @@ var _ interface { Cause() error ErrorName() string } = KafkaBrokerValidationError{} + +// Validate checks the field values on IdBasedBrokerRewriteSpec 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 *IdBasedBrokerRewriteSpec) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on IdBasedBrokerRewriteSpec 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 +// IdBasedBrokerRewriteSpecMultiError, or nil if none found. +func (m *IdBasedBrokerRewriteSpec) ValidateAll() error { + return m.validate(true) +} + +func (m *IdBasedBrokerRewriteSpec) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRules() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, IdBasedBrokerRewriteSpecValidationError{ + field: fmt.Sprintf("Rules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, IdBasedBrokerRewriteSpecValidationError{ + field: fmt.Sprintf("Rules[%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 IdBasedBrokerRewriteSpecValidationError{ + field: fmt.Sprintf("Rules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return IdBasedBrokerRewriteSpecMultiError(errors) + } + + return nil +} + +// IdBasedBrokerRewriteSpecMultiError is an error wrapping multiple validation +// errors returned by IdBasedBrokerRewriteSpec.ValidateAll() if the designated +// constraints aren't met. +type IdBasedBrokerRewriteSpecMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m IdBasedBrokerRewriteSpecMultiError) 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 IdBasedBrokerRewriteSpecMultiError) AllErrors() []error { return m } + +// IdBasedBrokerRewriteSpecValidationError is the validation error returned by +// IdBasedBrokerRewriteSpec.Validate if the designated constraints aren't met. +type IdBasedBrokerRewriteSpecValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e IdBasedBrokerRewriteSpecValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e IdBasedBrokerRewriteSpecValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e IdBasedBrokerRewriteSpecValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e IdBasedBrokerRewriteSpecValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e IdBasedBrokerRewriteSpecValidationError) ErrorName() string { + return "IdBasedBrokerRewriteSpecValidationError" +} + +// Error satisfies the builtin error interface +func (e IdBasedBrokerRewriteSpecValidationError) 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 %sIdBasedBrokerRewriteSpec.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = IdBasedBrokerRewriteSpecValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = IdBasedBrokerRewriteSpecValidationError{} + +// Validate checks the field values on IdBasedBrokerRewriteRule 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 *IdBasedBrokerRewriteRule) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on IdBasedBrokerRewriteRule 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 +// IdBasedBrokerRewriteRuleMultiError, or nil if none found. +func (m *IdBasedBrokerRewriteRule) ValidateAll() error { + return m.validate(true) +} + +func (m *IdBasedBrokerRewriteRule) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetId() < 0 { + err := IdBasedBrokerRewriteRuleValidationError{ + field: "Id", + reason: "value must be greater than or equal to 0", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetHost()) < 1 { + err := IdBasedBrokerRewriteRuleValidationError{ + field: "Host", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if m.GetPort() > 65535 { + err := IdBasedBrokerRewriteRuleValidationError{ + field: "Port", + reason: "value must be less than or equal to 65535", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return IdBasedBrokerRewriteRuleMultiError(errors) + } + + return nil +} + +// IdBasedBrokerRewriteRuleMultiError is an error wrapping multiple validation +// errors returned by IdBasedBrokerRewriteRule.ValidateAll() if the designated +// constraints aren't met. +type IdBasedBrokerRewriteRuleMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m IdBasedBrokerRewriteRuleMultiError) 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 IdBasedBrokerRewriteRuleMultiError) AllErrors() []error { return m } + +// IdBasedBrokerRewriteRuleValidationError is the validation error returned by +// IdBasedBrokerRewriteRule.Validate if the designated constraints aren't met. +type IdBasedBrokerRewriteRuleValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e IdBasedBrokerRewriteRuleValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e IdBasedBrokerRewriteRuleValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e IdBasedBrokerRewriteRuleValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e IdBasedBrokerRewriteRuleValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e IdBasedBrokerRewriteRuleValidationError) ErrorName() string { + return "IdBasedBrokerRewriteRuleValidationError" +} + +// Error satisfies the builtin error interface +func (e IdBasedBrokerRewriteRuleValidationError) 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 %sIdBasedBrokerRewriteRule.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = IdBasedBrokerRewriteRuleValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = IdBasedBrokerRewriteRuleValidationError{}