diff --git a/api/mesh/snp.pb.go b/api/mesh/snp.pb.go index e29b1ccd5..5f48aa97c 100644 --- a/api/mesh/snp.pb.go +++ b/api/mesh/snp.pb.go @@ -1,7 +1,23 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.5 +// protoc-gen-go v1.31.0 +// protoc v3.21.9 // source: snp.proto package mesh @@ -21,13 +37,13 @@ const ( ) // When dubbo provider start up, it reports its applicationName and its interfaceName, -// and Dubbo consumer will get the service name mapping info by xDS. +// and Dubbo consumer will get the service name mapping info by dds. type ServiceMappingRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // This is namespace of proxyless dubbo server + // This is namespace of dubbo server Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` ApplicationName string `protobuf:"bytes,2,opt,name=applicationName,proto3" json:"applicationName,omitempty"` InterfaceNames []string `protobuf:"bytes,3,rep,name=interfaceNames,proto3" json:"interfaceNames,omitempty"` @@ -90,6 +106,9 @@ type ServiceMappingResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` } func (x *ServiceMappingResponse) Reset() { @@ -124,70 +143,20 @@ func (*ServiceMappingResponse) Descriptor() ([]byte, []int) { return file_snp_proto_rawDescGZIP(), []int{1} } -type ServiceMappingXdsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // This is namespace of proxyless dubbo server - Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` - InterfaceName string `protobuf:"bytes,2,opt,name=interfaceName,proto3" json:"interfaceName,omitempty"` - ApplicationNames []string `protobuf:"bytes,3,rep,name=applicationNames,proto3" json:"applicationNames,omitempty"` -} - -func (x *ServiceMappingXdsResponse) Reset() { - *x = ServiceMappingXdsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_snp_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServiceMappingXdsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServiceMappingXdsResponse) ProtoMessage() {} - -func (x *ServiceMappingXdsResponse) ProtoReflect() protoreflect.Message { - mi := &file_snp_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 ServiceMappingXdsResponse.ProtoReflect.Descriptor instead. -func (*ServiceMappingXdsResponse) Descriptor() ([]byte, []int) { - return file_snp_proto_rawDescGZIP(), []int{2} -} - -func (x *ServiceMappingXdsResponse) GetNamespace() string { +func (x *ServiceMappingResponse) GetSuccess() bool { if x != nil { - return x.Namespace + return x.Success } - return "" + return false } -func (x *ServiceMappingXdsResponse) GetInterfaceName() string { +func (x *ServiceMappingResponse) GetMessage() string { if x != nil { - return x.InterfaceName + return x.Message } return "" } -func (x *ServiceMappingXdsResponse) GetApplicationNames() []string { - if x != nil { - return x.ApplicationNames - } - return nil -} - var File_snp_proto protoreflect.FileDescriptor var file_snp_proto_rawDesc = []byte{ @@ -201,26 +170,20 @@ var file_snp_proto_rawDesc = []byte{ 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x22, - 0x18, 0x0a, 0x16, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, - 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x8b, 0x01, 0x0a, 0x19, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x58, 0x64, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, - 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x61, - 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x32, 0x7b, 0x0a, 0x19, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x5e, 0x0a, 0x19, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x41, 0x70, 0x70, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, - 0x67, 0x12, 0x1f, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x04, 0x5a, 0x02, 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x4c, 0x0a, 0x16, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x7b, 0x0a, + 0x19, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x4d, 0x61, 0x70, 0x70, + 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5e, 0x0a, 0x19, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x41, 0x70, 0x70, + 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x1f, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x61, 0x70, 0x70, 0x69, + 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x04, 0x5a, 0x02, 0x2e, 0x2f, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -235,11 +198,10 @@ func file_snp_proto_rawDescGZIP() []byte { return file_snp_proto_rawDescData } -var file_snp_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_snp_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_snp_proto_goTypes = []interface{}{ - (*ServiceMappingRequest)(nil), // 0: v1alpha1.ServiceMappingRequest - (*ServiceMappingResponse)(nil), // 1: v1alpha1.ServiceMappingResponse - (*ServiceMappingXdsResponse)(nil), // 2: v1alpha1.ServiceMappingXdsResponse + (*ServiceMappingRequest)(nil), // 0: v1alpha1.ServiceMappingRequest + (*ServiceMappingResponse)(nil), // 1: v1alpha1.ServiceMappingResponse } var file_snp_proto_depIdxs = []int32{ 0, // 0: v1alpha1.ServiceNameMappingService.registerServiceAppMapping:input_type -> v1alpha1.ServiceMappingRequest @@ -281,18 +243,6 @@ func file_snp_proto_init() { return nil } } - file_snp_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServiceMappingXdsResponse); 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{ @@ -300,7 +250,7 @@ func file_snp_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_snp_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 2, NumExtensions: 0, NumServices: 1, }, diff --git a/api/mesh/snp.proto b/api/mesh/snp.proto index 4d80dc811..20c0fb0e0 100644 --- a/api/mesh/snp.proto +++ b/api/mesh/snp.proto @@ -28,9 +28,9 @@ service ServiceNameMappingService{ } // When dubbo provider start up, it reports its applicationName and its interfaceName, -// and Dubbo consumer will get the service name mapping info by xDS. +// and Dubbo consumer will get the service name mapping info by dds. message ServiceMappingRequest{ - // This is namespace of proxyless dubbo server + // This is namespace of dubbo server string namespace = 1; string applicationName = 2; @@ -39,4 +39,6 @@ message ServiceMappingRequest{ } message ServiceMappingResponse{ + bool success = 1; + string message = 2; } diff --git a/api/mesh/snp_grpc.pb.go b/api/mesh/snp_grpc.pb.go index 2e84accd4..4647ae1b5 100644 --- a/api/mesh/snp_grpc.pb.go +++ b/api/mesh/snp_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v3.21.5 +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.9 // source: snp.proto package mesh @@ -18,10 +18,6 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 -const ( - ServiceNameMappingService_RegisterServiceAppMapping_FullMethodName = "/v1alpha1.ServiceNameMappingService/registerServiceAppMapping" -) - // ServiceNameMappingServiceClient is the client API for ServiceNameMappingService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -39,7 +35,7 @@ func NewServiceNameMappingServiceClient(cc grpc.ClientConnInterface) ServiceName func (c *serviceNameMappingServiceClient) RegisterServiceAppMapping(ctx context.Context, in *ServiceMappingRequest, opts ...grpc.CallOption) (*ServiceMappingResponse, error) { out := new(ServiceMappingResponse) - err := c.cc.Invoke(ctx, ServiceNameMappingService_RegisterServiceAppMapping_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/v1alpha1.ServiceNameMappingService/registerServiceAppMapping", in, out, opts...) if err != nil { return nil, err } @@ -85,7 +81,7 @@ func _ServiceNameMappingService_RegisterServiceAppMapping_Handler(srv interface{ } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: ServiceNameMappingService_RegisterServiceAppMapping_FullMethodName, + FullMethod: "/v1alpha1.ServiceNameMappingService/registerServiceAppMapping", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ServiceNameMappingServiceServer).RegisterServiceAppMapping(ctx, req.(*ServiceMappingRequest)) diff --git a/api/resource/v1alpha1/authentication.pb.go b/api/resource/v1alpha1/authentication.pb.go index 0669612c3..abe1ca435 100644 --- a/api/resource/v1alpha1/authentication.pb.go +++ b/api/resource/v1alpha1/authentication.pb.go @@ -22,7 +22,7 @@ package dubbo_apache_org_v1alpha1 import ( fmt "fmt" - proto "github.com/gogo/protobuf/proto" + proto "github.com/golang/protobuf/proto" io "io" math "math" math_bits "math/bits" @@ -37,7 +37,117 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type AuthenticationPolicyToClient struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Spec *AuthenticationSpecToClient `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AuthenticationPolicyToClient) Reset() { *m = AuthenticationPolicyToClient{} } +func (m *AuthenticationPolicyToClient) String() string { return proto.CompactTextString(m) } +func (*AuthenticationPolicyToClient) ProtoMessage() {} +func (*AuthenticationPolicyToClient) Descriptor() ([]byte, []int) { + return fileDescriptor_d0dbc99083440df2, []int{0} +} +func (m *AuthenticationPolicyToClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AuthenticationPolicyToClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AuthenticationPolicyToClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AuthenticationPolicyToClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuthenticationPolicyToClient.Merge(m, src) +} +func (m *AuthenticationPolicyToClient) XXX_Size() int { + return m.Size() +} +func (m *AuthenticationPolicyToClient) XXX_DiscardUnknown() { + xxx_messageInfo_AuthenticationPolicyToClient.DiscardUnknown(m) +} + +var xxx_messageInfo_AuthenticationPolicyToClient proto.InternalMessageInfo + +func (m *AuthenticationPolicyToClient) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *AuthenticationPolicyToClient) GetSpec() *AuthenticationSpecToClient { + if m != nil { + return m.Spec + } + return nil +} + +type AuthenticationSpecToClient struct { + Action string `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"` + PortLevel []*AuthenticationPolicyPortLevel `protobuf:"bytes,2,rep,name=portLevel,proto3" json:"portLevel,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AuthenticationSpecToClient) Reset() { *m = AuthenticationSpecToClient{} } +func (m *AuthenticationSpecToClient) String() string { return proto.CompactTextString(m) } +func (*AuthenticationSpecToClient) ProtoMessage() {} +func (*AuthenticationSpecToClient) Descriptor() ([]byte, []int) { + return fileDescriptor_d0dbc99083440df2, []int{1} +} +func (m *AuthenticationSpecToClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AuthenticationSpecToClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AuthenticationSpecToClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AuthenticationSpecToClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuthenticationSpecToClient.Merge(m, src) +} +func (m *AuthenticationSpecToClient) XXX_Size() int { + return m.Size() +} +func (m *AuthenticationSpecToClient) XXX_DiscardUnknown() { + xxx_messageInfo_AuthenticationSpecToClient.DiscardUnknown(m) +} + +var xxx_messageInfo_AuthenticationSpecToClient proto.InternalMessageInfo + +func (m *AuthenticationSpecToClient) GetAction() string { + if m != nil { + return m.Action + } + return "" +} + +func (m *AuthenticationSpecToClient) GetPortLevel() []*AuthenticationPolicyPortLevel { + if m != nil { + return m.PortLevel + } + return nil +} type AuthenticationPolicy struct { Action string `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"` @@ -52,7 +162,7 @@ func (m *AuthenticationPolicy) Reset() { *m = AuthenticationPolicy{} } func (m *AuthenticationPolicy) String() string { return proto.CompactTextString(m) } func (*AuthenticationPolicy) ProtoMessage() {} func (*AuthenticationPolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_d0dbc99083440df2, []int{0} + return fileDescriptor_d0dbc99083440df2, []int{2} } func (m *AuthenticationPolicy) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -120,7 +230,7 @@ func (m *AuthenticationPolicySelector) Reset() { *m = AuthenticationPoli func (m *AuthenticationPolicySelector) String() string { return proto.CompactTextString(m) } func (*AuthenticationPolicySelector) ProtoMessage() {} func (*AuthenticationPolicySelector) Descriptor() ([]byte, []int) { - return fileDescriptor_d0dbc99083440df2, []int{1} + return fileDescriptor_d0dbc99083440df2, []int{3} } func (m *AuthenticationPolicySelector) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -217,7 +327,7 @@ func (m *AuthenticationPolicyPortLevel) Reset() { *m = AuthenticationPol func (m *AuthenticationPolicyPortLevel) String() string { return proto.CompactTextString(m) } func (*AuthenticationPolicyPortLevel) ProtoMessage() {} func (*AuthenticationPolicyPortLevel) Descriptor() ([]byte, []int) { - return fileDescriptor_d0dbc99083440df2, []int{2} + return fileDescriptor_d0dbc99083440df2, []int{4} } func (m *AuthenticationPolicyPortLevel) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -272,7 +382,7 @@ func (m *AuthenticationPolicyExtend) Reset() { *m = AuthenticationPolicy func (m *AuthenticationPolicyExtend) String() string { return proto.CompactTextString(m) } func (*AuthenticationPolicyExtend) ProtoMessage() {} func (*AuthenticationPolicyExtend) Descriptor() ([]byte, []int) { - return fileDescriptor_d0dbc99083440df2, []int{3} + return fileDescriptor_d0dbc99083440df2, []int{5} } func (m *AuthenticationPolicyExtend) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -316,6 +426,8 @@ func (m *AuthenticationPolicyExtend) GetValue() string { } func init() { + proto.RegisterType((*AuthenticationPolicyToClient)(nil), "dubbo.apache.org.v1alpha1.AuthenticationPolicyToClient") + proto.RegisterType((*AuthenticationSpecToClient)(nil), "dubbo.apache.org.v1alpha1.AuthenticationSpecToClient") proto.RegisterType((*AuthenticationPolicy)(nil), "dubbo.apache.org.v1alpha1.AuthenticationPolicy") proto.RegisterType((*AuthenticationPolicySelector)(nil), "dubbo.apache.org.v1alpha1.AuthenticationPolicySelector") proto.RegisterType((*AuthenticationPolicyPortLevel)(nil), "dubbo.apache.org.v1alpha1.AuthenticationPolicyPortLevel") @@ -325,31 +437,129 @@ func init() { func init() { proto.RegisterFile("authentication.proto", fileDescriptor_d0dbc99083440df2) } var fileDescriptor_d0dbc99083440df2 = []byte{ - // 377 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0xcf, 0x4a, 0xeb, 0x40, - 0x14, 0xc6, 0x99, 0xa6, 0xff, 0x72, 0xca, 0xbd, 0x5c, 0x86, 0x72, 0xc9, 0x2d, 0xd7, 0x10, 0x82, - 0x8b, 0xae, 0x02, 0x55, 0x44, 0xb7, 0x16, 0xbb, 0x10, 0x45, 0x43, 0x8a, 0xee, 0xa7, 0xd3, 0xc1, - 0x86, 0x8e, 0x33, 0x43, 0x32, 0x2d, 0xf6, 0x2d, 0x7c, 0x2c, 0x97, 0xee, 0xdd, 0x48, 0x9f, 0x44, - 0x32, 0x4d, 0x9b, 0x14, 0x6c, 0xa1, 0xb8, 0x9b, 0xf3, 0xcd, 0x39, 0xbf, 0x7c, 0xcc, 0xf9, 0x02, - 0x6d, 0x32, 0xd3, 0x13, 0x26, 0x74, 0x4c, 0x89, 0x8e, 0xa5, 0x08, 0x54, 0x22, 0xb5, 0xc4, 0xff, - 0xc6, 0xb3, 0xd1, 0x48, 0x06, 0x44, 0x11, 0x3a, 0x61, 0x81, 0x4c, 0x9e, 0x82, 0x79, 0x8f, 0x70, - 0x35, 0x21, 0x3d, 0xff, 0x03, 0x41, 0xfb, 0x72, 0x6b, 0x26, 0x94, 0x3c, 0xa6, 0x0b, 0xfc, 0x17, - 0xea, 0x84, 0x66, 0xb5, 0x83, 0x3c, 0xd4, 0xb5, 0xa3, 0xbc, 0xc2, 0x43, 0x68, 0xa6, 0x8c, 0x33, - 0xaa, 0x65, 0xe2, 0x54, 0x3c, 0xab, 0xdb, 0x3a, 0x39, 0x0f, 0x76, 0xe2, 0x83, 0xef, 0xd0, 0xc3, - 0x7c, 0x3c, 0xda, 0x80, 0xf0, 0x23, 0xd8, 0x4a, 0x26, 0xfa, 0x96, 0xcd, 0x19, 0x77, 0x2c, 0x43, - 0xbd, 0x38, 0x90, 0x1a, 0xae, 0xe7, 0xa3, 0x02, 0xe5, 0xbf, 0x5a, 0xf0, 0x7f, 0x9f, 0x05, 0xec, - 0x02, 0x08, 0xf2, 0xcc, 0x52, 0x45, 0x28, 0x4b, 0x1d, 0xe4, 0x59, 0x5d, 0x3b, 0x2a, 0x29, 0xf8, - 0x18, 0x7e, 0x09, 0xa9, 0xef, 0x8a, 0x96, 0x8a, 0x69, 0xd9, 0x16, 0x71, 0x07, 0x9a, 0xb1, 0xea, - 0x73, 0x49, 0xa7, 0xa9, 0x71, 0x6f, 0x47, 0x9b, 0x1a, 0x7b, 0xd0, 0x12, 0x52, 0x5f, 0xaf, 0xaf, - 0xab, 0xe6, 0xba, 0x2c, 0x65, 0x1e, 0x54, 0x12, 0x0b, 0x1a, 0x2b, 0xc2, 0x53, 0xa7, 0xb6, 0xf2, - 0x50, 0x28, 0xb9, 0x87, 0xb0, 0x68, 0xa9, 0x6f, 0x3c, 0x14, 0x22, 0xbe, 0x87, 0x06, 0x7b, 0xd1, - 0x4c, 0x8c, 0x53, 0xa7, 0x61, 0x1e, 0xf0, 0xec, 0xc0, 0x07, 0x1c, 0x98, 0xe9, 0x68, 0x4d, 0xc1, - 0x0f, 0x00, 0x42, 0xea, 0x41, 0xce, 0x6c, 0xfe, 0x84, 0x59, 0x02, 0xf9, 0x37, 0x70, 0xb4, 0x77, - 0x7d, 0x18, 0x43, 0x35, 0x5b, 0xa0, 0x89, 0x5d, 0x2d, 0x32, 0xe7, 0x52, 0x18, 0x2b, 0xe5, 0x30, - 0xfa, 0x57, 0xd0, 0xd9, 0xfd, 0x59, 0xfc, 0x07, 0xac, 0x29, 0x5b, 0xe4, 0xf9, 0xcd, 0x8e, 0xb8, - 0x0d, 0xb5, 0x39, 0xe1, 0x33, 0x96, 0x63, 0x56, 0x45, 0xff, 0xf7, 0xdb, 0xd2, 0x45, 0xef, 0x4b, - 0x17, 0x7d, 0x2e, 0x5d, 0x14, 0xa2, 0x51, 0xdd, 0xfc, 0x35, 0xa7, 0x5f, 0x01, 0x00, 0x00, 0xff, - 0xff, 0x36, 0x39, 0xa9, 0x31, 0x4d, 0x03, 0x00, 0x00, + // 438 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x8e, 0xd3, 0x30, + 0x10, 0x86, 0x71, 0xd2, 0x76, 0x9b, 0xa9, 0x90, 0x90, 0x55, 0xa1, 0xb0, 0x82, 0x28, 0x8a, 0x38, + 0xe4, 0x14, 0x69, 0x17, 0xad, 0xe0, 0xca, 0xc2, 0x1e, 0x56, 0x20, 0x88, 0x5c, 0xe0, 0xee, 0xba, + 0x16, 0x8d, 0x6a, 0x6c, 0x2b, 0x71, 0x2b, 0x2a, 0x5e, 0x81, 0x03, 0x47, 0x1e, 0x89, 0x23, 0x77, + 0x2e, 0xa8, 0xbc, 0x08, 0x8a, 0x9b, 0x34, 0x09, 0x6a, 0x11, 0x15, 0x7b, 0x8b, 0x7f, 0xcf, 0x7c, + 0xfe, 0xc7, 0x33, 0x0e, 0x8c, 0xe9, 0xd2, 0xcc, 0xb9, 0x34, 0x19, 0xa3, 0x26, 0x53, 0x32, 0xd1, + 0xb9, 0x32, 0x0a, 0xdf, 0x9b, 0x2d, 0xa7, 0x53, 0x95, 0x50, 0x4d, 0xd9, 0x9c, 0x27, 0x2a, 0x7f, + 0x9f, 0xac, 0xce, 0xa8, 0xd0, 0x73, 0x7a, 0x16, 0x7d, 0x82, 0xfb, 0x4f, 0x3b, 0x29, 0xa9, 0x12, + 0x19, 0x5b, 0xbf, 0x51, 0xcf, 0x44, 0xc6, 0xa5, 0xc1, 0x77, 0xc0, 0x5d, 0xf0, 0xb5, 0x8f, 0x42, + 0x14, 0x7b, 0xa4, 0xfc, 0xc4, 0xd7, 0xd0, 0x2b, 0x34, 0x67, 0xbe, 0x13, 0xa2, 0x78, 0x74, 0x7e, + 0x91, 0x1c, 0x64, 0x27, 0x5d, 0xf0, 0x44, 0x73, 0x56, 0x63, 0x89, 0x45, 0x44, 0x9f, 0x11, 0x9c, + 0x1e, 0x0e, 0xc2, 0x77, 0x61, 0x40, 0x59, 0xa9, 0x56, 0xc7, 0x57, 0x2b, 0xfc, 0x0e, 0x3c, 0xad, + 0x72, 0xf3, 0x92, 0xaf, 0xb8, 0xf0, 0x9d, 0xd0, 0x8d, 0x47, 0xe7, 0x4f, 0xfe, 0xd9, 0xc6, 0xb6, + 0xbe, 0xb4, 0xce, 0x27, 0x0d, 0x2a, 0xfa, 0x81, 0x60, 0xbc, 0x2f, 0xf8, 0xa0, 0x91, 0x09, 0x0c, + 0x0b, 0x2e, 0x38, 0x33, 0x2a, 0xaf, 0x7c, 0x3c, 0x3e, 0xd2, 0xc7, 0xa4, 0x4a, 0x27, 0x3b, 0x50, + 0xb7, 0x3a, 0xf7, 0xe6, 0xaa, 0xfb, 0xe2, 0xee, 0x6f, 0x75, 0x6d, 0x01, 0x07, 0x00, 0x92, 0x7e, + 0xe0, 0x85, 0xa6, 0x8c, 0x17, 0x3e, 0x0a, 0xdd, 0xd8, 0x23, 0x2d, 0x05, 0x3f, 0x84, 0xdb, 0x52, + 0x99, 0x57, 0x4d, 0x88, 0x63, 0x43, 0xba, 0x22, 0x3e, 0x85, 0x61, 0xa6, 0x2f, 0x85, 0x62, 0x8b, + 0xc2, 0xba, 0xf7, 0xc8, 0x6e, 0x8d, 0x43, 0x18, 0x49, 0x65, 0xae, 0xeb, 0xed, 0x9e, 0xdd, 0x6e, + 0x4b, 0xa5, 0x07, 0x9d, 0x67, 0x92, 0x65, 0x9a, 0x8a, 0xc2, 0xef, 0x6f, 0x3d, 0x34, 0x4a, 0xe5, + 0x21, 0x6d, 0x42, 0x06, 0x3b, 0x0f, 0x8d, 0x88, 0x5f, 0xc3, 0x09, 0xff, 0x68, 0xb8, 0x9c, 0x15, + 0xfe, 0x89, 0xbd, 0xc0, 0x8b, 0x23, 0x2f, 0xf0, 0xca, 0x66, 0x93, 0x9a, 0x82, 0xdf, 0x02, 0x48, + 0x65, 0xae, 0x2a, 0xe6, 0xf0, 0x7f, 0x98, 0x2d, 0x50, 0xf4, 0x02, 0x1e, 0xfc, 0xb5, 0x7d, 0x18, + 0x43, 0xaf, 0x6c, 0xa0, 0x1d, 0xbb, 0x3e, 0xb1, 0xdf, 0xad, 0x61, 0x74, 0xda, 0xc3, 0x18, 0x3d, + 0xff, 0xf3, 0x2d, 0xb5, 0x8f, 0xdd, 0xf3, 0x8e, 0xc7, 0xd0, 0x5f, 0x51, 0xb1, 0xe4, 0x15, 0x66, + 0xbb, 0xb8, 0xc4, 0xdf, 0x36, 0x01, 0xfa, 0xbe, 0x09, 0xd0, 0xcf, 0x4d, 0x80, 0xbe, 0xfe, 0x0a, + 0x6e, 0xa5, 0x68, 0x3a, 0xb0, 0x7f, 0x91, 0x47, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x5f, 0x05, + 0xef, 0xb0, 0x5d, 0x04, 0x00, 0x00, +} + +func (m *AuthenticationPolicyToClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AuthenticationPolicyToClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuthenticationPolicyToClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Spec != nil { + { + size, err := m.Spec.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthentication(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintAuthentication(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AuthenticationSpecToClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AuthenticationSpecToClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuthenticationSpecToClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.PortLevel) > 0 { + for iNdEx := len(m.PortLevel) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PortLevel[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthentication(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Action) > 0 { + i -= len(m.Action) + copy(dAtA[i:], m.Action) + i = encodeVarintAuthentication(dAtA, i, uint64(len(m.Action))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } func (m *AuthenticationPolicy) Marshal() (dAtA []byte, err error) { @@ -614,6 +824,48 @@ func encodeVarintAuthentication(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *AuthenticationPolicyToClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovAuthentication(uint64(l)) + } + if m.Spec != nil { + l = m.Spec.Size() + n += 1 + l + sovAuthentication(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *AuthenticationSpecToClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Action) + if l > 0 { + n += 1 + l + sovAuthentication(uint64(l)) + } + if len(m.PortLevel) > 0 { + for _, e := range m.PortLevel { + l = e.Size() + n += 1 + l + sovAuthentication(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *AuthenticationPolicy) Size() (n int) { if m == nil { return 0 @@ -747,6 +999,242 @@ func sovAuthentication(x uint64) (n int) { func sozAuthentication(x uint64) (n int) { return sovAuthentication(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *AuthenticationPolicyToClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthentication + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AuthenticationPolicyToClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AuthenticationPolicyToClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthentication + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAuthentication + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthentication + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Spec", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthentication + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuthentication + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuthentication + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Spec == nil { + m.Spec = &AuthenticationSpecToClient{} + } + if err := m.Spec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthentication(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthentication + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AuthenticationSpecToClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthentication + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AuthenticationSpecToClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AuthenticationSpecToClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthentication + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAuthentication + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthentication + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Action = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortLevel", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthentication + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuthentication + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuthentication + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortLevel = append(m.PortLevel, &AuthenticationPolicyPortLevel{}) + if err := m.PortLevel[len(m.PortLevel)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthentication(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthentication + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *AuthenticationPolicy) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/api/resource/v1alpha1/authentication.proto b/api/resource/v1alpha1/authentication.proto index 46cf89377..672595d36 100644 --- a/api/resource/v1alpha1/authentication.proto +++ b/api/resource/v1alpha1/authentication.proto @@ -21,6 +21,16 @@ package dubbo.apache.org.v1alpha1; option java_multiple_files = true; +message AuthenticationPolicyToClient { + string key = 1; + AuthenticationSpecToClient spec = 2; +} + +message AuthenticationSpecToClient { + string action = 1; + repeated AuthenticationPolicyPortLevel portLevel = 2; +} + message AuthenticationPolicy { string action = 1; repeated AuthenticationPolicySelector selector = 2; diff --git a/api/resource/v1alpha1/authorization.pb.go b/api/resource/v1alpha1/authorization.pb.go index 83136c21c..b2432f5b0 100644 --- a/api/resource/v1alpha1/authorization.pb.go +++ b/api/resource/v1alpha1/authorization.pb.go @@ -23,7 +23,7 @@ package dubbo_apache_org_v1alpha1 import ( encoding_binary "encoding/binary" fmt "fmt" - proto "github.com/gogo/protobuf/proto" + proto "github.com/golang/protobuf/proto" io "io" math "math" math_bits "math/bits" @@ -38,7 +38,196 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type AuthorizationPolicyToClient struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Spec *AuthorizationPolicySpecToClient `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AuthorizationPolicyToClient) Reset() { *m = AuthorizationPolicyToClient{} } +func (m *AuthorizationPolicyToClient) String() string { return proto.CompactTextString(m) } +func (*AuthorizationPolicyToClient) ProtoMessage() {} +func (*AuthorizationPolicyToClient) Descriptor() ([]byte, []int) { + return fileDescriptor_1dbbe58d1e51a797, []int{0} +} +func (m *AuthorizationPolicyToClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AuthorizationPolicyToClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AuthorizationPolicyToClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AuthorizationPolicyToClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuthorizationPolicyToClient.Merge(m, src) +} +func (m *AuthorizationPolicyToClient) XXX_Size() int { + return m.Size() +} +func (m *AuthorizationPolicyToClient) XXX_DiscardUnknown() { + xxx_messageInfo_AuthorizationPolicyToClient.DiscardUnknown(m) +} + +var xxx_messageInfo_AuthorizationPolicyToClient proto.InternalMessageInfo + +func (m *AuthorizationPolicyToClient) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *AuthorizationPolicyToClient) GetSpec() *AuthorizationPolicySpecToClient { + if m != nil { + return m.Spec + } + return nil +} + +type AuthorizationPolicySpecToClient struct { + Action string `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"` + Rules []*AuthorizationPolicyRuleToClient `protobuf:"bytes,2,rep,name=rules,proto3" json:"rules,omitempty"` + Samples float32 `protobuf:"fixed32,3,opt,name=samples,proto3" json:"samples,omitempty"` + Order float32 `protobuf:"fixed32,4,opt,name=order,proto3" json:"order,omitempty"` + MatchType string `protobuf:"bytes,5,opt,name=matchType,proto3" json:"matchType,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AuthorizationPolicySpecToClient) Reset() { *m = AuthorizationPolicySpecToClient{} } +func (m *AuthorizationPolicySpecToClient) String() string { return proto.CompactTextString(m) } +func (*AuthorizationPolicySpecToClient) ProtoMessage() {} +func (*AuthorizationPolicySpecToClient) Descriptor() ([]byte, []int) { + return fileDescriptor_1dbbe58d1e51a797, []int{1} +} +func (m *AuthorizationPolicySpecToClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AuthorizationPolicySpecToClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AuthorizationPolicySpecToClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AuthorizationPolicySpecToClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuthorizationPolicySpecToClient.Merge(m, src) +} +func (m *AuthorizationPolicySpecToClient) XXX_Size() int { + return m.Size() +} +func (m *AuthorizationPolicySpecToClient) XXX_DiscardUnknown() { + xxx_messageInfo_AuthorizationPolicySpecToClient.DiscardUnknown(m) +} + +var xxx_messageInfo_AuthorizationPolicySpecToClient proto.InternalMessageInfo + +func (m *AuthorizationPolicySpecToClient) GetAction() string { + if m != nil { + return m.Action + } + return "" +} + +func (m *AuthorizationPolicySpecToClient) GetRules() []*AuthorizationPolicyRuleToClient { + if m != nil { + return m.Rules + } + return nil +} + +func (m *AuthorizationPolicySpecToClient) GetSamples() float32 { + if m != nil { + return m.Samples + } + return 0 +} + +func (m *AuthorizationPolicySpecToClient) GetOrder() float32 { + if m != nil { + return m.Order + } + return 0 +} + +func (m *AuthorizationPolicySpecToClient) GetMatchType() string { + if m != nil { + return m.MatchType + } + return "" +} + +type AuthorizationPolicyRuleToClient struct { + From *AuthorizationPolicySource `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` + When *AuthorizationPolicyCondition `protobuf:"bytes,2,opt,name=when,proto3" json:"when,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AuthorizationPolicyRuleToClient) Reset() { *m = AuthorizationPolicyRuleToClient{} } +func (m *AuthorizationPolicyRuleToClient) String() string { return proto.CompactTextString(m) } +func (*AuthorizationPolicyRuleToClient) ProtoMessage() {} +func (*AuthorizationPolicyRuleToClient) Descriptor() ([]byte, []int) { + return fileDescriptor_1dbbe58d1e51a797, []int{2} +} +func (m *AuthorizationPolicyRuleToClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AuthorizationPolicyRuleToClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AuthorizationPolicyRuleToClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AuthorizationPolicyRuleToClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuthorizationPolicyRuleToClient.Merge(m, src) +} +func (m *AuthorizationPolicyRuleToClient) XXX_Size() int { + return m.Size() +} +func (m *AuthorizationPolicyRuleToClient) XXX_DiscardUnknown() { + xxx_messageInfo_AuthorizationPolicyRuleToClient.DiscardUnknown(m) +} + +var xxx_messageInfo_AuthorizationPolicyRuleToClient proto.InternalMessageInfo + +func (m *AuthorizationPolicyRuleToClient) GetFrom() *AuthorizationPolicySource { + if m != nil { + return m.From + } + return nil +} + +func (m *AuthorizationPolicyRuleToClient) GetWhen() *AuthorizationPolicyCondition { + if m != nil { + return m.When + } + return nil +} type AuthorizationPolicy struct { Action string `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"` @@ -55,7 +244,7 @@ func (m *AuthorizationPolicy) Reset() { *m = AuthorizationPolicy{} } func (m *AuthorizationPolicy) String() string { return proto.CompactTextString(m) } func (*AuthorizationPolicy) ProtoMessage() {} func (*AuthorizationPolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_1dbbe58d1e51a797, []int{0} + return fileDescriptor_1dbbe58d1e51a797, []int{3} } func (m *AuthorizationPolicy) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -132,7 +321,7 @@ func (m *AuthorizationPolicyRule) Reset() { *m = AuthorizationPolicyRule func (m *AuthorizationPolicyRule) String() string { return proto.CompactTextString(m) } func (*AuthorizationPolicyRule) ProtoMessage() {} func (*AuthorizationPolicyRule) Descriptor() ([]byte, []int) { - return fileDescriptor_1dbbe58d1e51a797, []int{1} + return fileDescriptor_1dbbe58d1e51a797, []int{4} } func (m *AuthorizationPolicyRule) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -200,7 +389,7 @@ func (m *AuthorizationPolicySource) Reset() { *m = AuthorizationPolicySo func (m *AuthorizationPolicySource) String() string { return proto.CompactTextString(m) } func (*AuthorizationPolicySource) ProtoMessage() {} func (*AuthorizationPolicySource) Descriptor() ([]byte, []int) { - return fileDescriptor_1dbbe58d1e51a797, []int{2} + return fileDescriptor_1dbbe58d1e51a797, []int{5} } func (m *AuthorizationPolicySource) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -303,7 +492,7 @@ func (m *AuthorizationPolicyTarget) Reset() { *m = AuthorizationPolicyTa func (m *AuthorizationPolicyTarget) String() string { return proto.CompactTextString(m) } func (*AuthorizationPolicyTarget) ProtoMessage() {} func (*AuthorizationPolicyTarget) Descriptor() ([]byte, []int) { - return fileDescriptor_1dbbe58d1e51a797, []int{3} + return fileDescriptor_1dbbe58d1e51a797, []int{6} } func (m *AuthorizationPolicyTarget) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -401,7 +590,7 @@ func (m *AuthorizationPolicyCondition) Reset() { *m = AuthorizationPolic func (m *AuthorizationPolicyCondition) String() string { return proto.CompactTextString(m) } func (*AuthorizationPolicyCondition) ProtoMessage() {} func (*AuthorizationPolicyCondition) Descriptor() ([]byte, []int) { - return fileDescriptor_1dbbe58d1e51a797, []int{4} + return fileDescriptor_1dbbe58d1e51a797, []int{7} } func (m *AuthorizationPolicyCondition) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -463,7 +652,7 @@ func (m *AuthorizationPolicyMatch) Reset() { *m = AuthorizationPolicyMat func (m *AuthorizationPolicyMatch) String() string { return proto.CompactTextString(m) } func (*AuthorizationPolicyMatch) ProtoMessage() {} func (*AuthorizationPolicyMatch) Descriptor() ([]byte, []int) { - return fileDescriptor_1dbbe58d1e51a797, []int{5} + return fileDescriptor_1dbbe58d1e51a797, []int{8} } func (m *AuthorizationPolicyMatch) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -518,7 +707,7 @@ func (m *AuthorizationPolicyExtend) Reset() { *m = AuthorizationPolicyEx func (m *AuthorizationPolicyExtend) String() string { return proto.CompactTextString(m) } func (*AuthorizationPolicyExtend) ProtoMessage() {} func (*AuthorizationPolicyExtend) Descriptor() ([]byte, []int) { - return fileDescriptor_1dbbe58d1e51a797, []int{6} + return fileDescriptor_1dbbe58d1e51a797, []int{9} } func (m *AuthorizationPolicyExtend) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -562,6 +751,9 @@ func (m *AuthorizationPolicyExtend) GetValue() string { } func init() { + proto.RegisterType((*AuthorizationPolicyToClient)(nil), "dubbo.apache.org.v1alpha1.AuthorizationPolicyToClient") + proto.RegisterType((*AuthorizationPolicySpecToClient)(nil), "dubbo.apache.org.v1alpha1.AuthorizationPolicySpecToClient") + proto.RegisterType((*AuthorizationPolicyRuleToClient)(nil), "dubbo.apache.org.v1alpha1.AuthorizationPolicyRuleToClient") proto.RegisterType((*AuthorizationPolicy)(nil), "dubbo.apache.org.v1alpha1.AuthorizationPolicy") proto.RegisterType((*AuthorizationPolicyRule)(nil), "dubbo.apache.org.v1alpha1.AuthorizationPolicyRule") proto.RegisterType((*AuthorizationPolicySource)(nil), "dubbo.apache.org.v1alpha1.AuthorizationPolicySource") @@ -574,42 +766,93 @@ func init() { func init() { proto.RegisterFile("authorization.proto", fileDescriptor_1dbbe58d1e51a797) } var fileDescriptor_1dbbe58d1e51a797 = []byte{ - // 507 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0xdf, 0x6a, 0xdb, 0x30, - 0x14, 0xc6, 0x91, 0x9d, 0x3f, 0xcd, 0x09, 0x1b, 0xe3, 0x74, 0x6c, 0xea, 0x28, 0x21, 0x84, 0x5d, - 0xe4, 0xca, 0xd0, 0x74, 0xb0, 0xeb, 0xf5, 0x0f, 0x74, 0x94, 0x95, 0x4c, 0x0b, 0xbb, 0x57, 0x1c, - 0xad, 0x36, 0x75, 0x24, 0x23, 0xcb, 0xdd, 0xb2, 0x57, 0xd8, 0x73, 0x0d, 0x76, 0xd9, 0x47, 0x18, - 0x79, 0x88, 0x5d, 0x0f, 0xc9, 0x4e, 0x9c, 0x41, 0x3c, 0x48, 0x07, 0xbb, 0xea, 0x9d, 0xbf, 0xcf, - 0x47, 0xbf, 0x7c, 0xd2, 0x51, 0x8e, 0x61, 0x9f, 0xe7, 0x26, 0x52, 0x3a, 0xfe, 0xca, 0x4d, 0xac, - 0x64, 0x90, 0x6a, 0x65, 0x14, 0x1e, 0xcc, 0xf2, 0xe9, 0x54, 0x05, 0x3c, 0xe5, 0x61, 0x24, 0x02, - 0xa5, 0xaf, 0x83, 0xdb, 0x23, 0x9e, 0xa4, 0x11, 0x3f, 0x1a, 0x7c, 0x27, 0xb0, 0xff, 0x66, 0x73, - 0xc9, 0x58, 0x25, 0x71, 0xb8, 0xc0, 0x67, 0xd0, 0xe2, 0xa1, 0xd5, 0x94, 0xf4, 0xc9, 0xb0, 0xc3, - 0x4a, 0x85, 0x17, 0xd0, 0xd4, 0x79, 0x22, 0x32, 0xea, 0xf5, 0xfd, 0x61, 0x77, 0x34, 0x0a, 0x6a, - 0xd1, 0xc1, 0x16, 0x2c, 0xcb, 0x13, 0xc1, 0x0a, 0x00, 0x52, 0x68, 0x67, 0x7c, 0x9e, 0x5a, 0x96, - 0xdf, 0x27, 0x43, 0x8f, 0xad, 0x24, 0x3e, 0x85, 0xa6, 0xd2, 0x33, 0xa1, 0x69, 0xc3, 0xf9, 0x85, - 0xc0, 0x43, 0xe8, 0xcc, 0xb9, 0x09, 0xa3, 0xc9, 0x22, 0x15, 0xb4, 0xe9, 0x42, 0x55, 0xc6, 0xe0, - 0x17, 0x81, 0xe7, 0x35, 0x3f, 0x88, 0x17, 0xd0, 0xf8, 0xa4, 0xd5, 0xdc, 0xed, 0xa4, 0x3b, 0x7a, - 0xb5, 0x5b, 0xe4, 0x0f, 0x2a, 0xd7, 0xa1, 0x60, 0x8e, 0x80, 0x67, 0xe0, 0x19, 0x45, 0xbd, 0xfb, - 0x70, 0x26, 0x5c, 0x5f, 0x0b, 0xc3, 0x3c, 0xa3, 0xf0, 0x12, 0x1a, 0x9f, 0x23, 0x21, 0xdd, 0xb6, - 0xbb, 0xa3, 0xd7, 0xbb, 0x71, 0x4e, 0x95, 0x9c, 0xc5, 0x56, 0x32, 0x07, 0x19, 0x7c, 0xf3, 0xe1, - 0xa0, 0x36, 0x36, 0xf6, 0x00, 0x24, 0x9f, 0x8b, 0x2c, 0xe5, 0xa1, 0xc8, 0x28, 0xe9, 0xfb, 0xc3, - 0x0e, 0xdb, 0x70, 0xf0, 0x25, 0x3c, 0x92, 0xca, 0x5c, 0x55, 0x25, 0x9e, 0x2b, 0xf9, 0xd3, 0xc4, - 0x17, 0xb0, 0x17, 0xa7, 0x27, 0x89, 0x0a, 0x6f, 0x6c, 0xaf, 0x6c, 0xc1, 0x5a, 0x63, 0x1f, 0xba, - 0x52, 0x99, 0xb7, 0xab, 0xd7, 0x0d, 0xf7, 0x7a, 0xd3, 0xb2, 0x19, 0x52, 0x1d, 0xcb, 0x30, 0x4e, - 0x79, 0x92, 0xd1, 0x66, 0x91, 0xa1, 0x72, 0xca, 0x0c, 0xe3, 0xaa, 0xa4, 0xb5, 0xce, 0x50, 0x99, - 0x78, 0x05, 0x6d, 0xf1, 0xc5, 0x08, 0x39, 0xcb, 0x68, 0xdb, 0x5d, 0xbd, 0x1d, 0xcf, 0xff, 0xdc, - 0x2d, 0x66, 0x2b, 0x08, 0x4e, 0x00, 0xa4, 0x32, 0xe7, 0x25, 0x72, 0xef, 0x1f, 0x90, 0x1b, 0x9c, - 0xba, 0x6e, 0x14, 0xcd, 0x7f, 0xe8, 0xc6, 0x7f, 0xee, 0xc6, 0x1d, 0x81, 0xc3, 0xbf, 0xfd, 0x85, - 0xf0, 0x09, 0xf8, 0x37, 0x62, 0x51, 0x8e, 0x38, 0xfb, 0x88, 0x97, 0xd0, 0xba, 0xe5, 0x49, 0xbe, - 0x1e, 0x70, 0xc7, 0xbb, 0x85, 0x78, 0x67, 0x07, 0x12, 0x2b, 0x11, 0xf8, 0x1e, 0x3a, 0x52, 0x99, - 0x8f, 0x05, 0xcf, 0xbf, 0x3f, 0xaf, 0xa2, 0x0c, 0xce, 0x80, 0xd6, 0x95, 0x21, 0x42, 0xc3, 0xd8, - 0xe1, 0x58, 0x6c, 0xc7, 0x3d, 0xdb, 0x59, 0xea, 0xc2, 0xb8, 0xa1, 0xd5, 0x61, 0x85, 0x18, 0x9c, - 0x6e, 0xbd, 0xa5, 0xc5, 0xb1, 0x6d, 0x39, 0x94, 0xad, 0x90, 0x93, 0xc7, 0x3f, 0x96, 0x3d, 0x72, - 0xb7, 0xec, 0x91, 0x9f, 0xcb, 0x1e, 0x19, 0x93, 0x69, 0xcb, 0x7d, 0x6c, 0x8e, 0x7f, 0x07, 0x00, - 0x00, 0xff, 0xff, 0xff, 0x5f, 0xd4, 0xe1, 0x83, 0x06, 0x00, 0x00, + // 581 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x96, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x71, 0x92, 0xb6, 0xeb, 0xab, 0x90, 0x90, 0x87, 0x20, 0x83, 0xa9, 0x44, 0x11, 0x87, + 0x9e, 0x22, 0xad, 0x43, 0x42, 0xe2, 0xc6, 0xba, 0x49, 0x43, 0x13, 0x55, 0x31, 0x15, 0x77, 0x37, + 0x35, 0x6b, 0xb4, 0xd4, 0xb6, 0x12, 0x67, 0x50, 0x2e, 0x7c, 0x00, 0xbe, 0x00, 0x1f, 0x85, 0x2f, + 0x80, 0xc4, 0x71, 0x57, 0x6e, 0xa8, 0x7c, 0x07, 0xce, 0x28, 0x4e, 0xda, 0x74, 0x52, 0x02, 0x0a, + 0x0c, 0x4e, 0xbb, 0xe5, 0x3d, 0xbf, 0xfc, 0xfc, 0xf7, 0xfb, 0xbb, 0xaf, 0x81, 0x6d, 0x9a, 0xa8, + 0x99, 0x88, 0x82, 0x77, 0x54, 0x05, 0x82, 0x7b, 0x32, 0x12, 0x4a, 0xe0, 0x9d, 0x69, 0x32, 0x99, + 0x08, 0x8f, 0x4a, 0xea, 0xcf, 0x98, 0x27, 0xa2, 0x53, 0xef, 0x7c, 0x8f, 0x86, 0x72, 0x46, 0xf7, + 0xdc, 0xf7, 0x70, 0xff, 0xe9, 0xe6, 0x1b, 0x23, 0x11, 0x06, 0xfe, 0x62, 0x2c, 0x06, 0x61, 0xc0, + 0xb8, 0xc2, 0xb7, 0xc0, 0x3c, 0x63, 0x0b, 0x1b, 0x39, 0xa8, 0xd7, 0x26, 0xe9, 0x23, 0x1e, 0x82, + 0x15, 0x4b, 0xe6, 0xdb, 0x86, 0x83, 0x7a, 0x9d, 0xfe, 0x13, 0xaf, 0x12, 0xed, 0x95, 0x70, 0x5f, + 0x4a, 0xe6, 0xaf, 0xd8, 0x44, 0x73, 0xdc, 0xaf, 0x08, 0x1e, 0xfc, 0xa6, 0x12, 0xdf, 0x81, 0x26, + 0xf5, 0xd3, 0xb5, 0x5c, 0x48, 0x1e, 0xe1, 0x11, 0x34, 0xa2, 0x24, 0x64, 0xb1, 0x6d, 0x38, 0x66, + 0x7d, 0x31, 0x24, 0x09, 0xd9, 0x5a, 0x4c, 0x06, 0xc2, 0x36, 0xb4, 0x62, 0x3a, 0x97, 0x29, 0xd3, + 0x74, 0x50, 0xcf, 0x20, 0xab, 0x10, 0xdf, 0x86, 0x86, 0x88, 0xa6, 0x2c, 0xb2, 0x2d, 0x9d, 0xcf, + 0x02, 0xbc, 0x0b, 0xed, 0x39, 0x55, 0xfe, 0x6c, 0xbc, 0x90, 0xcc, 0x6e, 0x68, 0x71, 0x45, 0xc2, + 0xfd, 0x54, 0x7e, 0xb6, 0xcd, 0x8d, 0xf1, 0x31, 0x58, 0xaf, 0x23, 0x31, 0xd7, 0x27, 0xeb, 0xf4, + 0x1f, 0xd5, 0xec, 0xa7, 0x48, 0x22, 0x9f, 0x11, 0x4d, 0xc0, 0x27, 0x60, 0xbd, 0x99, 0x31, 0x9e, + 0x3b, 0xf3, 0xb8, 0x1e, 0x69, 0x20, 0xf8, 0x34, 0x48, 0x43, 0xa2, 0x21, 0xee, 0x67, 0x04, 0xdb, + 0x25, 0x65, 0x95, 0x56, 0x1c, 0x5f, 0xb6, 0xa2, 0x5f, 0xdf, 0x8a, 0x7f, 0x63, 0xc1, 0x0f, 0x04, + 0x77, 0x2b, 0x36, 0xbc, 0xc2, 0xd6, 0x1f, 0x82, 0xa1, 0x44, 0xde, 0xf8, 0x9a, 0x9c, 0x31, 0x8d, + 0x4e, 0x99, 0x22, 0x86, 0x12, 0x6b, 0x03, 0xcd, 0xab, 0x30, 0xf0, 0x83, 0x09, 0x3b, 0x95, 0xb2, + 0x71, 0x17, 0x80, 0xd3, 0x39, 0x8b, 0x25, 0xf5, 0x59, 0x6c, 0x23, 0xc7, 0xec, 0xb5, 0xc9, 0x46, + 0x06, 0x3f, 0x84, 0x9b, 0x5c, 0xa8, 0x61, 0x51, 0x62, 0xe8, 0x92, 0xcb, 0x49, 0x7c, 0x0f, 0xb6, + 0x02, 0x79, 0x10, 0x0a, 0xff, 0x2c, 0xf5, 0x2a, 0x2d, 0x58, 0xc7, 0xd8, 0x81, 0x0e, 0x17, 0xea, + 0xd9, 0x6a, 0xd9, 0xd2, 0xcb, 0x9b, 0xa9, 0x54, 0x83, 0x8c, 0x02, 0xee, 0x07, 0x92, 0x86, 0xb1, + 0xdd, 0xc8, 0x34, 0x14, 0x99, 0x5c, 0xc3, 0xa8, 0x28, 0x69, 0xae, 0x35, 0x14, 0x49, 0x3c, 0x84, + 0x16, 0x7b, 0xab, 0x18, 0x9f, 0xc6, 0x76, 0x4b, 0x5f, 0xbd, 0x9a, 0xfd, 0x3f, 0xd2, 0x2f, 0x93, + 0x15, 0x04, 0x8f, 0x01, 0xb8, 0x50, 0x47, 0x39, 0x72, 0xeb, 0x2f, 0x90, 0x1b, 0x9c, 0x2a, 0x37, + 0x32, 0xf3, 0xaf, 0xdd, 0xf8, 0xcf, 0x6e, 0x5c, 0x20, 0xd8, 0xfd, 0xd5, 0x4f, 0xa8, 0xe4, 0x6f, + 0xef, 0x04, 0x9a, 0xe7, 0x34, 0x4c, 0xd6, 0x03, 0x6e, 0xbf, 0x9e, 0x88, 0xe7, 0xe9, 0x40, 0x22, + 0x39, 0x02, 0xbf, 0x80, 0x36, 0x17, 0xea, 0x55, 0xc6, 0x33, 0xff, 0x9c, 0x57, 0x50, 0xdc, 0x43, + 0xb0, 0xab, 0xca, 0x30, 0x06, 0x4b, 0xa5, 0xc3, 0x31, 0x3b, 0x8e, 0x7e, 0x4e, 0x67, 0xa9, 0x16, + 0xa3, 0x87, 0x56, 0x9b, 0x64, 0x81, 0x3b, 0x28, 0xbd, 0xa5, 0x59, 0xdb, 0x4a, 0x9a, 0x52, 0x0a, + 0x39, 0xc0, 0x5f, 0x96, 0x5d, 0x74, 0xb1, 0xec, 0xa2, 0x6f, 0xcb, 0x2e, 0xfa, 0xf8, 0xbd, 0x7b, + 0x63, 0x84, 0x26, 0x4d, 0xfd, 0x21, 0xb2, 0xff, 0x33, 0x00, 0x00, 0xff, 0xff, 0xef, 0x81, 0x9b, + 0x00, 0x9f, 0x08, 0x00, 0x00, +} + +func (m *AuthorizationPolicyToClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil } -func (m *AuthorizationPolicy) Marshal() (dAtA []byte, err error) { +func (m *AuthorizationPolicyToClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuthorizationPolicyToClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Spec != nil { + { + size, err := m.Spec.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthorization(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintAuthorization(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AuthorizationPolicySpecToClient) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -619,12 +862,12 @@ func (m *AuthorizationPolicy) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *AuthorizationPolicy) MarshalTo(dAtA []byte) (int, error) { +func (m *AuthorizationPolicySpecToClient) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *AuthorizationPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *AuthorizationPolicySpecToClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -676,7 +919,7 @@ func (m *AuthorizationPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *AuthorizationPolicyRule) Marshal() (dAtA []byte, err error) { +func (m *AuthorizationPolicyRuleToClient) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -686,12 +929,12 @@ func (m *AuthorizationPolicyRule) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *AuthorizationPolicyRule) MarshalTo(dAtA []byte) (int, error) { +func (m *AuthorizationPolicyRuleToClient) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *AuthorizationPolicyRule) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *AuthorizationPolicyRuleToClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -710,18 +953,6 @@ func (m *AuthorizationPolicyRule) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintAuthorization(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - } - if m.To != nil { - { - size, err := m.To.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAuthorization(dAtA, i, uint64(size)) - } - i-- dAtA[i] = 0x12 } if m.From != nil { @@ -739,7 +970,7 @@ func (m *AuthorizationPolicyRule) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *AuthorizationPolicySource) Marshal() (dAtA []byte, err error) { +func (m *AuthorizationPolicy) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -749,12 +980,12 @@ func (m *AuthorizationPolicySource) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *AuthorizationPolicySource) MarshalTo(dAtA []byte) (int, error) { +func (m *AuthorizationPolicy) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *AuthorizationPolicySource) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *AuthorizationPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -763,24 +994,29 @@ func (m *AuthorizationPolicySource) MarshalToSizedBuffer(dAtA []byte) (int, erro i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } - if len(m.NotExtends) > 0 { - for iNdEx := len(m.NotExtends) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.NotExtends[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAuthorization(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } + if len(m.MatchType) > 0 { + i -= len(m.MatchType) + copy(dAtA[i:], m.MatchType) + i = encodeVarintAuthorization(dAtA, i, uint64(len(m.MatchType))) + i-- + dAtA[i] = 0x2a } - if len(m.Extends) > 0 { - for iNdEx := len(m.Extends) - 1; iNdEx >= 0; iNdEx-- { + if m.Order != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Order)))) + i-- + dAtA[i] = 0x25 + } + if m.Samples != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Samples)))) + i-- + dAtA[i] = 0x1d + } + if len(m.Rules) > 0 { + for iNdEx := len(m.Rules) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Extends[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Rules[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -788,24 +1024,149 @@ func (m *AuthorizationPolicySource) MarshalToSizedBuffer(dAtA []byte) (int, erro i = encodeVarintAuthorization(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x12 } } - if len(m.NotPrincipals) > 0 { - for iNdEx := len(m.NotPrincipals) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.NotPrincipals[iNdEx]) - copy(dAtA[i:], m.NotPrincipals[iNdEx]) - i = encodeVarintAuthorization(dAtA, i, uint64(len(m.NotPrincipals[iNdEx]))) - i-- - dAtA[i] = 0x32 - } + if len(m.Action) > 0 { + i -= len(m.Action) + copy(dAtA[i:], m.Action) + i = encodeVarintAuthorization(dAtA, i, uint64(len(m.Action))) + i-- + dAtA[i] = 0xa } - if len(m.Principals) > 0 { - for iNdEx := len(m.Principals) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Principals[iNdEx]) - copy(dAtA[i:], m.Principals[iNdEx]) - i = encodeVarintAuthorization(dAtA, i, uint64(len(m.Principals[iNdEx]))) - i-- + return len(dAtA) - i, nil +} + +func (m *AuthorizationPolicyRule) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AuthorizationPolicyRule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuthorizationPolicyRule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.When != nil { + { + size, err := m.When.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthorization(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.To != nil { + { + size, err := m.To.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthorization(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.From != nil { + { + size, err := m.From.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthorization(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AuthorizationPolicySource) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AuthorizationPolicySource) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuthorizationPolicySource) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.NotExtends) > 0 { + for iNdEx := len(m.NotExtends) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.NotExtends[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthorization(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if len(m.Extends) > 0 { + for iNdEx := len(m.Extends) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Extends[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthorization(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.NotPrincipals) > 0 { + for iNdEx := len(m.NotPrincipals) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.NotPrincipals[iNdEx]) + copy(dAtA[i:], m.NotPrincipals[iNdEx]) + i = encodeVarintAuthorization(dAtA, i, uint64(len(m.NotPrincipals[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if len(m.Principals) > 0 { + for iNdEx := len(m.Principals) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Principals[iNdEx]) + copy(dAtA[i:], m.Principals[iNdEx]) + i = encodeVarintAuthorization(dAtA, i, uint64(len(m.Principals[iNdEx]))) + i-- dAtA[i] = 0x2a } } @@ -1112,6 +1473,78 @@ func encodeVarintAuthorization(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *AuthorizationPolicyToClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovAuthorization(uint64(l)) + } + if m.Spec != nil { + l = m.Spec.Size() + n += 1 + l + sovAuthorization(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *AuthorizationPolicySpecToClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Action) + if l > 0 { + n += 1 + l + sovAuthorization(uint64(l)) + } + if len(m.Rules) > 0 { + for _, e := range m.Rules { + l = e.Size() + n += 1 + l + sovAuthorization(uint64(l)) + } + } + if m.Samples != 0 { + n += 5 + } + if m.Order != 0 { + n += 5 + } + l = len(m.MatchType) + if l > 0 { + n += 1 + l + sovAuthorization(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *AuthorizationPolicyRuleToClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.From != nil { + l = m.From.Size() + n += 1 + l + sovAuthorization(uint64(l)) + } + if m.When != nil { + l = m.When.Size() + n += 1 + l + sovAuthorization(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *AuthorizationPolicy) Size() (n int) { if m == nil { return 0 @@ -1362,6 +1795,419 @@ func sovAuthorization(x uint64) (n int) { func sozAuthorization(x uint64) (n int) { return sovAuthorization(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *AuthorizationPolicyToClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorization + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AuthorizationPolicyToClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AuthorizationPolicyToClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorization + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAuthorization + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthorization + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Spec", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorization + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuthorization + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuthorization + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Spec == nil { + m.Spec = &AuthorizationPolicySpecToClient{} + } + if err := m.Spec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthorization(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthorization + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AuthorizationPolicySpecToClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorization + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AuthorizationPolicySpecToClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AuthorizationPolicySpecToClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorization + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAuthorization + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthorization + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Action = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorization + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuthorization + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuthorization + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rules = append(m.Rules, &AuthorizationPolicyRuleToClient{}) + if err := m.Rules[len(m.Rules)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Samples", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.Samples = float32(math.Float32frombits(v)) + case 4: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Order", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.Order = float32(math.Float32frombits(v)) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MatchType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorization + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAuthorization + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthorization + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MatchType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthorization(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthorization + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AuthorizationPolicyRuleToClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorization + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AuthorizationPolicyRuleToClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AuthorizationPolicyRuleToClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field From", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorization + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuthorization + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuthorization + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.From == nil { + m.From = &AuthorizationPolicySource{} + } + if err := m.From.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field When", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorization + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuthorization + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuthorization + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.When == nil { + m.When = &AuthorizationPolicyCondition{} + } + if err := m.When.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthorization(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthorization + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *AuthorizationPolicy) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/api/resource/v1alpha1/authorization.proto b/api/resource/v1alpha1/authorization.proto index e596da916..53982571d 100644 --- a/api/resource/v1alpha1/authorization.proto +++ b/api/resource/v1alpha1/authorization.proto @@ -21,6 +21,24 @@ package dubbo.apache.org.v1alpha1; option java_multiple_files = true; +message AuthorizationPolicyToClient { + string key = 1; + AuthorizationPolicySpecToClient spec = 2; +} + +message AuthorizationPolicySpecToClient { + string action = 1; + repeated AuthorizationPolicyRuleToClient rules = 2; + float samples = 3; + float order = 4; + string matchType = 5; +} + +message AuthorizationPolicyRuleToClient { + AuthorizationPolicySource from = 1; + AuthorizationPolicyCondition when = 2; +} + message AuthorizationPolicy { string action = 1; repeated AuthorizationPolicyRule rules = 2; diff --git a/api/resource/v1alpha1/traffic_deepcopy.go b/api/resource/v1alpha1/resource_deepcopy.go similarity index 58% rename from api/resource/v1alpha1/traffic_deepcopy.go rename to api/resource/v1alpha1/resource_deepcopy.go index 5468c2d69..3b167f448 100644 --- a/api/resource/v1alpha1/traffic_deepcopy.go +++ b/api/resource/v1alpha1/resource_deepcopy.go @@ -34,24 +34,45 @@ var ( _ = math.Inf ) -// DeepCopyInto supports using DynamicConfig within kubernetes types, where deepcopy-gen is used. -func (in *DynamicConfig) DeepCopyInto(out *DynamicConfig) { - p := proto.Clone(in).(*DynamicConfig) +// DeepCopyInto supports using AuthenticationPolicy within kubernetes types, where deepcopy-gen is used. +func (in *AuthenticationPolicy) DeepCopyInto(out *AuthenticationPolicy) { + p := proto.Clone(in).(*AuthenticationPolicy) *out = *p } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DynamicConfig. -func (in *DynamicConfig) DeepCopy() *DynamicConfig { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthenticationPolicy. +func (in *AuthenticationPolicy) DeepCopy() *AuthenticationPolicy { if in == nil { return nil } - out := new(DynamicConfig) + out := new(AuthenticationPolicy) in.DeepCopyInto(out) return out } -// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new DynamicConfig. -func (in *DynamicConfig) DeepCopyInterface() interface{} { +// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new AuthenticationPolicy. +func (in *AuthenticationPolicy) DeepCopyInterface() interface{} { + return in.DeepCopy() +} + +// DeepCopyInto supports using AuthorizationPolicy within kubernetes types, where deepcopy-gen is used. +func (in *AuthorizationPolicy) DeepCopyInto(out *AuthorizationPolicy) { + p := proto.Clone(in).(*AuthorizationPolicy) + *out = *p +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthorizationPolicy. +func (in *AuthorizationPolicy) DeepCopy() *AuthorizationPolicy { + if in == nil { + return nil + } + out := new(AuthorizationPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new AuthorizationPolicy. +func (in *AuthorizationPolicy) DeepCopyInterface() interface{} { return in.DeepCopy() } @@ -76,6 +97,48 @@ func (in *ConditionRoute) DeepCopyInterface() interface{} { return in.DeepCopy() } +// DeepCopyInto supports using DynamicConfig within kubernetes types, where deepcopy-gen is used. +func (in *DynamicConfig) DeepCopyInto(out *DynamicConfig) { + p := proto.Clone(in).(*DynamicConfig) + *out = *p +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DynamicConfig. +func (in *DynamicConfig) DeepCopy() *DynamicConfig { + if in == nil { + return nil + } + out := new(DynamicConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new DynamicConfig. +func (in *DynamicConfig) DeepCopyInterface() interface{} { + return in.DeepCopy() +} + +// DeepCopyInto supports using ServiceNameMapping within kubernetes types, where deepcopy-gen is used. +func (in *ServiceNameMapping) DeepCopyInto(out *ServiceNameMapping) { + p := proto.Clone(in).(*ServiceNameMapping) + *out = *p +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceNameMapping. +func (in *ServiceNameMapping) DeepCopy() *ServiceNameMapping { + if in == nil { + return nil + } + out := new(ServiceNameMapping) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new ServiceNameMapping. +func (in *ServiceNameMapping) DeepCopyInterface() interface{} { + return in.DeepCopy() +} + // DeepCopyInto supports using TagRoute within kubernetes types, where deepcopy-gen is used. func (in *TagRoute) DeepCopyInto(out *TagRoute) { p := proto.Clone(in).(*TagRoute) diff --git a/api/resource/v1alpha1/servicemapping.pb.go b/api/resource/v1alpha1/servicemapping.pb.go index 3dbca5cd8..c04d579ad 100644 --- a/api/resource/v1alpha1/servicemapping.pb.go +++ b/api/resource/v1alpha1/servicemapping.pb.go @@ -22,7 +22,7 @@ package dubbo_apache_org_v1alpha1 import ( fmt "fmt" - proto "github.com/gogo/protobuf/proto" + proto "github.com/golang/protobuf/proto" io "io" math "math" math_bits "math/bits" @@ -37,7 +37,62 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type ServiceNameMappingToClient struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Spec *ServiceNameMapping `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ServiceNameMappingToClient) Reset() { *m = ServiceNameMappingToClient{} } +func (m *ServiceNameMappingToClient) String() string { return proto.CompactTextString(m) } +func (*ServiceNameMappingToClient) ProtoMessage() {} +func (*ServiceNameMappingToClient) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0ebb678408b52a, []int{0} +} +func (m *ServiceNameMappingToClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ServiceNameMappingToClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ServiceNameMappingToClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ServiceNameMappingToClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServiceNameMappingToClient.Merge(m, src) +} +func (m *ServiceNameMappingToClient) XXX_Size() int { + return m.Size() +} +func (m *ServiceNameMappingToClient) XXX_DiscardUnknown() { + xxx_messageInfo_ServiceNameMappingToClient.DiscardUnknown(m) +} + +var xxx_messageInfo_ServiceNameMappingToClient proto.InternalMessageInfo + +func (m *ServiceNameMappingToClient) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *ServiceNameMappingToClient) GetSpec() *ServiceNameMapping { + if m != nil { + return m.Spec + } + return nil +} type ServiceNameMapping struct { InterfaceName string `protobuf:"bytes,1,opt,name=interfaceName,proto3" json:"interfaceName,omitempty"` @@ -51,7 +106,7 @@ func (m *ServiceNameMapping) Reset() { *m = ServiceNameMapping{} } func (m *ServiceNameMapping) String() string { return proto.CompactTextString(m) } func (*ServiceNameMapping) ProtoMessage() {} func (*ServiceNameMapping) Descriptor() ([]byte, []int) { - return fileDescriptor_4c0ebb678408b52a, []int{0} + return fileDescriptor_4c0ebb678408b52a, []int{1} } func (m *ServiceNameMapping) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -95,23 +150,74 @@ func (m *ServiceNameMapping) GetApplicationNames() []string { } func init() { + proto.RegisterType((*ServiceNameMappingToClient)(nil), "dubbo.apache.org.v1alpha1.ServiceNameMappingToClient") proto.RegisterType((*ServiceNameMapping)(nil), "dubbo.apache.org.v1alpha1.ServiceNameMapping") } func init() { proto.RegisterFile("servicemapping.proto", fileDescriptor_4c0ebb678408b52a) } var fileDescriptor_4c0ebb678408b52a = []byte{ - // 158 bytes of a gzipped FileDescriptorProto + // 213 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xcd, 0x4d, 0x2c, 0x28, 0xc8, 0xcc, 0x4b, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x4c, 0x29, 0x4d, 0x4a, 0xca, 0xd7, 0x4b, 0x2c, 0x48, 0x4c, 0xce, 0x48, 0xd5, 0xcb, - 0x2f, 0x4a, 0xd7, 0x2b, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0x54, 0x4a, 0xe3, 0x12, 0x0a, - 0x86, 0x68, 0xf1, 0x4b, 0xcc, 0x4d, 0xf5, 0x85, 0x68, 0x13, 0x52, 0xe1, 0xe2, 0xcd, 0xcc, 0x2b, - 0x49, 0x2d, 0x4a, 0x4b, 0x84, 0x88, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0xa1, 0x0a, 0x0a, - 0x69, 0x71, 0x09, 0x24, 0x16, 0x14, 0xe4, 0x64, 0x26, 0x27, 0x96, 0x64, 0xe6, 0xe7, 0x81, 0x84, - 0x8a, 0x25, 0x98, 0x14, 0x98, 0x35, 0x38, 0x83, 0x30, 0xc4, 0x9d, 0xf8, 0x4e, 0x3c, 0x92, 0x63, - 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x00, 0xc6, 0x24, 0x36, 0xb0, 0xcb, 0x8c, - 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x9d, 0x48, 0x0f, 0xb1, 0x00, 0x00, 0x00, + 0x2f, 0x4a, 0xd7, 0x2b, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0x54, 0x2a, 0xe4, 0x92, 0x0a, + 0x86, 0x68, 0xf1, 0x4b, 0xcc, 0x4d, 0xf5, 0x85, 0x68, 0x0b, 0xc9, 0x77, 0xce, 0xc9, 0x4c, 0xcd, + 0x2b, 0x11, 0x12, 0xe0, 0x62, 0xce, 0x4e, 0xad, 0x94, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, + 0x31, 0x85, 0x1c, 0xb9, 0x58, 0x8a, 0x0b, 0x52, 0x93, 0x25, 0x98, 0x14, 0x18, 0x35, 0xb8, 0x8d, + 0x74, 0xf5, 0x70, 0x9a, 0xac, 0x87, 0x69, 0x6c, 0x10, 0x58, 0xab, 0x52, 0x1a, 0x97, 0x10, 0xa6, + 0x9c, 0x90, 0x0a, 0x17, 0x6f, 0x66, 0x5e, 0x49, 0x6a, 0x51, 0x5a, 0x22, 0x44, 0x1c, 0x6a, 0x29, + 0xaa, 0xa0, 0x90, 0x16, 0x97, 0x40, 0x62, 0x41, 0x41, 0x4e, 0x66, 0x72, 0x62, 0x49, 0x66, 0x7e, + 0x1e, 0x48, 0xa8, 0x58, 0x82, 0x49, 0x81, 0x59, 0x83, 0x33, 0x08, 0x43, 0xdc, 0x49, 0xe8, 0xc4, + 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf1, 0x58, 0x8e, 0x21, + 0x80, 0x31, 0x89, 0x0d, 0x1c, 0x20, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8b, 0xa6, 0x0b, + 0x9d, 0x28, 0x01, 0x00, 0x00, +} + +func (m *ServiceNameMappingToClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ServiceNameMappingToClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ServiceNameMappingToClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Spec != nil { + { + size, err := m.Spec.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintServicemapping(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintServicemapping(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } func (m *ServiceNameMapping) Marshal() (dAtA []byte, err error) { @@ -168,6 +274,26 @@ func encodeVarintServicemapping(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *ServiceNameMappingToClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovServicemapping(uint64(l)) + } + if m.Spec != nil { + l = m.Spec.Size() + n += 1 + l + sovServicemapping(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *ServiceNameMapping) Size() (n int) { if m == nil { return 0 @@ -196,6 +322,125 @@ func sovServicemapping(x uint64) (n int) { func sozServicemapping(x uint64) (n int) { return sovServicemapping(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *ServiceNameMappingToClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServicemapping + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ServiceNameMappingToClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ServiceNameMappingToClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServicemapping + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthServicemapping + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthServicemapping + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Spec", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServicemapping + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthServicemapping + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthServicemapping + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Spec == nil { + m.Spec = &ServiceNameMapping{} + } + if err := m.Spec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipServicemapping(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthServicemapping + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ServiceNameMapping) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/api/resource/v1alpha1/servicemapping.proto b/api/resource/v1alpha1/servicemapping.proto index 5525c16ba..96279e981 100644 --- a/api/resource/v1alpha1/servicemapping.proto +++ b/api/resource/v1alpha1/servicemapping.proto @@ -21,6 +21,11 @@ package dubbo.apache.org.v1alpha1; option java_multiple_files = true; +message ServiceNameMappingToClient { + string key = 1; + ServiceNameMapping spec = 2; +} + message ServiceNameMapping { string interfaceName = 1; repeated string applicationNames = 2; diff --git a/api/resource/v1alpha1/servicemapping_deepcopy.go b/api/resource/v1alpha1/servicemapping_deepcopy.go deleted file mode 100644 index 21cb81bb7..000000000 --- a/api/resource/v1alpha1/servicemapping_deepcopy.go +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Code generated by tools/generate_deepcopy_types.go. DO NOT EDIT! - -package dubbo_apache_org_v1alpha1 - -import ( - fmt "fmt" - proto "github.com/gogo/protobuf/proto" - _ "github.com/gogo/protobuf/types" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// DeepCopyInto supports using ServiceNameMapping within kubernetes types, where deepcopy-gen is used. -func (in *ServiceNameMapping) DeepCopyInto(out *ServiceNameMapping) { - p := proto.Clone(in).(*ServiceNameMapping) - *out = *p -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceNameMapping. -func (in *ServiceNameMapping) DeepCopy() *ServiceNameMapping { - if in == nil { - return nil - } - out := new(ServiceNameMapping) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new ServiceNameMapping. -func (in *ServiceNameMapping) DeepCopyInterface() interface{} { - return in.DeepCopy() -} diff --git a/api/resource/v1alpha1/ca_deepcopy.go b/api/resource/v1alpha1/toClient_deepcopy.go similarity index 59% rename from api/resource/v1alpha1/ca_deepcopy.go rename to api/resource/v1alpha1/toClient_deepcopy.go index 156ebaf00..9985db8e3 100644 --- a/api/resource/v1alpha1/ca_deepcopy.go +++ b/api/resource/v1alpha1/toClient_deepcopy.go @@ -34,44 +34,44 @@ var ( _ = math.Inf ) -// DeepCopyInto supports using AuthorizationPolicy within kubernetes types, where deepcopy-gen is used. -func (in *AuthorizationPolicy) DeepCopyInto(out *AuthorizationPolicy) { - p := proto.Clone(in).(*AuthorizationPolicy) +// DeepCopyInto supports using AuthorizationPolicySource within kubernetes types, where deepcopy-gen is used. +func (in *AuthorizationPolicySource) DeepCopyInto(out *AuthorizationPolicySource) { + p := proto.Clone(in).(*AuthorizationPolicySource) *out = *p } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthorizationPolicy. -func (in *AuthorizationPolicy) DeepCopy() *AuthorizationPolicy { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthorizationPolicySource. +func (in *AuthorizationPolicySource) DeepCopy() *AuthorizationPolicySource { if in == nil { return nil } - out := new(AuthorizationPolicy) + out := new(AuthorizationPolicySource) in.DeepCopyInto(out) return out } -// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new AuthorizationPolicy. -func (in *AuthorizationPolicy) DeepCopyInterface() interface{} { +// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new AuthorizationPolicySource. +func (in *AuthorizationPolicySource) DeepCopyInterface() interface{} { return in.DeepCopy() } -// DeepCopyInto supports using AuthenticationPolicy within kubernetes types, where deepcopy-gen is used. -func (in *AuthenticationPolicy) DeepCopyInto(out *AuthenticationPolicy) { - p := proto.Clone(in).(*AuthenticationPolicy) +// DeepCopyInto supports using AuthorizationPolicyCondition within kubernetes types, where deepcopy-gen is used. +func (in *AuthorizationPolicyCondition) DeepCopyInto(out *AuthorizationPolicyCondition) { + p := proto.Clone(in).(*AuthorizationPolicyCondition) *out = *p } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthenticationPolicy. -func (in *AuthenticationPolicy) DeepCopy() *AuthenticationPolicy { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthorizationPolicyCondition. +func (in *AuthorizationPolicyCondition) DeepCopy() *AuthorizationPolicyCondition { if in == nil { return nil } - out := new(AuthenticationPolicy) + out := new(AuthorizationPolicyCondition) in.DeepCopyInto(out) return out } -// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new AuthenticationPolicy. -func (in *AuthenticationPolicy) DeepCopyInterface() interface{} { +// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new AuthorizationPolicyCondition. +func (in *AuthorizationPolicyCondition) DeepCopyInterface() interface{} { return in.DeepCopy() } diff --git a/api/resource/v1alpha1/traffic.pb.go b/api/resource/v1alpha1/traffic.pb.go index eb5790a8b..102945f1e 100644 --- a/api/resource/v1alpha1/traffic.pb.go +++ b/api/resource/v1alpha1/traffic.pb.go @@ -16,13 +16,13 @@ */ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: resource.proto +// source: traffic.proto package dubbo_apache_org_v1alpha1 import ( fmt "fmt" - proto "github.com/gogo/protobuf/proto" + proto "github.com/golang/protobuf/proto" io "io" math "math" math_bits "math/bits" @@ -37,7 +37,172 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type ConditionRouteToClient struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Spec *ConditionRoute `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ConditionRouteToClient) Reset() { *m = ConditionRouteToClient{} } +func (m *ConditionRouteToClient) String() string { return proto.CompactTextString(m) } +func (*ConditionRouteToClient) ProtoMessage() {} +func (*ConditionRouteToClient) Descriptor() ([]byte, []int) { + return fileDescriptor_50e185a42cb2d3c6, []int{0} +} +func (m *ConditionRouteToClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConditionRouteToClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConditionRouteToClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ConditionRouteToClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConditionRouteToClient.Merge(m, src) +} +func (m *ConditionRouteToClient) XXX_Size() int { + return m.Size() +} +func (m *ConditionRouteToClient) XXX_DiscardUnknown() { + xxx_messageInfo_ConditionRouteToClient.DiscardUnknown(m) +} + +var xxx_messageInfo_ConditionRouteToClient proto.InternalMessageInfo + +func (m *ConditionRouteToClient) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *ConditionRouteToClient) GetSpec() *ConditionRoute { + if m != nil { + return m.Spec + } + return nil +} + +type DynamicConfigToClient struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Spec *DynamicConfig `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DynamicConfigToClient) Reset() { *m = DynamicConfigToClient{} } +func (m *DynamicConfigToClient) String() string { return proto.CompactTextString(m) } +func (*DynamicConfigToClient) ProtoMessage() {} +func (*DynamicConfigToClient) Descriptor() ([]byte, []int) { + return fileDescriptor_50e185a42cb2d3c6, []int{1} +} +func (m *DynamicConfigToClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DynamicConfigToClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DynamicConfigToClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DynamicConfigToClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_DynamicConfigToClient.Merge(m, src) +} +func (m *DynamicConfigToClient) XXX_Size() int { + return m.Size() +} +func (m *DynamicConfigToClient) XXX_DiscardUnknown() { + xxx_messageInfo_DynamicConfigToClient.DiscardUnknown(m) +} + +var xxx_messageInfo_DynamicConfigToClient proto.InternalMessageInfo + +func (m *DynamicConfigToClient) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *DynamicConfigToClient) GetSpec() *DynamicConfig { + if m != nil { + return m.Spec + } + return nil +} + +type TagRouteToClient struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Spec *TagRoute `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TagRouteToClient) Reset() { *m = TagRouteToClient{} } +func (m *TagRouteToClient) String() string { return proto.CompactTextString(m) } +func (*TagRouteToClient) ProtoMessage() {} +func (*TagRouteToClient) Descriptor() ([]byte, []int) { + return fileDescriptor_50e185a42cb2d3c6, []int{2} +} +func (m *TagRouteToClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TagRouteToClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TagRouteToClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TagRouteToClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_TagRouteToClient.Merge(m, src) +} +func (m *TagRouteToClient) XXX_Size() int { + return m.Size() +} +func (m *TagRouteToClient) XXX_DiscardUnknown() { + xxx_messageInfo_TagRouteToClient.DiscardUnknown(m) +} + +var xxx_messageInfo_TagRouteToClient proto.InternalMessageInfo + +func (m *TagRouteToClient) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *TagRouteToClient) GetSpec() *TagRoute { + if m != nil { + return m.Spec + } + return nil +} type ConditionRoute struct { Priority int32 `protobuf:"varint,1,opt,name=priority,proto3" json:"priority,omitempty"` @@ -57,7 +222,7 @@ func (m *ConditionRoute) Reset() { *m = ConditionRoute{} } func (m *ConditionRoute) String() string { return proto.CompactTextString(m) } func (*ConditionRoute) ProtoMessage() {} func (*ConditionRoute) Descriptor() ([]byte, []int) { - return fileDescriptor_50e185a42cb2d3c6, []int{0} + return fileDescriptor_50e185a42cb2d3c6, []int{3} } func (m *ConditionRoute) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -157,7 +322,7 @@ func (m *DynamicConfig) Reset() { *m = DynamicConfig{} } func (m *DynamicConfig) String() string { return proto.CompactTextString(m) } func (*DynamicConfig) ProtoMessage() {} func (*DynamicConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_50e185a42cb2d3c6, []int{1} + return fileDescriptor_50e185a42cb2d3c6, []int{4} } func (m *DynamicConfig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -240,7 +405,7 @@ func (m *OverrideConfig) Reset() { *m = OverrideConfig{} } func (m *OverrideConfig) String() string { return proto.CompactTextString(m) } func (*OverrideConfig) ProtoMessage() {} func (*OverrideConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_50e185a42cb2d3c6, []int{2} + return fileDescriptor_50e185a42cb2d3c6, []int{5} } func (m *OverrideConfig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -346,7 +511,7 @@ func (m *ConditionMatch) Reset() { *m = ConditionMatch{} } func (m *ConditionMatch) String() string { return proto.CompactTextString(m) } func (*ConditionMatch) ProtoMessage() {} func (*ConditionMatch) Descriptor() ([]byte, []int) { - return fileDescriptor_50e185a42cb2d3c6, []int{3} + return fileDescriptor_50e185a42cb2d3c6, []int{6} } func (m *ConditionMatch) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -416,7 +581,7 @@ func (m *AddressMatch) Reset() { *m = AddressMatch{} } func (m *AddressMatch) String() string { return proto.CompactTextString(m) } func (*AddressMatch) ProtoMessage() {} func (*AddressMatch) Descriptor() ([]byte, []int) { - return fileDescriptor_50e185a42cb2d3c6, []int{4} + return fileDescriptor_50e185a42cb2d3c6, []int{7} } func (m *AddressMatch) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -477,7 +642,7 @@ func (m *ListStringMatch) Reset() { *m = ListStringMatch{} } func (m *ListStringMatch) String() string { return proto.CompactTextString(m) } func (*ListStringMatch) ProtoMessage() {} func (*ListStringMatch) Descriptor() ([]byte, []int) { - return fileDescriptor_50e185a42cb2d3c6, []int{5} + return fileDescriptor_50e185a42cb2d3c6, []int{8} } func (m *ListStringMatch) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -529,7 +694,7 @@ func (m *StringMatch) Reset() { *m = StringMatch{} } func (m *StringMatch) String() string { return proto.CompactTextString(m) } func (*StringMatch) ProtoMessage() {} func (*StringMatch) Descriptor() ([]byte, []int) { - return fileDescriptor_50e185a42cb2d3c6, []int{6} + return fileDescriptor_50e185a42cb2d3c6, []int{9} } func (m *StringMatch) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -612,7 +777,7 @@ func (m *ParamMatch) Reset() { *m = ParamMatch{} } func (m *ParamMatch) String() string { return proto.CompactTextString(m) } func (*ParamMatch) ProtoMessage() {} func (*ParamMatch) Descriptor() ([]byte, []int) { - return fileDescriptor_50e185a42cb2d3c6, []int{7} + return fileDescriptor_50e185a42cb2d3c6, []int{10} } func (m *ParamMatch) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -661,7 +826,8 @@ type TagRoute struct { Runtime bool `protobuf:"varint,3,opt,name=runtime,proto3" json:"runtime,omitempty"` Key string `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"` ConfigVersion string `protobuf:"bytes,5,opt,name=configVersion,proto3" json:"configVersion,omitempty"` - Tags []*Tag `protobuf:"bytes,6,rep,name=tags,proto3" json:"tags,omitempty"` + Force bool `protobuf:"varint,6,opt,name=force,proto3" json:"force,omitempty"` + Tags []*Tag `protobuf:"bytes,7,rep,name=tags,proto3" json:"tags,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -671,7 +837,7 @@ func (m *TagRoute) Reset() { *m = TagRoute{} } func (m *TagRoute) String() string { return proto.CompactTextString(m) } func (*TagRoute) ProtoMessage() {} func (*TagRoute) Descriptor() ([]byte, []int) { - return fileDescriptor_50e185a42cb2d3c6, []int{8} + return fileDescriptor_50e185a42cb2d3c6, []int{11} } func (m *TagRoute) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -735,6 +901,13 @@ func (m *TagRoute) GetConfigVersion() string { return "" } +func (m *TagRoute) GetForce() bool { + if m != nil { + return m.Force + } + return false +} + func (m *TagRoute) GetTags() []*Tag { if m != nil { return m.Tags @@ -755,7 +928,7 @@ func (m *Tag) Reset() { *m = Tag{} } func (m *Tag) String() string { return proto.CompactTextString(m) } func (*Tag) ProtoMessage() {} func (*Tag) Descriptor() ([]byte, []int) { - return fileDescriptor_50e185a42cb2d3c6, []int{9} + return fileDescriptor_50e185a42cb2d3c6, []int{12} } func (m *Tag) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -806,6 +979,9 @@ func (m *Tag) GetMatch() []*ParamMatch { } func init() { + proto.RegisterType((*ConditionRouteToClient)(nil), "dubbo.apache.org.v1alpha1.ConditionRouteToClient") + proto.RegisterType((*DynamicConfigToClient)(nil), "dubbo.apache.org.v1alpha1.DynamicConfigToClient") + proto.RegisterType((*TagRouteToClient)(nil), "dubbo.apache.org.v1alpha1.TagRouteToClient") proto.RegisterType((*ConditionRoute)(nil), "dubbo.apache.org.v1alpha1.ConditionRoute") proto.RegisterType((*DynamicConfig)(nil), "dubbo.apache.org.v1alpha1.DynamicConfig") proto.RegisterType((*OverrideConfig)(nil), "dubbo.apache.org.v1alpha1.OverrideConfig") @@ -819,57 +995,200 @@ func init() { proto.RegisterType((*Tag)(nil), "dubbo.apache.org.v1alpha1.Tag") } -func init() { proto.RegisterFile("resource.proto", fileDescriptor_50e185a42cb2d3c6) } +func init() { proto.RegisterFile("traffic.proto", fileDescriptor_50e185a42cb2d3c6) } var fileDescriptor_50e185a42cb2d3c6 = []byte{ - // 751 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcb, 0x6e, 0x13, 0x4b, - 0x10, 0x55, 0x7b, 0x3c, 0x7e, 0x94, 0xf3, 0xb8, 0xb7, 0x75, 0x75, 0xd5, 0x37, 0xba, 0xb2, 0xac, - 0x11, 0x0f, 0x83, 0x90, 0xa5, 0x98, 0x0d, 0x90, 0x20, 0x14, 0x12, 0x76, 0x41, 0x89, 0x86, 0x08, - 0x09, 0x89, 0x4d, 0x7b, 0xa6, 0xed, 0xb4, 0xb0, 0xa7, 0x47, 0x3d, 0x6d, 0x13, 0x7f, 0x0c, 0x3b, - 0x7e, 0x02, 0x89, 0x35, 0x62, 0xc9, 0x27, 0xa0, 0x88, 0x0f, 0x41, 0x53, 0xf3, 0x48, 0x3b, 0x31, - 0x0e, 0x11, 0xbb, 0xae, 0x9a, 0xaa, 0xd3, 0xa7, 0x4e, 0xd5, 0x54, 0xc3, 0xba, 0xd1, 0x7c, 0x38, - 0x94, 0x41, 0x2f, 0xd6, 0xca, 0x28, 0xfa, 0x5f, 0x38, 0x1d, 0x0c, 0x54, 0x8f, 0xc7, 0x3c, 0x38, - 0x15, 0x3d, 0xa5, 0x47, 0xbd, 0xd9, 0x36, 0x1f, 0xc7, 0xa7, 0x7c, 0xdb, 0xfb, 0x41, 0x60, 0x63, - 0x5f, 0x45, 0xa1, 0x34, 0x52, 0x45, 0xbe, 0x9a, 0x1a, 0x41, 0xb7, 0xa0, 0x11, 0x6b, 0xa9, 0xb4, - 0x34, 0x73, 0x46, 0x3a, 0xa4, 0xeb, 0xfa, 0xa5, 0x4d, 0x19, 0xd4, 0x45, 0xc4, 0x07, 0x63, 0x11, - 0xb2, 0x4a, 0x87, 0x74, 0x1b, 0x7e, 0x61, 0xd2, 0x7f, 0xc0, 0x1d, 0x2a, 0x1d, 0x08, 0xe6, 0xa0, - 0x3f, 0x33, 0xd2, 0x78, 0x3d, 0x8d, 0x8c, 0x9c, 0x08, 0x56, 0xcd, 0xe2, 0x73, 0x93, 0xfe, 0x05, - 0xce, 0x3b, 0x31, 0x67, 0x6e, 0x87, 0x74, 0x9b, 0x7e, 0x7a, 0x4c, 0x11, 0x92, 0x40, 0xc5, 0x82, - 0xd5, 0xd0, 0x97, 0x19, 0xb4, 0x0d, 0x10, 0x14, 0xfc, 0x12, 0x56, 0xef, 0x38, 0xdd, 0xa6, 0x6f, - 0x79, 0xe8, 0x2d, 0x58, 0x0f, 0x54, 0x34, 0x94, 0xa3, 0xd7, 0x42, 0x27, 0x52, 0x45, 0xac, 0x81, - 0xd9, 0x8b, 0x4e, 0xef, 0x33, 0x81, 0xf5, 0x83, 0x79, 0xc4, 0x27, 0x32, 0xd8, 0xc7, 0x0f, 0xc5, - 0xfd, 0x64, 0xc9, 0xfd, 0x15, 0xfb, 0xfe, 0x2b, 0xf8, 0xce, 0x12, 0x7c, 0x5b, 0x97, 0xea, 0xa2, - 0x2e, 0xfb, 0x50, 0xcf, 0x42, 0x13, 0xe6, 0x76, 0x9c, 0x6e, 0xab, 0x7f, 0xaf, 0xf7, 0xcb, 0x6e, - 0xf4, 0x8e, 0x66, 0x42, 0x6b, 0x19, 0x8a, 0x8c, 0xa3, 0x5f, 0x64, 0x7a, 0x9f, 0x1c, 0xd8, 0x58, - 0xfc, 0x46, 0x29, 0x54, 0x13, 0x19, 0x8a, 0xbc, 0x00, 0x3c, 0xd3, 0xff, 0xa1, 0xc9, 0xc3, 0x50, - 0x8b, 0x24, 0x11, 0x09, 0xab, 0xa0, 0x54, 0x17, 0x0e, 0xfa, 0x00, 0xfe, 0x8e, 0xb5, 0x9a, 0xc9, - 0x50, 0xe8, 0xbd, 0x32, 0xca, 0xc1, 0xa8, 0xab, 0x1f, 0xe8, 0x1b, 0x80, 0x98, 0x6b, 0x3e, 0x11, - 0x46, 0xe8, 0x84, 0x55, 0x91, 0xfa, 0xe3, 0xdf, 0xa6, 0xde, 0x3b, 0x2e, 0x73, 0x5f, 0x44, 0x46, - 0xcf, 0x7d, 0x0b, 0x8c, 0x7a, 0xb0, 0xc6, 0xe3, 0x78, 0x2c, 0x03, 0x9e, 0x35, 0xd5, 0x45, 0x0e, - 0x0b, 0xbe, 0x74, 0x08, 0x13, 0xa1, 0x67, 0x32, 0x10, 0x09, 0xab, 0xe1, 0xf7, 0xd2, 0x4e, 0x4b, - 0x37, 0xf3, 0x58, 0xb0, 0x7a, 0x56, 0x7a, 0x7a, 0xb6, 0x1b, 0xd0, 0x58, 0x6c, 0xc0, 0x33, 0x70, - 0x27, 0xdc, 0x04, 0xa7, 0xac, 0xd9, 0x21, 0xd7, 0xc8, 0x5f, 0xfe, 0x08, 0x2f, 0xd3, 0x04, 0x3f, - 0xcb, 0xdb, 0x7a, 0x0a, 0x9b, 0x97, 0xaa, 0x59, 0x3e, 0x3c, 0x33, 0x3e, 0x9e, 0x96, 0xc3, 0x83, - 0xc6, 0x93, 0xca, 0x23, 0xe2, 0x7d, 0xac, 0x58, 0x7f, 0x18, 0x02, 0xd3, 0x3d, 0xa8, 0xe7, 0x6d, - 0x41, 0x88, 0x56, 0xff, 0xee, 0x0a, 0x52, 0x79, 0x4b, 0x32, 0x4a, 0x45, 0x1e, 0x3d, 0x80, 0x7a, - 0xae, 0x07, 0xde, 0xd8, 0xea, 0xdf, 0x5f, 0x01, 0x71, 0x28, 0x13, 0xf3, 0xca, 0x68, 0x19, 0x8d, - 0x72, 0x94, 0x3c, 0x95, 0x1e, 0x42, 0xcb, 0x52, 0x1d, 0x47, 0xfb, 0x66, 0x48, 0x76, 0x3a, 0xdd, - 0x01, 0x17, 0xbb, 0x9c, 0x4f, 0xcb, 0xed, 0x15, 0x38, 0x28, 0x68, 0xae, 0x32, 0xe6, 0x78, 0x27, - 0xb0, 0x66, 0x57, 0x9a, 0x0e, 0xc0, 0x7b, 0x39, 0x0e, 0x03, 0xae, 0xc3, 0x5c, 0xe7, 0xd2, 0x4e, - 0x07, 0x20, 0x90, 0x3a, 0xcc, 0xb5, 0xc6, 0x73, 0xda, 0x00, 0x71, 0xc6, 0x03, 0x93, 0xff, 0x9f, - 0x99, 0xe1, 0x1d, 0xc1, 0xe6, 0x25, 0xca, 0x74, 0x17, 0x5c, 0x15, 0x09, 0x35, 0x64, 0x04, 0x59, - 0xde, 0x59, 0xc1, 0xd2, 0xae, 0x34, 0x4b, 0xf2, 0x3e, 0x10, 0x68, 0xd9, 0x68, 0xe5, 0xb5, 0xc4, - 0xba, 0x96, 0xfe, 0x0b, 0xb5, 0x58, 0x8b, 0xa1, 0x3c, 0xcb, 0x29, 0xe6, 0x56, 0x1a, 0xad, 0xc5, - 0x48, 0x9c, 0x15, 0x24, 0xd1, 0x48, 0x67, 0x37, 0x52, 0x62, 0x12, 0x9b, 0x39, 0x2e, 0x8f, 0xa6, - 0x5f, 0x98, 0x88, 0x8e, 0x7e, 0x37, 0x47, 0x47, 0xaf, 0x2d, 0x4d, 0x6d, 0x51, 0x1a, 0xef, 0x2d, - 0xc0, 0x85, 0xb6, 0x4b, 0xe6, 0x74, 0xd7, 0x9e, 0xd3, 0x1b, 0x54, 0x8f, 0x49, 0xde, 0x17, 0x02, - 0x8d, 0x13, 0x3e, 0xfa, 0x93, 0x77, 0xc2, 0x7a, 0x11, 0x9c, 0xa5, 0x2f, 0x42, 0xf5, 0x82, 0xec, - 0x95, 0xdd, 0xeb, 0x2e, 0xdb, 0xbd, 0x7d, 0xa8, 0x1a, 0x3e, 0xca, 0xd6, 0x44, 0xab, 0xdf, 0x5e, - 0x51, 0x51, 0x4a, 0x1d, 0x63, 0x3d, 0x03, 0xce, 0x09, 0xc7, 0x25, 0x1a, 0xf1, 0x49, 0xb9, 0x44, - 0xd3, 0xf3, 0x35, 0x4b, 0x74, 0xa7, 0xd8, 0x26, 0xce, 0x8d, 0x66, 0x1c, 0x73, 0x9e, 0x6f, 0x7c, - 0x3d, 0x6f, 0x93, 0x6f, 0xe7, 0x6d, 0xf2, 0xfd, 0xbc, 0x4d, 0x8e, 0xc9, 0xa0, 0x86, 0xcf, 0xf3, - 0xc3, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa4, 0x9b, 0x1f, 0x09, 0xaf, 0x07, 0x00, 0x00, + // 820 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xdd, 0x6e, 0xd3, 0x4a, + 0x10, 0x3e, 0x8e, 0xe3, 0xfc, 0x4c, 0xfa, 0x77, 0x56, 0x3d, 0x95, 0x4f, 0x75, 0x14, 0x45, 0x3e, + 0xfc, 0x04, 0x84, 0x22, 0x35, 0x5c, 0xf0, 0xd3, 0x56, 0xa8, 0xa4, 0xdc, 0x15, 0xb5, 0x32, 0x11, + 0x12, 0x12, 0x5c, 0x6c, 0xec, 0x4d, 0xba, 0x22, 0xf1, 0x5a, 0xeb, 0x4d, 0x68, 0xde, 0x84, 0x1b, + 0xee, 0x78, 0x09, 0x24, 0x1e, 0x80, 0x4b, 0x1e, 0x80, 0x0b, 0x54, 0x78, 0x10, 0xe4, 0xf5, 0xda, + 0x59, 0xb7, 0x21, 0x69, 0xb9, 0xdb, 0x19, 0xef, 0x7c, 0x33, 0xf3, 0xcd, 0xec, 0x8c, 0x61, 0x55, + 0x70, 0xdc, 0xef, 0x53, 0xaf, 0x15, 0x72, 0x26, 0x18, 0xfa, 0xd7, 0x1f, 0xf7, 0x7a, 0xac, 0x85, + 0x43, 0xec, 0x9d, 0x92, 0x16, 0xe3, 0x83, 0xd6, 0x64, 0x07, 0x0f, 0xc3, 0x53, 0xbc, 0xe3, 0x50, + 0xd8, 0xea, 0xb0, 0xc0, 0xa7, 0x82, 0xb2, 0xc0, 0x65, 0x63, 0x41, 0xba, 0xac, 0x33, 0xa4, 0x24, + 0x10, 0x68, 0x03, 0xcc, 0xb7, 0x64, 0x6a, 0x1b, 0x0d, 0xa3, 0x59, 0x75, 0xe3, 0x23, 0xda, 0x87, + 0x62, 0x14, 0x12, 0xcf, 0x2e, 0x34, 0x8c, 0x66, 0xad, 0x7d, 0xa7, 0xf5, 0x5b, 0xd4, 0x56, 0x1e, + 0xd2, 0x95, 0x66, 0xce, 0x00, 0xfe, 0x39, 0x9c, 0x06, 0x78, 0x44, 0xbd, 0x0e, 0x0b, 0xfa, 0x74, + 0xb0, 0xc0, 0xd3, 0x5e, 0xce, 0x53, 0x73, 0x81, 0xa7, 0x1c, 0xa2, 0x72, 0xf4, 0x06, 0x36, 0xba, + 0x78, 0xb0, 0x2c, 0x9b, 0x07, 0x39, 0x1f, 0xff, 0x2f, 0xf0, 0x91, 0x82, 0x29, 0xf8, 0x9f, 0x06, + 0xac, 0xe5, 0x13, 0x44, 0xdb, 0x50, 0x09, 0x39, 0x65, 0x9c, 0x8a, 0xc4, 0x85, 0xe5, 0x66, 0x32, + 0xb2, 0xa1, 0x4c, 0x02, 0xdc, 0x1b, 0x12, 0x5f, 0xba, 0xaa, 0xb8, 0xa9, 0x88, 0x36, 0xc1, 0xea, + 0x33, 0xee, 0x11, 0xdb, 0x94, 0xfa, 0x44, 0x88, 0xef, 0xf3, 0x71, 0x20, 0xe8, 0x88, 0xd8, 0xc5, + 0xe4, 0xbe, 0x12, 0xd3, 0x1c, 0xac, 0x59, 0x0e, 0x9b, 0x60, 0x45, 0x1e, 0x0b, 0x89, 0x5d, 0x92, + 0xba, 0x44, 0x40, 0x75, 0x00, 0x2f, 0x8d, 0x2f, 0xb2, 0xcb, 0x0d, 0xb3, 0x59, 0x75, 0x35, 0x0d, + 0xba, 0x01, 0xab, 0x9e, 0xe4, 0xeb, 0x25, 0xe1, 0x11, 0x65, 0x81, 0x5d, 0x91, 0xd6, 0x79, 0xa5, + 0xf3, 0xd9, 0x80, 0xd5, 0x1c, 0xbb, 0x73, 0x38, 0xcc, 0xfc, 0x17, 0x74, 0xff, 0x97, 0xf0, 0xcd, + 0x39, 0xf8, 0x3a, 0x2f, 0xc5, 0x3c, 0x2f, 0x1d, 0x28, 0x27, 0x57, 0x23, 0xdb, 0x6a, 0x98, 0x4b, + 0x5a, 0xed, 0x78, 0x42, 0x38, 0xa7, 0x3e, 0x51, 0x1d, 0x90, 0x5a, 0x3a, 0x9f, 0x4c, 0x58, 0xcb, + 0x7f, 0x43, 0x08, 0x8a, 0x11, 0xf5, 0x89, 0x4a, 0x40, 0x9e, 0xd1, 0x7f, 0x50, 0xc5, 0xbe, 0xcf, + 0x49, 0x14, 0x91, 0xc8, 0x2e, 0x48, 0xaa, 0x66, 0x0a, 0x74, 0x0f, 0xfe, 0x0e, 0x39, 0x9b, 0x50, + 0x9f, 0xf0, 0x83, 0xec, 0x96, 0x29, 0x6f, 0x5d, 0xfe, 0x80, 0x5e, 0x01, 0x84, 0x98, 0xe3, 0x11, + 0x11, 0x84, 0x47, 0x76, 0x51, 0x86, 0xfe, 0xe8, 0xca, 0xa1, 0xb7, 0x4e, 0x32, 0xdb, 0x67, 0x81, + 0xe0, 0x53, 0x57, 0x03, 0x43, 0x0e, 0xac, 0xe0, 0x30, 0x1c, 0x52, 0x0f, 0x27, 0x45, 0xb5, 0x64, + 0x0c, 0x39, 0x5d, 0xdc, 0x84, 0x11, 0xe1, 0x13, 0xea, 0x91, 0xc8, 0x2e, 0xc9, 0xef, 0x99, 0x1c, + 0xa7, 0x2e, 0xa6, 0x21, 0xb1, 0xcb, 0x49, 0xea, 0xf1, 0x59, 0x2f, 0x40, 0x25, 0x5f, 0x80, 0x27, + 0x60, 0x8d, 0xb0, 0xf0, 0x4e, 0xed, 0xea, 0xd5, 0x5f, 0xfa, 0xf3, 0xd8, 0xc0, 0x4d, 0xec, 0xb6, + 0xf7, 0x61, 0xfd, 0x42, 0x36, 0xf3, 0x9b, 0x67, 0x82, 0x87, 0xe3, 0xac, 0x79, 0xa4, 0xf0, 0xb8, + 0xf0, 0xd0, 0x70, 0x3e, 0x16, 0xb4, 0x17, 0x26, 0x81, 0xd1, 0x01, 0x94, 0x55, 0x59, 0x24, 0x44, + 0xad, 0x7d, 0x7b, 0x41, 0x50, 0xaa, 0x24, 0x49, 0x48, 0xa9, 0x1d, 0x3a, 0x84, 0xb2, 0xe2, 0x43, + 0xbd, 0xf9, 0xbb, 0x0b, 0x20, 0x8e, 0x68, 0x24, 0x5e, 0x08, 0x4e, 0x83, 0x81, 0x42, 0x51, 0xa6, + 0xe8, 0x08, 0x6a, 0x1a, 0xeb, 0xb2, 0xb5, 0xaf, 0x87, 0xa4, 0x9b, 0xa3, 0x5d, 0xb0, 0x64, 0x95, + 0x55, 0xb7, 0xdc, 0x5c, 0x80, 0x23, 0x09, 0x55, 0x2c, 0x4b, 0x1b, 0xa7, 0x0b, 0x2b, 0x7a, 0xa6, + 0x71, 0x03, 0xbc, 0xa3, 0x43, 0xdf, 0xc3, 0xdc, 0x57, 0x3c, 0x67, 0x72, 0xdc, 0x00, 0x1e, 0xe5, + 0xbe, 0xe2, 0x5a, 0x9e, 0xe3, 0x02, 0x90, 0x33, 0xec, 0x09, 0xf5, 0x3e, 0x13, 0xc1, 0x39, 0x86, + 0xf5, 0x0b, 0x21, 0xa3, 0x3d, 0xb0, 0x58, 0x40, 0x58, 0xdf, 0x36, 0x64, 0x94, 0xb7, 0x16, 0x44, + 0xa9, 0x67, 0x9a, 0x18, 0x39, 0x1f, 0x0c, 0xa8, 0xe9, 0x68, 0x99, 0x5b, 0x43, 0x73, 0x8b, 0xb6, + 0xa0, 0x14, 0x72, 0xd2, 0xa7, 0x67, 0x2a, 0x44, 0x25, 0xc5, 0xb7, 0x39, 0x19, 0x90, 0xb3, 0x34, + 0x48, 0x29, 0xc4, 0xbd, 0x1b, 0x30, 0x32, 0x0a, 0xc5, 0x54, 0x0e, 0x8f, 0xaa, 0x9b, 0x8a, 0x12, + 0x5d, 0xea, 0x2d, 0x85, 0x2e, 0xb5, 0x3a, 0x35, 0xa5, 0x3c, 0x35, 0xce, 0x6b, 0x80, 0x19, 0xb7, + 0x73, 0x97, 0x91, 0xd6, 0xa7, 0xd7, 0xc8, 0x5e, 0x1a, 0x39, 0xdf, 0x0c, 0xa8, 0xa4, 0x0b, 0xe4, + 0x0f, 0xf7, 0x84, 0xb6, 0x11, 0xcc, 0xb9, 0x1b, 0xa1, 0x38, 0x0b, 0xf6, 0xd2, 0xec, 0xb5, 0xe6, + 0xcd, 0xde, 0x6c, 0xf3, 0x94, 0xf4, 0xcd, 0xd3, 0x86, 0xa2, 0xc0, 0x83, 0x64, 0x63, 0xd4, 0xda, + 0xf5, 0x25, 0x1b, 0x51, 0xde, 0x75, 0x04, 0x98, 0x5d, 0x2c, 0x47, 0x6b, 0x80, 0x47, 0xd9, 0x68, + 0x8d, 0xcf, 0x4b, 0x46, 0xeb, 0x6e, 0x3a, 0x63, 0xcc, 0x6b, 0x75, 0xbe, 0xb4, 0x79, 0x8a, 0xbe, + 0x9c, 0xd7, 0x8d, 0xaf, 0xe7, 0x75, 0xe3, 0xfb, 0x79, 0xdd, 0x78, 0xff, 0xa3, 0xfe, 0xd7, 0x89, + 0xd1, 0x2b, 0xc9, 0x7f, 0x9d, 0xfb, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x4e, 0x95, 0x23, 0x1d, + 0xfc, 0x08, 0x00, 0x00, +} + +func (m *ConditionRouteToClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ConditionRouteToClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConditionRouteToClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Spec != nil { + { + size, err := m.Spec.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTraffic(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintTraffic(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DynamicConfigToClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DynamicConfigToClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DynamicConfigToClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Spec != nil { + { + size, err := m.Spec.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTraffic(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintTraffic(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TagRouteToClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TagRouteToClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TagRouteToClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Spec != nil { + { + size, err := m.Spec.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTraffic(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintTraffic(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } func (m *ConditionRoute) Marshal() (dAtA []byte, err error) { @@ -1470,17 +1789,27 @@ func (m *TagRoute) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTraffic(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } } - if len(m.ConfigVersion) > 0 { - i -= len(m.ConfigVersion) - copy(dAtA[i:], m.ConfigVersion) - i = encodeVarintTraffic(dAtA, i, uint64(len(m.ConfigVersion))) + if m.Force { i-- - dAtA[i] = 0x2a - } - if len(m.Key) > 0 { + if m.Force { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + if len(m.ConfigVersion) > 0 { + i -= len(m.ConfigVersion) + copy(dAtA[i:], m.ConfigVersion) + i = encodeVarintTraffic(dAtA, i, uint64(len(m.ConfigVersion))) + i-- + dAtA[i] = 0x2a + } + if len(m.Key) > 0 { i -= len(m.Key) copy(dAtA[i:], m.Key) i = encodeVarintTraffic(dAtA, i, uint64(len(m.Key))) @@ -1583,6 +1912,66 @@ func encodeVarintTraffic(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *ConditionRouteToClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + if m.Spec != nil { + l = m.Spec.Size() + n += 1 + l + sovTraffic(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *DynamicConfigToClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + if m.Spec != nil { + l = m.Spec.Size() + n += 1 + l + sovTraffic(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *TagRouteToClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + if m.Spec != nil { + l = m.Spec.Size() + n += 1 + l + sovTraffic(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *ConditionRoute) Size() (n int) { if m == nil { return 0 @@ -1783,136 +2172,496 @@ func (m *ListStringMatch) Size() (n int) { n += 1 + l + sovTraffic(uint64(l)) } } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *StringMatch) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Exact) - if l > 0 { - n += 1 + l + sovTraffic(uint64(l)) - } - l = len(m.Prefix) - if l > 0 { - n += 1 + l + sovTraffic(uint64(l)) - } - l = len(m.Regex) - if l > 0 { - n += 1 + l + sovTraffic(uint64(l)) - } - l = len(m.Noempty) - if l > 0 { - n += 1 + l + sovTraffic(uint64(l)) - } - l = len(m.Empty) - if l > 0 { - n += 1 + l + sovTraffic(uint64(l)) - } - l = len(m.Wildcard) - if l > 0 { - n += 1 + l + sovTraffic(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *StringMatch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Exact) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + l = len(m.Prefix) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + l = len(m.Regex) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + l = len(m.Noempty) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + l = len(m.Empty) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + l = len(m.Wildcard) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *ParamMatch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + if m.Value != nil { + l = m.Value.Size() + n += 1 + l + sovTraffic(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *TagRoute) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Priority != 0 { + n += 1 + sovTraffic(uint64(m.Priority)) + } + if m.Enabled { + n += 2 + } + if m.Runtime { + n += 2 + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + l = len(m.ConfigVersion) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + if m.Force { + n += 2 + } + if len(m.Tags) > 0 { + for _, e := range m.Tags { + l = e.Size() + n += 1 + l + sovTraffic(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Tag) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTraffic(uint64(l)) + } + if len(m.Addresses) > 0 { + for _, s := range m.Addresses { + l = len(s) + n += 1 + l + sovTraffic(uint64(l)) + } + } + if len(m.Match) > 0 { + for _, e := range m.Match { + l = e.Size() + n += 1 + l + sovTraffic(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovTraffic(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTraffic(x uint64) (n int) { + return sovTraffic(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ConditionRouteToClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraffic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ConditionRouteToClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConditionRouteToClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraffic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTraffic + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTraffic + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Spec", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraffic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTraffic + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTraffic + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Spec == nil { + m.Spec = &ConditionRoute{} + } + if err := m.Spec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTraffic(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTraffic + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DynamicConfigToClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraffic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DynamicConfigToClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DynamicConfigToClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraffic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTraffic + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTraffic + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Spec", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraffic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTraffic + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTraffic + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Spec == nil { + m.Spec = &DynamicConfig{} + } + if err := m.Spec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTraffic(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTraffic + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } -func (m *ParamMatch) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovTraffic(uint64(l)) - } - if m.Value != nil { - l = m.Value.Size() - n += 1 + l + sovTraffic(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) + if iNdEx > l { + return io.ErrUnexpectedEOF } - return n + return nil } - -func (m *TagRoute) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Priority != 0 { - n += 1 + sovTraffic(uint64(m.Priority)) - } - if m.Enabled { - n += 2 - } - if m.Runtime { - n += 2 - } - l = len(m.Key) - if l > 0 { - n += 1 + l + sovTraffic(uint64(l)) - } - l = len(m.ConfigVersion) - if l > 0 { - n += 1 + l + sovTraffic(uint64(l)) - } - if len(m.Tags) > 0 { - for _, e := range m.Tags { - l = e.Size() - n += 1 + l + sovTraffic(uint64(l)) +func (m *TagRouteToClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraffic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Tag) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovTraffic(uint64(l)) - } - if len(m.Addresses) > 0 { - for _, s := range m.Addresses { - l = len(s) - n += 1 + l + sovTraffic(uint64(l)) + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TagRouteToClient: wiretype end group for non-group") } - } - if len(m.Match) > 0 { - for _, e := range m.Match { - l = e.Size() - n += 1 + l + sovTraffic(uint64(l)) + if fieldNum <= 0 { + return fmt.Errorf("proto: TagRouteToClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraffic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTraffic + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTraffic + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Spec", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraffic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTraffic + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTraffic + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Spec == nil { + m.Spec = &TagRoute{} + } + if err := m.Spec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTraffic(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTraffic + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy } } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} -func sovTraffic(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTraffic(x uint64) (n int) { - return sovTraffic(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } func (m *ConditionRoute) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -3739,6 +4488,26 @@ func (m *TagRoute) Unmarshal(dAtA []byte) error { m.ConfigVersion = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Force", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTraffic + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Force = bool(v != 0) + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Tags", wireType) } diff --git a/api/resource/v1alpha1/traffic.proto b/api/resource/v1alpha1/traffic.proto index 9849ab98c..e81ace210 100644 --- a/api/resource/v1alpha1/traffic.proto +++ b/api/resource/v1alpha1/traffic.proto @@ -22,6 +22,21 @@ package dubbo.apache.org.v1alpha1; option java_multiple_files = true; +message ConditionRouteToClient { + string key = 1; + ConditionRoute spec = 2; +} + +message DynamicConfigToClient { + string key = 1; + DynamicConfig spec = 2; +} + +message TagRouteToClient { + string key = 1; + TagRoute spec = 2; +} + message ConditionRoute { int32 priority = 1; bool enabled = 2; @@ -90,7 +105,8 @@ message TagRoute { bool runtime = 3; string key = 4; string configVersion = 5; - repeated Tag tags = 6; + bool force = 6; + repeated Tag tags = 7; } message Tag { diff --git a/conf/admin.yml b/conf/admin.yml index 33098601e..f02f216f8 100644 --- a/conf/admin.yml +++ b/conf/admin.yml @@ -30,6 +30,7 @@ security: enable-oidc-check: true webhook-port: 30080 webhook-allow-on-err: true + is-trust-anyone: false kube-config: namespace: dubbo-system service-name: dubbo-cp diff --git a/go.mod b/go.mod index d5ebbf2da..b0cb79f88 100644 --- a/go.mod +++ b/go.mod @@ -20,12 +20,14 @@ go 1.20 require ( dubbo.apache.org/dubbo-go/v3 v3.1.0 github.com/apache/dubbo-go-hessian2 v1.12.2 + github.com/cenkalti/backoff v2.2.1+incompatible github.com/davecgh/go-spew v1.1.1 github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 github.com/dubbogo/gost v1.14.0 github.com/dubbogo/grpc-go v1.42.10 github.com/dubbogo/triple v1.2.2-rc3 github.com/evanphx/json-patch/v5 v5.6.0 + github.com/ghodss/yaml v1.0.0 github.com/gin-gonic/gin v1.9.1 github.com/gogo/protobuf v1.3.2 github.com/golang-jwt/jwt/v4 v4.5.0 @@ -46,7 +48,6 @@ require ( github.com/stretchr/testify v1.8.3 github.com/tidwall/gjson v1.14.4 github.com/vcraescu/go-paginator v1.0.0 - go.opencensus.io v0.24.0 go.uber.org/atomic v1.10.0 go.uber.org/zap v1.24.0 golang.org/x/net v0.10.0 @@ -70,7 +71,6 @@ require ( require ( cloud.google.com/go/compute v1.19.1 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - contrib.go.opencensus.io/exporter/prometheus v0.4.1 // indirect github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/BurntSushi/toml v1.2.1 // indirect @@ -124,8 +124,6 @@ require ( github.com/go-co-op/gocron v1.9.0 // indirect github.com/go-errors/errors v1.4.2 // indirect github.com/go-gorp/gorp/v3 v3.0.5 // indirect - github.com/go-kit/log v0.2.1 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect @@ -139,13 +137,11 @@ require ( github.com/go-sql-driver/mysql v1.7.0 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/goccy/go-json v0.10.2 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.0.1 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601 // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/gosuri/uitable v0.0.4 // indirect @@ -196,7 +192,6 @@ require ( github.com/morikuni/aec v1.0.0 // indirect github.com/mschoch/smat v0.2.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/nacos-group/nacos-sdk-go v1.1.4 // indirect github.com/nacos-group/nacos-sdk-go/v2 v2.2.2 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852 // indirect @@ -208,11 +203,10 @@ require ( github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pierrec/lz4 v2.5.2+incompatible // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/polarismesh/polaris-go v1.3.0 // indirect + github.com/polarismesh/polaris-go v1.4.0 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/prometheus/client_model v0.4.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect - github.com/prometheus/statsd_exporter v0.21.0 // indirect github.com/robfig/cron/v3 v3.0.1 // indirect github.com/rubenv/sql-migrate v1.3.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect @@ -251,7 +245,6 @@ require ( golang.org/x/term v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.9.1 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/go.sum b/go.sum index a3b7f93aa..9f6eee542 100644 --- a/go.sum +++ b/go.sum @@ -367,11 +367,7 @@ cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1V cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= cloud.google.com/go/workflows v1.8.0/go.mod h1:ysGhmEajwZxGn1OhGOGKsTXc5PyxOc0vfKf5Af+to4M= cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT3ujaO/WwSA= -contrib.go.opencensus.io/exporter/prometheus v0.4.1 h1:oObVeKo2NxpdF/fIfrPsNj6K0Prg0R0mHM+uANlYMiM= -contrib.go.opencensus.io/exporter/prometheus v0.4.1/go.mod h1:t9wvfitlUjGXG2IXAZsuFq26mDGid/JwCEXp+gTG/9U= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -dubbo.apache.org/dubbo-go/v3 v3.0.5 h1:14GKXcCJ4/Z5l3KQiQJ7xDoUNlZs0uo5OMi41ykNn+o= -dubbo.apache.org/dubbo-go/v3 v3.0.5/go.mod h1:87jr5U/NZGMkzGLsmbwXTxVh8h2MnaGOjHj/aHwf0ZM= dubbo.apache.org/dubbo-go/v3 v3.1.0 h1:Bb9NvPNoLEwzY65ayPgEcqq952fzgKfTpmlgOgc2Fmc= dubbo.apache.org/dubbo-go/v3 v3.1.0/go.mod h1:IPpAfDe/FaEGDT4AuVlxhupTPbdbeqnBINvyL+iFat0= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic= @@ -402,7 +398,6 @@ github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8 github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Microsoft/hcsshim v0.10.0-rc.7 h1:HBytQPxcv8Oy4244zbQbe6hnOnx544eL5QPUqhJldz8= -github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/RageCage64/multilinediff v0.2.0 h1:yNSpSF5NXIrmo6bRIgO4Q0g7SXqFD4j/WEcBE+BdCFY= github.com/RageCage64/multilinediff v0.2.0/go.mod h1:pKr+KLgP0gvRzA+yv0/IUaYQuBYN1ucWysvsL58aMP0= @@ -432,13 +427,10 @@ github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDH github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 h1:PpfENOj/vPfhhy9N2OFRjpue0hjM5XqAp2thFmkXXIk= github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704/go.mod h1:RcDobYh8k5VP6TNybz9m++gL3ijVI5wueVr0EM10VsU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/dubbo-getty v1.4.9-0.20221022181821-4dc6252ce98c/go.mod h1:6qmrqBSPGs3B35zwEuGhEYNVsx1nfGT/xzV2yOt2amM= github.com/apache/dubbo-getty v1.4.9 h1:Y8l1EYJqIc7BnmyfYtvG4H4Nmu4v7P1uS31fFQGdJzM= github.com/apache/dubbo-getty v1.4.9/go.mod h1:6qmrqBSPGs3B35zwEuGhEYNVsx1nfGT/xzV2yOt2amM= github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/dubbo-go-hessian2 v1.9.3/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= -github.com/apache/dubbo-go-hessian2 v1.11.4/go.mod h1:QP9Tc0w/B/mDopjusebo/c7GgEfl6Lz8jeuFg8JA6yw= -github.com/apache/dubbo-go-hessian2 v1.11.5/go.mod h1:QP9Tc0w/B/mDopjusebo/c7GgEfl6Lz8jeuFg8JA6yw= github.com/apache/dubbo-go-hessian2 v1.12.2 h1:2/56JRPng2lnLziJF3fqmSgsg28Yt1a5YZ5RX+jHDGs= github.com/apache/dubbo-go-hessian2 v1.12.2/go.mod h1:QP9Tc0w/B/mDopjusebo/c7GgEfl6Lz8jeuFg8JA6yw= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= @@ -542,7 +534,6 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -599,7 +590,6 @@ github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fAD github.com/dubbogo/gost v1.11.18/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/gost v1.12.6-0.20220824084206-300e27e9e524/go.mod h1:0YHTGJtjHiYlWtVEkZnyrvhr7rR+23GczNaJrgc2v38= github.com/dubbogo/gost v1.13.1/go.mod h1:9HMXBv+WBMRWhF3SklpqDjkS/01AKWm2SrVdz/A0xJI= -github.com/dubbogo/gost v1.13.2/go.mod h1:2vbZ7bo4PgR7stX1He5XBvQgP6wx4A7q7IFHZU3hVmE= github.com/dubbogo/gost v1.14.0 h1:yc5YfozvUBAChAox8H7CkmHb6/TvF6cKdqZNJNv2jdE= github.com/dubbogo/gost v1.14.0/go.mod h1:YP28JweR+hhJdikP3bZ3bVKUWWI313xX1rgLaEE0FvQ= github.com/dubbogo/grpc-go v1.42.9/go.mod h1:F1T9hnUvYGW4JLK1QNriavpOkhusU677ovPzLkk6zHM= @@ -608,7 +598,6 @@ github.com/dubbogo/grpc-go v1.42.10/go.mod h1:JMkPt1mIHL96GAFeYsMoMjew6f1ROKycik github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.4/go.mod h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc= github.com/dubbogo/triple v1.0.9/go.mod h1:1t9me4j4CTvNDcsMZy6/OGarbRyAUSY0tFXGXHCp7Iw= -github.com/dubbogo/triple v1.2.2-rc2/go.mod h1:8qprF2uJX82IE5hjiIuswp416sEr0oL/+bb7IjiizYs= github.com/dubbogo/triple v1.2.2-rc3 h1:9rxLqru35MmJkypCHJMiZb1VzwH+zmbPBend9Cq+VOI= github.com/dubbogo/triple v1.2.2-rc3/go.mod h1:9pgEahtmsY/avYJp3dzUQE8CMMVe1NtGBmUhfICKLJk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -672,6 +661,7 @@ github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbS github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -693,14 +683,11 @@ github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= -github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= github.com/go-ldap/ldap/v3 v3.1.10/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -719,16 +706,12 @@ github.com/go-openapi/jsonreference v0.20.1 h1:FBLnyygC4/IZZr893oiomc9XaghoveYTr github.com/go-openapi/jsonreference v0.20.1/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-playground/validator/v10 v10.12.0/go.mod h1:hCAPuzYvKdP33pxWa+2+6AIKXEKqjIUyqsNCtbsSJrA= github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= @@ -779,7 +762,6 @@ github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4er github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= @@ -894,8 +876,6 @@ github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw= github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601 h1:mrEEilTAUmaAORhssPPkxj84TsHrPMLBGW2Z4SoTxm8= -github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601/go.mod h1:Qcp2HIAYhR7mNUVSIxZww3Guk4it82ghYcEXIAk+QT0= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= @@ -1098,7 +1078,6 @@ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk= github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw= -github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/leodido/go-urn v1.2.2/go.mod h1:kUaIbLZWttglzwNuG0pgsh5vuV6u2YcGBYz1hIPjtOQ= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= @@ -1216,11 +1195,7 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= -github.com/nacos-group/nacos-sdk-go v1.1.3/go.mod h1:cBv9wy5iObs7khOqov1ERFQrCuTR4ILpgaiaVMxEmGI= -github.com/nacos-group/nacos-sdk-go v1.1.4 h1:qyrZ7HTWM4aeymFfqnbgNRERh7TWuER10pCB7ddRcTY= -github.com/nacos-group/nacos-sdk-go v1.1.4/go.mod h1:cBv9wy5iObs7khOqov1ERFQrCuTR4ILpgaiaVMxEmGI= github.com/nacos-group/nacos-sdk-go/v2 v2.1.2/go.mod h1:ys/1adWeKXXzbNWfRNbaFlX/t6HVLWdpsNDvmoWTw0g= github.com/nacos-group/nacos-sdk-go/v2 v2.2.2 h1:FI+7vr1fvCA4jbgx36KezmP3zlU/WoP/7wAloaSd1Ew= github.com/nacos-group/nacos-sdk-go/v2 v2.2.2/go.mod h1:ys/1adWeKXXzbNWfRNbaFlX/t6HVLWdpsNDvmoWTw0g= @@ -1295,8 +1270,9 @@ github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/polarismesh/polaris-go v1.3.0 h1:KZKX//ow4OPPoS5+s7h07ptprg+2AcNVGrN6WakC9QM= github.com/polarismesh/polaris-go v1.3.0/go.mod h1:HsN0ierETIujHpmnnYJ3qkwQw4QGAECuHvBZTDaw1tI= +github.com/polarismesh/polaris-go v1.4.0 h1:aHvrqBxDKHhPwO47/tX2Ge0+2bgrJ/10O5GcagBVwPw= +github.com/polarismesh/polaris-go v1.4.0/go.mod h1:TjTxtDfw1e8n/e86UPgQ8thGZDo4oPkfmG+riiynTAA= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= @@ -1340,7 +1316,6 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.28.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= @@ -1358,8 +1333,6 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/prometheus/statsd_exporter v0.21.0 h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf33yKI+pyX6T8= -github.com/prometheus/statsd_exporter v0.21.0/go.mod h1:rbT83sZq2V+p73lHhPZfMc3MLCHmSHelCh9hSGYNLTQ= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= @@ -1407,7 +1380,6 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9 github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/soheilhy/cmux v0.1.5-0.20210205191134-5ec6847320e5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= -github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= @@ -1557,7 +1529,6 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= -go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.40.0 h1:5jD3teb4Qh7mx/nfzq4jO2WFFpvXD0vYWFDrdvNWmXk= go.opentelemetry.io/otel v1.11.0/go.mod h1:H2KtuEphyMvlhZ+F7tg9GRhAOe60moNx61Ex+WmiKkk= go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= @@ -1621,7 +1592,6 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= @@ -1640,6 +1610,7 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5 h1:FR+oGxGfbQu1d+jglI3rCkjAjUnhRSZcUxr+DqlDLNo= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= @@ -1727,7 +1698,6 @@ golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211105192438-b53810dc28af/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -2017,7 +1987,6 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= -golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2029,6 +1998,7 @@ golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNq gomodules.xyz/jsonpatch/v2 v2.3.0 h1:8NFhfS6gzxNqjLIYnZxg319wZ5Qjnx4m/CcX+Klzazc= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= +gonum.org/v1/gonum v0.8.2 h1:CCXrcPKiGGotvnN6jfUsKk4rRqm7q09/YbKb5xCEvtM= gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= @@ -2257,7 +2227,6 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= diff --git a/pkg/authority/server/authority.go b/pkg/authority/server/authority.go index 63f97f19f..387184862 100644 --- a/pkg/authority/server/authority.go +++ b/pkg/authority/server/authority.go @@ -49,13 +49,13 @@ func (s *AuthorityService) Start(stop <-chan struct{}) error { errChan := make(chan error) if s.Options.KubeConfig.InPodEnv { go func() { - err := s.WebhookServer.Server.ListenAndServe() + err := s.WebhookServer.Server.ListenAndServeTLS("", "") if err != nil { switch err { case http.ErrServerClosed: - logger.Sugar().Info("shutting down HTTP Server") + logger.Sugar().Info("[Webhook] shutting down HTTP Server") default: - logger.Sugar().Error(err, "could not start an HTTP Server") + logger.Sugar().Error(err, "[Webhook] could not start an HTTP Server") errChan <- err } } @@ -63,7 +63,7 @@ func (s *AuthorityService) Start(stop <-chan struct{}) error { s.CertClient.UpdateWebhookConfig(s.Options, s.CertStorage) select { case <-stop: - logger.Sugar().Info("stopping admin") + logger.Sugar().Info("[Webhook] stopping Authority") if s.WebhookServer.Server != nil { return s.WebhookServer.Server.Shutdown(context.Background()) } @@ -102,7 +102,7 @@ func (s *AuthorityService) CreateIdentity( p, _ := peer.FromContext(c) endpoint, err := endpoint.ExactEndpoint(c, s.CertStorage, s.Options, s.CertClient) if err != nil { - logger.Sugar().Warnf("Failed to exact endpoint from context: %v. RemoteAddr: %s", err, p.Addr.String()) + logger.Sugar().Warnf("[Authority] Failed to exact endpoint from context: %v. RemoteAddr: %s", err, p.Addr.String()) return &ca.IdentityResponse{ Success: false, @@ -112,7 +112,7 @@ func (s *AuthorityService) CreateIdentity( certPem, err := cert.SignFromCSR(csr, endpoint, s.CertStorage.GetAuthorityCert(), s.Options.Security.CertValidity) if err != nil { - logger.Sugar().Warnf("Failed to sign certificate from csr: %v. RemoteAddr: %s", err, p.Addr.String()) + logger.Sugar().Warnf("[Authority] Failed to sign certificate from csr: %v. RemoteAddr: %s", err, p.Addr.String()) return &ca.IdentityResponse{ Success: false, @@ -120,11 +120,11 @@ func (s *AuthorityService) CreateIdentity( }, nil } - logger.Sugar().Infof("Success to sign certificate from csr. RemoteAddr: %s", p.Addr.String()) + logger.Sugar().Infof("[Authority] Success to sign certificate from csr. RemoteAddr: %s", p.Addr.String()) token, err := jwt.NewClaims(endpoint.SpiffeID, endpoint.ToString(), endpoint.ID, s.Options.Security.CertValidity).Sign(s.CertStorage.GetAuthorityCert().PrivateKey) if err != nil { - logger.Sugar().Warnf("Failed to sign jwt token: %v. RemoteAddr: %s", err, p.Addr.String()) + logger.Sugar().Warnf("[Authority] Failed to sign jwt token: %v. RemoteAddr: %s", err, p.Addr.String()) return &ca.IdentityResponse{ Success: false, diff --git a/pkg/config/app/dubbo-cp/dubbo-cp.default.yaml b/pkg/config/app/dubbo-cp/dubbo-cp.default.yaml index 127b9e8ef..3cc9f0d06 100644 --- a/pkg/config/app/dubbo-cp/dubbo-cp.default.yaml +++ b/pkg/config/app/dubbo-cp/dubbo-cp.default.yaml @@ -30,6 +30,7 @@ security: enable-oidc-check: true webhook-port: 30080 webhook-allow-on-err: true + is-trust-anyone: false kube-config: namespace: dubbo-system service-name: dubbo-ca diff --git a/pkg/core/cert/provider/client.go b/pkg/core/cert/provider/client.go index 3f525ecd3..b66f3ff74 100644 --- a/pkg/core/cert/provider/client.go +++ b/pkg/core/cert/provider/client.go @@ -55,7 +55,7 @@ func NewClient(kubeClient kubernetes.Interface) Client { func (c *ClientImpl) GetAuthorityCert(namespace string) (string, string) { s, err := c.kubeClient.CoreV1().Secrets(namespace).Get(context.TODO(), "dubbo-ca-secret", metav1.GetOptions{}) if err != nil { - logger.Sugar().Warnf("Unable to get authority cert secret from kubernetes. " + err.Error()) + logger.Sugar().Warnf("[Authority] Unable to get authority cert secret from kubernetes. " + err.Error()) } return string(s.Data["cert.pem"]), string(s.Data["pri.pem"]) } @@ -63,7 +63,7 @@ func (c *ClientImpl) GetAuthorityCert(namespace string) (string, string) { func (c *ClientImpl) UpdateAuthorityCert(cert string, pri string, namespace string) { s, err := c.kubeClient.CoreV1().Secrets(namespace).Get(context.TODO(), "dubbo-ca-secret", metav1.GetOptions{}) if err != nil { - logger.Sugar().Warnf("Unable to get ca secret from kubernetes. Will try to create. " + err.Error()) + logger.Sugar().Warnf("[Authority] Unable to get ca secret from kubernetes. Will try to create. " + err.Error()) s = &v1.Secret{ Data: map[string][]byte{ "cert.pem": []byte(cert), @@ -73,14 +73,14 @@ func (c *ClientImpl) UpdateAuthorityCert(cert string, pri string, namespace stri s.Name = "dubbo-ca-secret" _, err = c.kubeClient.CoreV1().Secrets(namespace).Create(context.TODO(), s, metav1.CreateOptions{}) if err != nil { - logger.Sugar().Warnf("Failed to create ca secret to kubernetes. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to create ca secret to kubernetes. " + err.Error()) } else { - logger.Sugar().Info("Create ca secret to kubernetes success. ") + logger.Sugar().Info("[Authority] Create ca secret to kubernetes success. ") } } if string(s.Data["cert.pem"]) == cert && string(s.Data["pri.pem"]) == pri { - logger.Sugar().Info("Ca secret in kubernetes is already the newest vesion.") + logger.Sugar().Info("[Authority] Ca secret in kubernetes is already the newest version.") return } @@ -88,16 +88,16 @@ func (c *ClientImpl) UpdateAuthorityCert(cert string, pri string, namespace stri s.Data["pri.pem"] = []byte(pri) _, err = c.kubeClient.CoreV1().Secrets(namespace).Update(context.TODO(), s, metav1.UpdateOptions{}) if err != nil { - logger.Sugar().Warnf("Failed to update ca secret to kubernetes. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to update ca secret to kubernetes. " + err.Error()) } else { - logger.Sugar().Info("Update ca secret to kubernetes success. ") + logger.Sugar().Info("[Authority] Update ca secret to kubernetes success. ") } } func (c *ClientImpl) UpdateAuthorityPublicKey(cert string) bool { ns, err := c.kubeClient.CoreV1().Namespaces().List(context.TODO(), metav1.ListOptions{}) if err != nil { - logger.Sugar().Warnf("Failed to get namespaces. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to get namespaces. " + err.Error()) return false } for _, n := range ns.Items { @@ -106,7 +106,7 @@ func (c *ClientImpl) UpdateAuthorityPublicKey(cert string) bool { } cm, err := c.kubeClient.CoreV1().ConfigMaps(n.Name).Get(context.TODO(), "dubbo-ca-cert", metav1.GetOptions{}) if err != nil { - logger.Sugar().Warnf("Unable to find dubbo-ca-cert in " + n.Name + ". Will create config map. " + err.Error()) + logger.Sugar().Warnf("[Authority] Unable to find dubbo-ca-cert in " + n.Name + ". Will create config map. " + err.Error()) cm = &v1.ConfigMap{ Data: map[string]string{ "ca.crt": cert, @@ -115,23 +115,23 @@ func (c *ClientImpl) UpdateAuthorityPublicKey(cert string) bool { cm.Name = "dubbo-ca-cert" _, err = c.kubeClient.CoreV1().ConfigMaps(n.Name).Create(context.TODO(), cm, metav1.CreateOptions{}) if err != nil { - logger.Sugar().Warnf("Failed to create config map for " + n.Name + ". " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to create config map for " + n.Name + ". " + err.Error()) return false } else { - logger.Sugar().Info("Create ca config map for " + n.Name + " success.") + logger.Sugar().Info("[Authority] Create ca config map for " + n.Name + " success.") } } if cm.Data["ca.crt"] == cert { - logger.Sugar().Info("Ignore override ca to " + n.Name + ". Cause: Already exist.") + logger.Sugar().Info("[Authority] Ignore override ca to " + n.Name + ". Cause: Already exist.") continue } cm.Data["ca.crt"] = cert _, err = c.kubeClient.CoreV1().ConfigMaps(n.Name).Update(context.TODO(), cm, metav1.UpdateOptions{}) if err != nil { - logger.Sugar().Warnf("Failed to update config map for " + n.Name + ". " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to update config map for " + n.Name + ". " + err.Error()) return false } else { - logger.Sugar().Info("Update ca config map for " + n.Name + " success.") + logger.Sugar().Info("[Authority] Update ca config map for " + n.Name + " success.") } } return true @@ -140,7 +140,7 @@ func (c *ClientImpl) UpdateAuthorityPublicKey(cert string) bool { func (c *ClientImpl) GetNamespaceLabels(namespace string) map[string]string { ns, err := c.kubeClient.CoreV1().Namespaces().Get(context.TODO(), namespace, metav1.GetOptions{}) if err != nil { - logger.Sugar().Warnf("Failed to validate token. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to validate token. " + err.Error()) return map[string]string{} } if ns.Labels != nil { @@ -169,18 +169,18 @@ func (c *ClientImpl) VerifyServiceAccount(token string, authorizationType string reviewRes, err := c.kubeClient.AuthenticationV1().TokenReviews().Create( context.TODO(), tokenReview, metav1.CreateOptions{}) if err != nil { - logger.Sugar().Warnf("Failed to validate token. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to validate token. " + err.Error()) return nil, false } if reviewRes.Status.Error != "" { - logger.Sugar().Warnf("Failed to validate token. " + reviewRes.Status.Error) + logger.Sugar().Warnf("[Authority] Failed to validate token. " + reviewRes.Status.Error) return nil, false } names := strings.Split(reviewRes.Status.User.Username, ":") if len(names) != 4 { - logger.Sugar().Warnf("Token is not a pod service account. " + reviewRes.Status.User.Username) + logger.Sugar().Warnf("[Authority] Token is not a pod service account. " + reviewRes.Status.User.Username) return nil, false } @@ -189,18 +189,18 @@ func (c *ClientImpl) VerifyServiceAccount(token string, authorizationType string podUid := reviewRes.Status.User.Extra["authentication.kubernetes.io/pod-uid"] if len(podName) != 1 || len(podUid) != 1 { - logger.Sugar().Warnf("Token is not a pod service account. " + reviewRes.Status.User.Username) + logger.Sugar().Warnf("[Authority] Token is not a pod service account. " + reviewRes.Status.User.Username) return nil, false } pod, err := c.kubeClient.CoreV1().Pods(namespace).Get(context.TODO(), podName[0], metav1.GetOptions{}) if err != nil { - logger.Sugar().Warnf("Failed to get pod. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to get pod. " + err.Error()) return nil, false } if pod.UID != types.UID(podUid[0]) { - logger.Sugar().Warnf("Token is not a pod service account. " + reviewRes.Status.User.Username) + logger.Sugar().Warnf("[Authority] Token is not a pod service account. " + reviewRes.Status.User.Username) return nil, false } @@ -239,7 +239,7 @@ func (c *ClientImpl) UpdateWebhookConfig(options *dubbo_cp.Config, storage *Cert bundle := storage.GetAuthorityCert().CertPem mwConfig, err := c.kubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Get(context.TODO(), "dubbo-ca", metav1.GetOptions{}) if err != nil { - logger.Sugar().Warnf("Unable to find dubbo-ca webhook config. Will create. " + err.Error()) + logger.Sugar().Warnf("[Webhook] Unable to find dubbo-ca webhook config. Will create. " + err.Error()) mwConfig = &admissionregistrationV1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: "dubbo-ca", @@ -287,24 +287,24 @@ func (c *ClientImpl) UpdateWebhookConfig(options *dubbo_cp.Config, storage *Cert _, err := c.kubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Create(context.TODO(), mwConfig, metav1.CreateOptions{}) if err != nil { - logger.Sugar().Warnf("Failed to create webhook config. " + err.Error()) + logger.Sugar().Warnf("[Webhook] Failed to create webhook config. " + err.Error()) } else { - logger.Sugar().Info("Create webhook config success.") + logger.Sugar().Info("[Webhook] Create webhook config success.") } return } if reflect.DeepEqual(mwConfig.Webhooks[0].ClientConfig.CABundle, []byte(bundle)) { - logger.Sugar().Info("Ignore override webhook config. Cause: Already exist.") + logger.Sugar().Info("[Webhook] Ignore override webhook config. Cause: Already exist.") return } mwConfig.Webhooks[0].ClientConfig.CABundle = []byte(bundle) _, err = c.kubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Update(context.TODO(), mwConfig, metav1.UpdateOptions{}) if err != nil { - logger.Sugar().Warnf("Failed to update webhook config. " + err.Error()) + logger.Sugar().Warnf("[Webhook] Failed to update webhook config. " + err.Error()) } else { - logger.Sugar().Info("Update webhook config success.") + logger.Sugar().Info("[Webhook] Update webhook config success.") } } diff --git a/pkg/core/cert/provider/storage.go b/pkg/core/cert/provider/storage.go index 018f20a02..1de874bb3 100644 --- a/pkg/core/cert/provider/storage.go +++ b/pkg/core/cert/provider/storage.go @@ -43,37 +43,41 @@ type CertStorage struct { serverCerts *Cert } +func calculateInterval(caValidity int64) time.Duration { + interval := math.Max(math.Min(float64(caValidity/100), 10_000), 1) + return time.Duration(interval) * time.Millisecond +} + func (s *CertStorage) Start(stop <-chan struct{}) error { go s.RefreshServerCert(stop) go func(stop <-chan struct{}) { - interval := math.Min(math.Floor(float64(s.config.Security.CaValidity)/100), 10_000) - for { - time.Sleep(time.Duration(interval) * time.Millisecond) - if s.GetAuthorityCert().NeedRefresh() { - logger.Sugar().Infof("Authority cert is invalid, refresh it.") - // TODO lock if multi cp-server - // TODO refresh signed cert - - err := NewleaderElection().Election(s, s.config, s.certClient.GetKubClient()) - if err != nil { - return - } - if s.config.KubeConfig.IsKubernetesConnected { - s.certClient.UpdateAuthorityCert(s.GetAuthorityCert().CertPem, EncodePrivateKey(s.GetAuthorityCert().PrivateKey), s.config.KubeConfig.Namespace) - s.certClient.UpdateWebhookConfig(s.config, s) - if s.certClient.UpdateAuthorityPublicKey(s.GetAuthorityCert().CertPem) { - logger.Sugar().Infof("Write ca to config maps success.") - } else { - logger.Sugar().Warnf("Write ca to config maps failed.") - } - } - } + ticker := time.NewTicker(calculateInterval(s.config.Security.CaValidity)) + defer ticker.Stop() + for { select { case <-stop: return - default: - continue + case <-ticker.C: + if s.GetAuthorityCert().NeedRefresh() { + logger.Sugar().Infof("[Authority] Authority cert is invalid, refresh it.") + // TODO lock if multi cp-server + // TODO refresh signed cert + + err := NewleaderElection().Election(s, s.config, s.certClient.GetKubClient()) + if err != nil { + logger.Sugar().Error("[Authority] Leader Election failed") + } + if s.config.KubeConfig.IsKubernetesConnected { + s.certClient.UpdateAuthorityCert(s.GetAuthorityCert().CertPem, EncodePrivateKey(s.GetAuthorityCert().PrivateKey), s.config.KubeConfig.Namespace) + s.certClient.UpdateWebhookConfig(s.config, s) + if s.certClient.UpdateAuthorityPublicKey(s.GetAuthorityCert().CertPem) { + logger.Sugar().Infof("[Authority] Write ca to config maps success.") + } else { + logger.Sugar().Warnf("[Authority] Write ca to config maps failed.") + } + } + } } } }(stop) @@ -146,34 +150,34 @@ func (c *Cert) GetTlsCert() *tls.Certificate { } tlsCert, err := tls.X509KeyPair([]byte(c.CertPem), []byte(EncodePrivateKey(c.PrivateKey))) if err != nil { - logger.Sugar().Warnf("Failed to load x509 cert. %v", err) + logger.Sugar().Warnf("[Authority] Failed to load x509 cert. %v", err) } c.tlsCert = &tlsCert return c.tlsCert } func (s *CertStorage) RefreshServerCert(stop <-chan struct{}) { - interval := math.Min(math.Floor(float64(s.config.Security.CertValidity)/100), 10_000) - for true { + interval := math.Max(math.Min(math.Floor(float64(s.config.Security.CertValidity)/100), 10_000), 1) + ticker := time.NewTicker(time.Duration(interval) * time.Millisecond) + defer ticker.Stop() + for { select { case <-stop: return - default: + case <-ticker.C: + func() { + s.mutex.Lock() + defer s.mutex.Unlock() + if s.authorityCert == nil || !s.authorityCert.IsValid() { + // ignore if authority cert is invalid + return + } + if s.serverCerts == nil || !s.serverCerts.IsValid() { + logger.Sugar().Infof("[Authority] Server cert is invalid, refresh it.") + s.serverCerts = SignServerCert(s.authorityCert, s.serverNames, s.config.Security.CertValidity) + } + }() } - - time.Sleep(time.Duration(interval) * time.Millisecond) - func() { - s.mutex.Lock() - defer s.mutex.Unlock() - if s.authorityCert == nil || !s.authorityCert.IsValid() { - // ignore if authority cert is invalid - return - } - if s.serverCerts == nil || !s.serverCerts.IsValid() { - logger.Sugar().Infof("Server cert is invalid, refresh it.") - s.serverCerts = SignServerCert(s.authorityCert, s.serverNames, s.config.Security.CertValidity) - } - }() } } diff --git a/pkg/core/cert/provider/util.go b/pkg/core/cert/provider/util.go index 7e5da0f6c..ddd9a73bd 100644 --- a/pkg/core/cert/provider/util.go +++ b/pkg/core/cert/provider/util.go @@ -44,12 +44,12 @@ var oidSubjectAlternativeName = asn1.ObjectIdentifier{2, 5, 29, 17} func DecodeCert(cert string) *x509.Certificate { block, _ := pem.Decode([]byte(cert)) if block == nil { - logger.Sugar().Warnf("Failed to parse public key.") + logger.Sugar().Warnf("[Authority] Failed to parse public key.") return nil } p, err := x509.ParseCertificate(block.Bytes) if err != nil { - logger.Sugar().Warnf("Failed to parse public key. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to parse public key. " + err.Error()) return nil } return p @@ -58,12 +58,12 @@ func DecodeCert(cert string) *x509.Certificate { func DecodePrivateKey(cert string) *ecdsa.PrivateKey { block, _ := pem.Decode([]byte(cert)) if block == nil { - logger.Sugar().Warnf("Failed to parse private key.") + logger.Sugar().Warnf("[Authority] Failed to parse private key.") return nil } p, err := x509.ParseECPrivateKey(block.Bytes) if err != nil { - logger.Sugar().Warnf("Failed to parse private key. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to parse private key. " + err.Error()) return nil } return p @@ -104,7 +104,7 @@ func GenerateAuthorityCert(rootCert *Cert, caValidity int64) *Cert { Bytes: caBytes, }) if err != nil { - logger.Sugar().Warnf("Failed to encode certificate. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to encode certificate. " + err.Error()) panic(err) } @@ -146,7 +146,7 @@ func SignServerCert(authorityCert *Cert, serverName []string, certValidity int64 Bytes: c, }) if err != nil { - logger.Sugar().Warnf("Failed to encode certificate. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to encode certificate. " + err.Error()) panic(err) } return &Cert{ @@ -182,7 +182,7 @@ func GenerateCSR() (string, *ecdsa.PrivateKey, error) { }) if err != nil { - logger.Sugar().Warnf("Failed to encode certificate. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to encode certificate. " + err.Error()) return "", nil, err } return csr.String(), privateKey, nil @@ -244,7 +244,7 @@ func AppendEndpoint(endpoint *endpoint.Endpoint, cert *x509.Certificate) { if endpoint.SpiffeID != "" { spiffeId, err := url.Parse(endpoint.SpiffeID) if err != nil { - logger.Sugar().Warnf("failed to parse the spiffe id (err: %s)", err) + logger.Sugar().Warnf("[Authority] failed to parse the spiffe id (err: %s)", err) return } cert.URIs = append(cert.URIs, spiffeId) @@ -255,7 +255,7 @@ func EncodePrivateKey(caPrivKey *ecdsa.PrivateKey) string { caPrivKeyPEM := new(bytes.Buffer) pri, err := x509.MarshalECPrivateKey(caPrivKey) if err != nil { - logger.Sugar().Warnf("Failed to marshal EC private key. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to marshal EC private key. " + err.Error()) return "" } err = pem.Encode(caPrivKeyPEM, &pem.Block{ @@ -263,7 +263,7 @@ func EncodePrivateKey(caPrivKey *ecdsa.PrivateKey) string { Bytes: pri, }) if err != nil { - logger.Sugar().Warnf("Failed to encode private key. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to encode private key. " + err.Error()) return "" } return caPrivKeyPEM.String() @@ -273,13 +273,13 @@ func EncodePublicKey(pub *ecdsa.PublicKey) (res string) { caPrivKeyPEM := new(bytes.Buffer) defer func() { if err := recover(); err != nil { - logger.Sugar().Warnf("Failed to marshal EC public key. %v", err) + logger.Sugar().Warnf("[Authority] Failed to marshal EC public key. %v", err) res = "" } }() pri, err := x509.MarshalPKIXPublicKey(pub) if err != nil { - logger.Sugar().Warnf("Failed to marshal EC public key. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to marshal EC public key. " + err.Error()) return "" } err = pem.Encode(caPrivKeyPEM, &pem.Block{ @@ -287,7 +287,7 @@ func EncodePublicKey(pub *ecdsa.PublicKey) (res string) { Bytes: pri, }) if err != nil { - logger.Sugar().Warnf("Failed to encode public key. " + err.Error()) + logger.Sugar().Warnf("[Authority] Failed to encode public key. " + err.Error()) return "" } return caPrivKeyPEM.String() diff --git a/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/register.go b/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/register.go index aa1f1e754..7e3b0b5a7 100644 --- a/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/register.go +++ b/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/register.go @@ -44,18 +44,24 @@ var ( // Adds the list of known types to Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, + &AuthenticationPolicy{}, + &AuthenticationPolicyList{}, + &AuthorizationPolicy{}, - &ServiceNameMapping{}, + &AuthorizationPolicyList{}, + &ConditionRoute{}, + &ConditionRouteList{}, + &DynamicConfig{}, - &TagRoute{}, - &TagRouteList{}, &DynamicConfigList{}, + + &ServiceNameMapping{}, &ServiceNameMappingList{}, - &ConditionRouteList{}, - &AuthorizationPolicyList{}, - &AuthenticationPolicyList{}, + + &TagRoute{}, + &TagRouteList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/types.go b/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/types.go index 8fff32a09..53bbb65fb 100644 --- a/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/types.go +++ b/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/types.go @@ -1,17 +1,19 @@ -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package v1alpha1 @@ -22,7 +24,6 @@ import ( // +genclient // +kubebuilder:object:root=true -// +kubebuilder:resource:shortName=ac // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type AuthenticationPolicy struct { @@ -34,7 +35,6 @@ type AuthenticationPolicy struct { } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - type AuthenticationPolicyList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata"` @@ -44,18 +44,17 @@ type AuthenticationPolicyList struct { // +genclient // +kubebuilder:object:root=true -// +kubebuilder:resource:shortName=az // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type AuthorizationPolicy struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec api.AuthorizationPolicy `json:"spec"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - type AuthorizationPolicyList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata"` @@ -63,96 +62,82 @@ type AuthorizationPolicyList struct { Items []AuthorizationPolicy `json:"items"` } -// +kubetype-gen -// +kubetype-gen:groupVersion=dubbo.apache.org/v1alpha1 // +genclient -// +genclient:noStatus -// +k8s:deepcopy-gen=true +// +kubebuilder:object:root=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type ServiceNameMapping struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + +type ConditionRoute struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional - Spec api.ServiceNameMapping `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` + Spec api.ConditionRoute `json:"spec"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type ServiceNameMappingList struct { +type ConditionRouteList struct { metav1.TypeMeta `json:",inline"` - // +optional - metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - Items []*ServiceNameMapping `json:"items" protobuf:"bytes,2,rep,name=items"` + metav1.ListMeta `json:"metadata"` + + Items []ConditionRoute `json:"items"` } // +genclient -//+kubebuilder:object:root=true -// +kubebuilder:resource:shortName=cd +// +kubebuilder:object:root=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// ConditionRouteSpec is the Schema for the conditionroutes API -type ConditionRoute struct { +type DynamicConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` // +optional - Spec api.ConditionRoute `json:"spec"` + Spec api.DynamicConfig `json:"spec"` } -//+kubebuilder:object:root=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ConditionRouteList contains a list of ConditionRouteSpec -type ConditionRouteList struct { +type DynamicConfigList struct { metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []ConditionRoute `json:"items"` + metav1.ListMeta `json:"metadata"` + + Items []DynamicConfig `json:"items"` } // +genclient // +kubebuilder:object:root=true -// +kubebuilder:resource:shortName=tg // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// TagRouteSpec is the Schema for the tagroutes API -type TagRoute struct { +type ServiceNameMapping struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` // +optional - Spec api.TagRoute `json:"spec"` + Spec api.ServiceNameMapping `json:"spec"` } -//+kubebuilder:object:root=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// TagRouteList contains a list of TagRouteSpec -type TagRouteList struct { +type ServiceNameMappingList struct { metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []TagRoute `json:"items"` + metav1.ListMeta `json:"metadata"` + + Items []ServiceNameMapping `json:"items"` } // +genclient // +kubebuilder:object:root=true -// +kubebuilder:resource:shortName=dc // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// DynamicConfigSpec is the Schema for the dynamicconfigs API -type DynamicConfig struct { +type TagRoute struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` // +optional - Spec api.DynamicConfig `json:"spec"` + Spec api.TagRoute `json:"spec"` } -//+kubebuilder:object:root=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// DynamicConfigList contains a list of DynamicConfigSpec -type DynamicConfigList struct { +type TagRouteList struct { metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []DynamicConfig `json:"items"` + metav1.ListMeta `json:"metadata"` + + Items []TagRoute `json:"items"` } diff --git a/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/zz_generated.deepcopy.go b/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/zz_generated.deepcopy.go index 636af9ac3..47b0964cf 100644 --- a/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/core/gen/apis/dubbo.apache.org/v1alpha1/zz_generated.deepcopy.go @@ -35,7 +35,6 @@ limitations under the License. */ // Code generated by deepcopy-gen. DO NOT EDIT. - package v1alpha1 import ( @@ -48,7 +47,6 @@ func (in *AuthenticationPolicy) DeepCopyInto(out *AuthenticationPolicy) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthenticationPolicy. @@ -81,7 +79,6 @@ func (in *AuthenticationPolicyList) DeepCopyInto(out *AuthenticationPolicyList) (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthenticationPolicyList. @@ -108,7 +105,6 @@ func (in *AuthorizationPolicy) DeepCopyInto(out *AuthorizationPolicy) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthorizationPolicy. @@ -141,7 +137,6 @@ func (in *AuthorizationPolicyList) DeepCopyInto(out *AuthorizationPolicyList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthorizationPolicyList. @@ -168,7 +163,6 @@ func (in *ConditionRoute) DeepCopyInto(out *ConditionRoute) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionRoute. @@ -201,7 +195,6 @@ func (in *ConditionRouteList) DeepCopyInto(out *ConditionRouteList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionRouteList. @@ -228,7 +221,6 @@ func (in *DynamicConfig) DeepCopyInto(out *DynamicConfig) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DynamicConfig. @@ -261,7 +253,6 @@ func (in *DynamicConfigList) DeepCopyInto(out *DynamicConfigList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DynamicConfigList. @@ -288,7 +279,6 @@ func (in *ServiceNameMapping) DeepCopyInto(out *ServiceNameMapping) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceNameMapping. @@ -316,16 +306,11 @@ func (in *ServiceNameMappingList) DeepCopyInto(out *ServiceNameMappingList) { in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]*ServiceNameMapping, len(*in)) + *out = make([]ServiceNameMapping, len(*in)) for i := range *in { - if (*in)[i] != nil { - in, out := &(*in)[i], &(*out)[i] - *out = new(ServiceNameMapping) - (*in).DeepCopyInto(*out) - } + (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceNameMappingList. @@ -352,7 +337,6 @@ func (in *TagRoute) DeepCopyInto(out *TagRoute) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TagRoute. @@ -385,7 +369,6 @@ func (in *TagRouteList) DeepCopyInto(out *TagRouteList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TagRouteList. diff --git a/pkg/core/model/model.go b/pkg/core/model/model.go index 47e27fd0c..ecdff1924 100644 --- a/pkg/core/model/model.go +++ b/pkg/core/model/model.go @@ -35,12 +35,12 @@ import ( const ( ApiTypePrefix = "type.googleapis.com/" - AuthenticationTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.AuthenticationPolicy" - AuthorizationTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.AuthorizationPolicy" - TagRouteTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.TagRoute" - DynamicConfigTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.DynamicConfig" - ServiceMappingTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.ServiceNameMapping" - ConditionRouteTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.ConditionRoute" + AuthenticationTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.AuthenticationPolicyToClient" + AuthorizationTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.AuthorizationPolicyToClient" + TagRouteTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.TagRouteToClient" + DynamicConfigTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.DynamicConfigToClient" + ServiceMappingTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.ServiceNameMappingToClient" + ConditionRouteTypeUrl = ApiTypePrefix + "dubbo.apache.org.v1alpha1.ConditionRouteToClient" ) // Meta is metadata attached to each configuration unit. diff --git a/pkg/core/schema/ast/ast.go b/pkg/core/schema/ast/ast.go new file mode 100644 index 000000000..4fff081e2 --- /dev/null +++ b/pkg/core/schema/ast/ast.go @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ast + +import ( + "encoding/json" + + "github.com/apache/dubbo-admin/pkg/core/tools/resource" + "github.com/apache/dubbo-admin/pkg/core/validation" + "github.com/ghodss/yaml" +) + +// Metadata is the top-level container +type Metadata struct { + Collections []*Collection `json:"collections"` + Resources []*Resource `json:"resources"` +} + +// for testing purposes +var jsonUnmarshal = json.Unmarshal + +// FindResourceForGroupKind looks up a resource with the given group and kind. Returns nil if not found. +func (m *Metadata) FindResourceForGroupKind(group, kind string) *Resource { + for _, r := range m.Resources { + if r.Group == group && r.Kind == kind { + return r + } + } + return nil +} + +func (m *Metadata) UnmarshalJSON(data []byte) error { + var in struct { + Collections []*Collection `json:"collections"` + Resources []*Resource `json:"resources"` + } + + if err := jsonUnmarshal(data, &in); err != nil { + return err + } + + m.Collections = in.Collections + m.Resources = in.Resources + // Process resources. + for i, r := range m.Resources { + if r.Validate == "" { + validateFn := "Validate" + asResourceVariableName(r.Kind) + if !validation.IsValidateFunc(validateFn) { + validateFn = "EmptyValidate" + } + m.Resources[i].Validate = validateFn + } + } + + // Process collections + for i, c := range m.Collections { + // If no variable name was specified, use default. + if c.VariableName == "" { + m.Collections[i].VariableName = asCollectionVariableName(c.Name) + } + } + return nil +} + +var _ json.Unmarshaler = &Metadata{} + +// Collection metadata. Describes basic structure of collections. +type Collection struct { + Name string `json:"name"` + VariableName string `json:"variableName"` + Group string `json:"group"` + Kind string `json:"kind"` + Dds bool `json:"dds"` +} + +// Resource metadata for resources contained within a collection. +type Resource struct { + Group string `json:"group"` + Version string `json:"version"` + Kind string `json:"kind"` + Plural string `json:"plural"` + ClusterScoped bool `json:"clusterScoped"` + Proto string `json:"proto"` + Validate string `json:"validate"` +} + +func asResourceVariableName(n string) string { + return resource.CamelCase(n) +} + +func asCollectionVariableName(n string) string { + n = resource.CamelCaseWithSeparator(n, "/") + n = resource.CamelCaseWithSeparator(n, ".") + return n +} + +// Parse and return a yaml representation of Metadata +func Parse(yamlText string) (*Metadata, error) { + var s Metadata + err := yaml.Unmarshal([]byte(yamlText), &s) + if err != nil { + return nil, err + } + return &s, nil +} diff --git a/pkg/core/schema/ast/ast_test.go b/pkg/core/schema/ast/ast_test.go new file mode 100644 index 000000000..c670042e1 --- /dev/null +++ b/pkg/core/schema/ast/ast_test.go @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ast + +import ( + "testing" + + . "github.com/onsi/gomega" +) + +func TestParse(t *testing.T) { + cases := []struct { + input string + expected *Metadata + }{ + { + input: ``, + expected: &Metadata{}, + }, + { + input: ` +resources: + - kind: "AuthenticationPolicy" + group: "dubbo.apache.org" + version: "v1alpha1" + validate: "EmptyValidate" + proto: "dubbo.apache.org.v1alpha1.AuthenticationPolicy" +`, + expected: &Metadata{ + Resources: []*Resource{ + { + Kind: "AuthenticationPolicy", + Group: "dubbo.apache.org", + Version: "v1alpha1", + Proto: "dubbo.apache.org.v1alpha1.AuthenticationPolicy", + Validate: "EmptyValidate", + }, + }, + }, + }, + } + + for _, c := range cases { + t.Run("", func(t *testing.T) { + g := NewWithT(t) + actual, err := Parse(c.input) + g.Expect(err).To(BeNil()) + g.Expect(actual).To(Equal(c.expected)) + }) + } +} diff --git a/pkg/core/schema/collection/schema.go b/pkg/core/schema/collection/schema.go index 20a295498..98ad8eb57 100644 --- a/pkg/core/schema/collection/schema.go +++ b/pkg/core/schema/collection/schema.go @@ -30,14 +30,18 @@ type Schema interface { // Name of the collection. Name() Name + // VariableName is a utility method used to help with codegen. It provides the name of a Schema instance variable. + VariableName() string + // Resource is the schema for resources contained in this collection. Resource() resource.Schema } // Builder Config for the creation of a Schema type Builder struct { - Name string - Resource resource.Schema + Name string + VariableName string + Resource resource.Schema } // Build a Schema instance. @@ -50,8 +54,9 @@ func (b Builder) Build() (Schema, error) { } return &schemaImpl{ - name: NewName(b.Name), - resource: b.Resource, + name: NewName(b.Name), + variableName: b.VariableName, + resource: b.Resource, }, nil } @@ -69,7 +74,6 @@ type schemaImpl struct { resource resource.Schema name Name variableName string - disabled bool } // String interface method implementation. @@ -81,6 +85,10 @@ func (s *schemaImpl) Name() Name { return s.name } +func (s *schemaImpl) VariableName() string { + return s.variableName +} + func (s *schemaImpl) Resource() resource.Schema { return s.resource } diff --git a/pkg/core/schema/collection/schemas.go b/pkg/core/schema/collection/schemas.go index fa1c1bcbd..f94d5bb06 100644 --- a/pkg/core/schema/collection/schemas.go +++ b/pkg/core/schema/collection/schemas.go @@ -24,6 +24,7 @@ import ( "github.com/apache/dubbo-admin/pkg/core/model" + "github.com/google/go-cmp/cmp" "github.com/hashicorp/go-multierror" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -123,7 +124,7 @@ func (s Schemas) FindByGroupVersionKind(gvk model.GroupVersionKind) (Schema, boo return nil, false } -// FindByKind searches and returns the first schema with the given kind +// FindByGroupVersionResource FindByKind searches and returns the first schema with the given kind func (s Schemas) FindByGroupVersionResource(gvr schema.GroupVersionResource) (Schema, bool) { for _, rs := range s.byAddOrder { if rs.Resource().GroupVersionResource() == gvr { @@ -234,3 +235,7 @@ func (s Schemas) Validate() (err error) { } return } + +func (s Schemas) Equal(o Schemas) bool { + return cmp.Equal(s.byAddOrder, o.byAddOrder) +} diff --git a/pkg/core/schema/collections/collections.go b/pkg/core/schema/collections/collections.gen.go similarity index 72% rename from pkg/core/schema/collections/collections.go rename to pkg/core/schema/collections/collections.gen.go index 06b06a837..7bff642c4 100644 --- a/pkg/core/schema/collections/collections.go +++ b/pkg/core/schema/collections/collections.gen.go @@ -27,96 +27,102 @@ import ( ) var ( - DubboCAV1Alpha1Authentication = collection.Builder{ - Name: "dubbo/apache/org/v1alpha1/AuthenticationPolicy", + DubboApacheOrgV1Alpha1AuthenticationPolicy = collection.Builder{ + Name: "dubbo/apache/org/v1alpha1/AuthenticationPolicy", + VariableName: "DubboApacheOrgV1Alpha1AuthenticationPolicy", Resource: resource.Builder{ - ClusterScoped: false, + Group: "dubbo.apache.org", Kind: "AuthenticationPolicy", Plural: "authenticationpolicies", - Group: "dubbo.apache.org", Version: "v1alpha1", Proto: "dubbo.apache.org.v1alpha1.AuthenticationPolicy", ReflectType: reflect.TypeOf(&api.AuthenticationPolicy{}).Elem(), + ClusterScoped: false, ValidateProto: validation.EmptyValidate, }.MustBuild(), }.MustBuild() - DubboCAV1Alpha1Authorization = collection.Builder{ - Name: "dubbo/apache/org/v1alpha1/AuthorizationPolicy", + DubboApacheOrgV1Alpha1AuthorizationPolicy = collection.Builder{ + Name: "dubbo/apache/org/v1alpha1/AuthorizationPolicy", + VariableName: "DubboApacheOrgV1Alpha1AuthorizationPolicy", Resource: resource.Builder{ - ClusterScoped: false, + Group: "dubbo.apache.org", Kind: "AuthorizationPolicy", Plural: "authorizationpolicies", - Group: "dubbo.apache.org", Version: "v1alpha1", Proto: "dubbo.apache.org.v1alpha1.AuthorizationPolicy", ReflectType: reflect.TypeOf(&api.AuthorizationPolicy{}).Elem(), + ClusterScoped: false, ValidateProto: validation.EmptyValidate, }.MustBuild(), }.MustBuild() - DubboNetWorkV1Alpha1ConditionRoute = collection.Builder{ - Name: "dubbo/apache/org/v1alpha1/ConditionRoute", + DubboApacheOrgV1Alpha1ConditionRoute = collection.Builder{ + Name: "dubbo/apache/org/v1alpha1/ConditionRoute", + VariableName: "DubboApacheOrgV1Alpha1ConditionRoute", Resource: resource.Builder{ - ClusterScoped: false, + Group: "dubbo.apache.org", Kind: "ConditionRoute", Plural: "conditionroutes", - Group: "dubbo.apache.org", Version: "v1alpha1", Proto: "dubbo.apache.org.v1alpha1.ConditionRoute", ReflectType: reflect.TypeOf(&api.ConditionRoute{}).Elem(), - ValidateProto: validation.EmptyValidate, - }.MustBuild(), - }.MustBuild() - - DubboNetWorkV1Alpha1TagRoute = collection.Builder{ - Name: "dubbo/apache/org/v1alpha1/TagRoute", - Resource: resource.Builder{ ClusterScoped: false, - Kind: "TagRoute", - Plural: "tagroutes", - Group: "dubbo.apache.org", - Version: "v1alpha1", - Proto: "dubbo.apache.org.v1alpha1.TagRoute", - ReflectType: reflect.TypeOf(&api.TagRoute{}).Elem(), ValidateProto: validation.EmptyValidate, }.MustBuild(), }.MustBuild() - DubboNetWorkV1Alpha1DynamicConfig = collection.Builder{ - Name: "dubbo/apache/org/v1alpha1/DynamicConfig", + DubboApacheOrgV1Alpha1DynamicConfig = collection.Builder{ + Name: "dubbo/apache/org/v1alpha1/DynamicConfig", + VariableName: "DubboApacheOrgV1Alpha1DynamicConfig", Resource: resource.Builder{ - ClusterScoped: false, + Group: "dubbo.apache.org", Kind: "DynamicConfig", Plural: "dynamicconfigs", - Group: "dubbo.apache.org", Version: "v1alpha1", Proto: "dubbo.apache.org.v1alpha1.DynamicConfig", ReflectType: reflect.TypeOf(&api.DynamicConfig{}).Elem(), + ClusterScoped: false, ValidateProto: validation.EmptyValidate, }.MustBuild(), }.MustBuild() - DubboServiceV1Alpha1ServiceMapping = collection.Builder{ - Name: "dubbo/apache/org/v1alpha1/ServiceNameMapping", + DubboApacheOrgV1Alpha1ServiceNameMapping = collection.Builder{ + Name: "dubbo/apache/org/v1alpha1/ServiceNameMapping", + VariableName: "DubboApacheOrgV1Alpha1ServiceNameMapping", Resource: resource.Builder{ - ClusterScoped: false, + Group: "dubbo.apache.org", Kind: "ServiceNameMapping", Plural: "servicenamemappings", - Group: "dubbo.apache.org", Version: "v1alpha1", Proto: "dubbo.apache.org.v1alpha1.ServiceNameMapping", ReflectType: reflect.TypeOf(&api.ServiceNameMapping{}).Elem(), + ClusterScoped: false, + ValidateProto: validation.EmptyValidate, + }.MustBuild(), + }.MustBuild() + + DubboApacheOrgV1Alpha1TagRoute = collection.Builder{ + Name: "dubbo/apache/org/v1alpha1/TagRoute", + VariableName: "DubboApacheOrgV1Alpha1TagRoute", + Resource: resource.Builder{ + Group: "dubbo.apache.org", + Kind: "TagRoute", + Plural: "tagroutes", + Version: "v1alpha1", + Proto: "dubbo.apache.org.v1alpha1.TagRoute", + ReflectType: reflect.TypeOf(&api.TagRoute{}).Elem(), + ClusterScoped: false, ValidateProto: validation.EmptyValidate, }.MustBuild(), }.MustBuild() Rule = collection.NewSchemasBuilder(). - MustAdd(DubboCAV1Alpha1Authentication). - MustAdd(DubboCAV1Alpha1Authorization). - MustAdd(DubboServiceV1Alpha1ServiceMapping). - MustAdd(DubboNetWorkV1Alpha1ConditionRoute). - MustAdd(DubboNetWorkV1Alpha1DynamicConfig). - MustAdd(DubboNetWorkV1Alpha1TagRoute). + MustAdd(DubboApacheOrgV1Alpha1AuthenticationPolicy). + MustAdd(DubboApacheOrgV1Alpha1AuthorizationPolicy). + MustAdd(DubboApacheOrgV1Alpha1ConditionRoute). + MustAdd(DubboApacheOrgV1Alpha1DynamicConfig). + MustAdd(DubboApacheOrgV1Alpha1ServiceNameMapping). + MustAdd(DubboApacheOrgV1Alpha1TagRoute). Build() ) diff --git a/pkg/core/schema/gvk/resource.go b/pkg/core/schema/gvk/gvk.gen.go similarity index 51% rename from pkg/core/schema/gvk/resource.go rename to pkg/core/schema/gvk/gvk.gen.go index 2a441e949..8c842db4a 100644 --- a/pkg/core/schema/gvk/resource.go +++ b/pkg/core/schema/gvk/gvk.gen.go @@ -20,34 +20,10 @@ package gvk import "github.com/apache/dubbo-admin/pkg/core/model" var ( - Authentication = model.GroupVersionKind{ - Group: "dubbo.apache.org", - Version: "v1alpha1", - Kind: "AuthenticationPolicy", - }.String() - Authorization = model.GroupVersionKind{ - Group: "dubbo.apache.org", - Version: "v1alpha1", - Kind: "AuthorizationPolicy", - }.String() - ConditionRoute = model.GroupVersionKind{ - Group: "dubbo.apache.org", - Version: "v1alpha1", - Kind: "ConditionRoute", - }.String() - TagRoute = model.GroupVersionKind{ - Group: "dubbo.apache.org", - Version: "v1alpha1", - Kind: "TagRoute", - }.String() - DynamicConfig = model.GroupVersionKind{ - Group: "dubbo.apache.org", - Version: "v1alpha1", - Kind: "DynamicConfig", - }.String() - ServiceMapping = model.GroupVersionKind{ - Group: "dubbo.apache.org", - Version: "v1alpha1", - Kind: "ServiceNameMapping", - }.String() + AuthenticationPolicy = model.GroupVersionKind{Group: "dubbo.apache.org", Version: "v1alpha1", Kind: "AuthenticationPolicy"}.String() + AuthorizationPolicy = model.GroupVersionKind{Group: "dubbo.apache.org", Version: "v1alpha1", Kind: "AuthorizationPolicy"}.String() + ConditionRoute = model.GroupVersionKind{Group: "dubbo.apache.org", Version: "v1alpha1", Kind: "ConditionRoute"}.String() + DynamicConfig = model.GroupVersionKind{Group: "dubbo.apache.org", Version: "v1alpha1", Kind: "DynamicConfig"}.String() + ServiceNameMapping = model.GroupVersionKind{Group: "dubbo.apache.org", Version: "v1alpha1", Kind: "ServiceNameMapping"}.String() + TagRoute = model.GroupVersionKind{Group: "dubbo.apache.org", Version: "v1alpha1", Kind: "TagRoute"}.String() ) diff --git a/pkg/core/schema/schema.go b/pkg/core/schema/schema.go new file mode 100644 index 000000000..4788ca426 --- /dev/null +++ b/pkg/core/schema/schema.go @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package schema + +import ( + "fmt" + + "github.com/apache/dubbo-admin/pkg/core/schema/ast" + "github.com/apache/dubbo-admin/pkg/core/schema/collection" + "github.com/apache/dubbo-admin/pkg/core/schema/resource" + resource2 "github.com/apache/dubbo-admin/pkg/core/tools/resource" + "github.com/apache/dubbo-admin/pkg/core/validation" + "github.com/google/go-cmp/cmp" +) + +type Metadata struct { + collections collection.Schemas +} + +// AllCollections is all known collections +func (m *Metadata) AllCollections() collection.Schemas { return m.collections } + +func (m *Metadata) Equal(o *Metadata) bool { + return cmp.Equal(m.collections, o.collections) +} + +// ParseAndBuild parses the given metadata file and returns the strongly typed schema. +func ParseAndBuild(yamlText string) (*Metadata, error) { + mast, err := ast.Parse(yamlText) + if err != nil { + return nil, err + } + + return Build(mast) +} + +// Build strongly-typed Metadata from parsed AST. +func Build(astm *ast.Metadata) (*Metadata, error) { + resourceKey := func(group, kind string) string { + return group + "/" + kind + } + + resources := make(map[string]resource.Schema) + for i, ar := range astm.Resources { + if ar.Kind == "" { + return nil, fmt.Errorf("resource %d missing type", i) + } + if ar.Plural == "" { + return nil, fmt.Errorf("resource %d missing type", i) + } + if ar.Version == "" { + return nil, fmt.Errorf("resource %d missing type", i) + } + if ar.Proto == "" { + return nil, fmt.Errorf("resource %d missing type", i) + } + if ar.Validate == "" { + validateFn := "Validate" + resource2.CamelCase(ar.Kind) + if !validation.IsValidateFunc(validateFn) { + validateFn = "EmptyValidate" + } + ar.Validate = validateFn + } + validateFn := validation.GetValidateFunc(ar.Validate) + if validateFn == nil { + return nil, fmt.Errorf("failed locating proto validation function %s", ar.Validate) + } + + r := resource.Builder{ + ClusterScoped: ar.ClusterScoped, + Kind: ar.Kind, + Plural: ar.Plural, + Group: ar.Group, + Version: ar.Version, + Proto: ar.Proto, + ValidateProto: validateFn, + }.BuildNoValidate() + + key := resourceKey(ar.Group, ar.Kind) + if _, ok := resources[key]; ok { + return nil, fmt.Errorf("found duplicate resource for resource (%s)", key) + } + resources[key] = r + } + + cBuilder := collection.NewSchemasBuilder() + for _, c := range astm.Collections { + key := resourceKey(c.Group, c.Kind) + r, found := resources[key] + if !found { + return nil, fmt.Errorf("failed locating resource (%s) for collection %s", key, c.Name) + } + + s, err := collection.Builder{ + Name: c.Name, + Resource: r, + }.Build() + if err != nil { + return nil, err + } + + if err = cBuilder.Add(s); err != nil { + return nil, err + } + } + + collections := cBuilder.Build() + + return &Metadata{ + collections: collections, + }, nil +} diff --git a/pkg/core/schema/schema_test.go b/pkg/core/schema/schema_test.go new file mode 100644 index 000000000..8382bdede --- /dev/null +++ b/pkg/core/schema/schema_test.go @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package schema + +import ( + "testing" + + "github.com/apache/dubbo-admin/pkg/core/schema/collection" + "github.com/apache/dubbo-admin/pkg/core/schema/collections" + . "github.com/onsi/gomega" +) + +var Authentication = collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() + +func TestSchema_ParseAndBuild(t *testing.T) { + cases := []struct { + Input string + Expected *Metadata + }{ + { + Input: ` +collections: + - name: "dubbo/apache/org/v1alpha1/AuthenticationPolicy" + kind: "AuthenticationPolicy" + group: "dubbo.apache.org" + dds: true + +# Configuration for resource types +resources: + - kind: "AuthenticationPolicy" + plural: "authenticationpolicies" + group: "dubbo.apache.org" + version: "v1alpha1" + validate: "EmptyValidate" + proto: "dubbo.apache.org.v1alpha1.AuthenticationPolicy" +`, + Expected: &Metadata{ + collections: func() collection.Schemas { + b := collection.NewSchemasBuilder() + b.MustAdd( + collection.Builder{ + Name: "dubbo/apache/org/v1alpha1/AuthenticationPolicy", + Resource: Authentication, + }.MustBuild(), + ) + return b.Build() + }(), + }, + }, + } + + for _, c := range cases { + t.Run("", func(t *testing.T) { + g := NewWithT(t) + + _, err := ParseAndBuild(c.Input) + g.Expect(err).To(BeNil()) + }) + } +} diff --git a/pkg/core/tools/endpoint/endpoint.go b/pkg/core/tools/endpoint/endpoint.go index 2788aa88d..924504566 100644 --- a/pkg/core/tools/endpoint/endpoint.go +++ b/pkg/core/tools/endpoint/endpoint.go @@ -54,7 +54,7 @@ func ExactEndpoint(c context.Context, certStorage *provider.CertStorage, options } if !options.Security.IsTrustAnyone && connectionErr != nil { - return nil, fmt.Errorf("Failed to get endpoint from header: %s. Failed to get endpoint from storage: %s. RemoteAddr: %s", + return nil, fmt.Errorf("failed to get endpoint from header: %s. Failed to get endpoint from storage: %s. RemoteAddr: %s", endpointErr.Error(), connectionErr.Error(), p.Addr.String()) } diff --git a/pkg/core/tools/generate/key.go b/pkg/core/tools/generate/key.go new file mode 100644 index 000000000..a51179382 --- /dev/null +++ b/pkg/core/tools/generate/key.go @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package generate + +func GenerateKey(name, namespace string) string { + if namespace != "" { + return name + "/" + namespace + } + return name +} diff --git a/pkg/core/tools/resource/camelcase.go b/pkg/core/tools/resource/camelcase.go new file mode 100644 index 000000000..48f50b65a --- /dev/null +++ b/pkg/core/tools/resource/camelcase.go @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package resource + +import "strings" + +// CamelCase converts the string into camel case string +func CamelCase(s string) string { + if s == "" { + return "" + } + t := make([]byte, 0, 32) + i := 0 + if isWordSeparator(s[0]) { + // Need a capital letter; drop the '_'. + t = append(t, 'X') + i++ + } + // Invariant: if the next letter is lower case, it must be converted + // to upper case. + // That is, we process a word at a time, where words are marked by _, - or + // upper case letter. Digits are treated as words. + for ; i < len(s); i++ { + c := s[i] + if isWordSeparator(c) { + // Skip the separate and capitalize the next letter. + continue + } + if isASCIIDigit(c) { + t = append(t, c) + continue + } + // Assume we have a letter now - if not, it's a bogus identifier. + // The next word is a sequence of characters that must start upper case. + if isASCIILower(c) { + c ^= ' ' // Make it a capital letter. + } + t = append(t, c) // Guaranteed not lower case. + // Accept lower case sequence that follows. + for i+1 < len(s) && isASCIILower(s[i+1]) { + i++ + t = append(t, s[i]) + } + } + return string(t) +} + +func isWordSeparator(c byte) bool { + return c == '_' || c == '-' +} + +// Is c an ASCII lower-case letter? +func isASCIILower(c byte) bool { + return 'a' <= c && c <= 'z' +} + +// Is c an ASCII digit? +func isASCIIDigit(c byte) bool { + return '0' <= c && c <= '9' +} + +// CamelCaseWithSeparator splits the given string by the separator, converts the parts to CamelCase and then re-joins them. +func CamelCaseWithSeparator(n string, sep string) string { + p := strings.Split(n, sep) + for i := 0; i < len(p); i++ { + p[i] = CamelCase(p[i]) + } + return strings.Join(p, "") +} diff --git a/pkg/core/validation/validation.go b/pkg/core/validation/validation.go index 5ed14193c..09c7d3a56 100644 --- a/pkg/core/validation/validation.go +++ b/pkg/core/validation/validation.go @@ -38,3 +38,13 @@ func registerValidateFunc(name string, f ValidateFunc) ValidateFunc { validateFuncs[name] = f return f } + +// IsValidateFunc indicates whether there is a validation function with the given name. +func IsValidateFunc(name string) bool { + return GetValidateFunc(name) != nil +} + +// GetValidateFunc returns the validation function with the given name, or null if it does not exist. +func GetValidateFunc(name string) ValidateFunc { + return validateFuncs[name] +} diff --git a/pkg/cp-server/server/server.go b/pkg/cp-server/server/server.go index 8f0ed25c9..eae888566 100644 --- a/pkg/cp-server/server/server.go +++ b/pkg/cp-server/server/server.go @@ -81,25 +81,25 @@ func (d *GrpcServer) Start(stop <-chan struct{}) error { go func() { defer close(plainErrChan) if err = d.PlainServer.Serve(plainLis); err != nil { - logger.Sugar().Error(err, "terminated with an error") + logger.Sugar().Error(err, "[cp-server] terminated with an error") plainErrChan <- err } else { - logger.Sugar().Info("terminated normally") + logger.Sugar().Info("[cp-server] terminated normally") } }() go func() { defer close(secureErrChan) if err = d.SecureServer.Serve(secureLis); err != nil { - logger.Sugar().Error(err, "terminated with an error") + logger.Sugar().Error(err, "[cp-server] terminated with an error") secureErrChan <- err } else { - logger.Sugar().Info("terminated normally") + logger.Sugar().Info("[cp-server] terminated normally") } }() select { case <-stop: - logger.Sugar().Info("stopping gracefully") + logger.Sugar().Info("[cp-server] stopping gracefully") d.PlainServer.GracefulStop() d.SecureServer.GracefulStop() return nil diff --git a/pkg/dds/kube/crdclient/client.go b/pkg/dds/kube/crdclient/client.go index 4ecef6962..dcdb2fdf4 100644 --- a/pkg/dds/kube/crdclient/client.go +++ b/pkg/dds/kube/crdclient/client.go @@ -102,7 +102,7 @@ func getObjectMetadata(config model.Config) metav1.ObjectMeta { func (cl *Client) HasSynced() bool { for kind, ctl := range cl.kinds { if !ctl.informer.HasSynced() { - logger.Sugar().Infof("controller %q is syncing...", kind) + logger.Sugar().Infof("[DDS] controller %q is syncing...", kind) return false } } @@ -112,16 +112,16 @@ func (cl *Client) HasSynced() bool { // Start the queue and all informers. Callers should wait for HasSynced() before depending on results. func (cl *Client) Start(stop <-chan struct{}) error { t0 := time.Now() - logger.Sugar().Info("Starting Rule K8S CRD controller") + logger.Sugar().Info("[DDS] Starting Rule K8S CRD controller") go func() { cache.WaitForCacheSync(stop, cl.HasSynced) - logger.Sugar().Info("Rule K8S CRD controller synced", time.Since(t0)) + logger.Sugar().Info("[DDS] Rule K8S CRD controller synced", time.Since(t0)) cl.queue.Run(stop) }() <-stop - logger.Sugar().Info("controller terminated") + logger.Sugar().Info("[DDS] controller terminated") return nil } @@ -141,7 +141,7 @@ func (cl *Client) checkReadyForEvents(curr interface{}) error { } _, err := cache.DeletionHandlingMetaNamespaceKeyFunc(curr) if err != nil { - logger.Sugar().Infof("Error retrieving key: %v", err) + logger.Sugar().Infof("[DDS] Error retrieving key: %v", err) } return nil } @@ -157,7 +157,7 @@ func knownCRDs(crdClient apiextensionsclient.Interface) map[string]struct{} { if err == nil { break } - logger.Sugar().Errorf("failed to list CRDs: %v", err) + logger.Sugar().Errorf("[DDS] failed to list CRDs: %v", err) time.Sleep(delay) delay *= 2 if delay > maxDelay { @@ -198,13 +198,13 @@ func (cl *Client) Schemas() collection.Schemas { func (cl *Client) Get(typ model.GroupVersionKind, name, namespace string) *model.Config { h, f := cl.kinds[typ] if !f { - logger.Sugar().Warnf("unknown type: %s", typ) + logger.Sugar().Warnf("[DDS] unknown type: %s", typ) return nil } obj, err := h.lister(namespace).Get(name) if err != nil { - logger.Sugar().Warnf("error on get %v/%v: %v", name, namespace, err) + logger.Sugar().Warnf("[DDS] error on get %v/%v: %v", name, namespace, err) return nil } @@ -215,7 +215,7 @@ func (cl *Client) Get(typ model.GroupVersionKind, name, namespace string) *model func TranslateObject(r runtime.Object, gvk model.GroupVersionKind, domainSuffix string) *model.Config { translateFunc, f := translationMap[gvk] if !f { - logger.Sugar().Errorf("unknown type %v", gvk) + logger.Sugar().Errorf("[DDS] unknown type %v", gvk) return nil } c := translateFunc(r) @@ -248,7 +248,7 @@ func NewForSchemas(client *client.KubeClient, domainSuffix string, schemas colle } out.kinds[s.Resource().GroupVersionKind()] = createCacheHandler(out, s, i) } else { - logger.Sugar().Warnf("Skipping CRD %v as it is not present", s.Resource().GroupVersionKind()) + logger.Sugar().Warnf("[DDS] Skipping CRD %v as it is not present", s.Resource().GroupVersionKind()) } } diff --git a/pkg/dds/kube/crdclient/client_test.go b/pkg/dds/kube/crdclient/client_test.go index ca069a621..070c94610 100644 --- a/pkg/dds/kube/crdclient/client_test.go +++ b/pkg/dds/kube/crdclient/client_test.go @@ -67,10 +67,10 @@ func makeClient(t *testing.T, schemas collection.Schemas) ConfigStoreCache { // Ensure that the client can run without CRDs present func TestClientNoCRDs(t *testing.T) { - schema := collection.NewSchemasBuilder().MustAdd(collections.DubboServiceV1Alpha1ServiceMapping).Build() + schema := collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1ServiceNameMapping).Build() store := makeClient(t, schema) retry.UntilOrFail(t, store.HasSynced, retry.Timeout(time.Second)) - r := collections.DubboCAV1Alpha1Authorization.Resource() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", diff --git a/pkg/dds/kube/crdclient/handler.go b/pkg/dds/kube/crdclient/handler.go index 485e60eeb..5316197fc 100644 --- a/pkg/dds/kube/crdclient/handler.go +++ b/pkg/dds/kube/crdclient/handler.go @@ -51,22 +51,21 @@ func NewHandler(storage *storage.Storage, rootNamespace string, cache ConfigStor } } -// nolint func (p *PushContext) NotifyWithIndex(schema collection.Schema) error { gvk := schema.Resource().GroupVersionKind() configs, err := p.cache.List(gvk, NamespaceAll) data := make([]model.Config, 0) if err != nil { - logger.Sugar().Error("fail to get the cache from client-go Index") + logger.Sugar().Error("[DDS] fail to get the cache from client-go Index") return err } - if gvk.String() == gvks.Authorization { + if gvk.String() == gvks.AuthorizationPolicy { // WARNING: the client-go cache is read-only, if we must change the resource, we need to deep copy first for _, config := range configs { deepCopy := authorization(config, p.rootNamespace) data = append(data, deepCopy) } - } else if gvk.String() == gvks.Authentication { + } else if gvk.String() == gvks.AuthenticationPolicy { // WARNING: the client-go cache is read-only, if we must change the resource, we need to deep copy first for _, config := range configs { deepCopy := authentication(config, p.rootNamespace) @@ -98,21 +97,21 @@ func (p *PushContext) NotifyWithIndex(schema collection.Schema) error { func authorization(config model.Config, rootNamespace string) model.Config { deepCopy := config.DeepCopy() policy := deepCopy.Spec.(*api.AuthorizationPolicy) - if rootNamespace != config.Namespace { - if len(policy.Rules) == 0 { - policy.Rules = append(policy.Rules, &api.AuthorizationPolicyRule{ - To: &api.AuthorizationPolicyTarget{ - Namespaces: []string{config.Namespace}, - }, - }) - } else { - for _, rule := range policy.Rules { - if rule.To != nil { - rule.To = &api.AuthorizationPolicyTarget{} - } - if !slices.Contains(rule.To.Namespaces, config.Namespace) { - rule.To.Namespaces = append(rule.To.Namespaces, config.Namespace) - } + if rootNamespace == deepCopy.Namespace { + return deepCopy + } + if policy.GetRules() == nil { + policy.Rules = []*api.AuthorizationPolicyRule{} + policy.Rules = append(policy.Rules, &api.AuthorizationPolicyRule{ + To: &api.AuthorizationPolicyTarget{ + Namespaces: []string{deepCopy.Namespace}, + }, + }) + } else { + for _, rule := range policy.Rules { + rule.To = &api.AuthorizationPolicyTarget{} + if !slices.Contains(rule.To.Namespaces, deepCopy.Namespace) { + rule.To.Namespaces = append(rule.To.Namespaces, deepCopy.Namespace) } } } @@ -123,7 +122,8 @@ func authentication(config model.Config, rootNamespace string) model.Config { deepCopy := config.DeepCopy() policy := deepCopy.Spec.(*api.AuthenticationPolicy) if rootNamespace != config.Namespace { - if len(policy.Selector) == 0 { + if policy.GetSelector() == nil { + policy.Selector = []*api.AuthenticationPolicySelector{} policy.Selector = append(policy.Selector, &api.AuthenticationPolicySelector{ Namespaces: []string{config.Namespace}, }) diff --git a/pkg/dds/kube/crdclient/handler_test.go b/pkg/dds/kube/crdclient/handler_test.go index ee8fbd36e..dac07e804 100644 --- a/pkg/dds/kube/crdclient/handler_test.go +++ b/pkg/dds/kube/crdclient/handler_test.go @@ -33,7 +33,7 @@ import ( func TestAuthentication(t *testing.T) { configName := "name" configNamespace := "namespace" - c := collections.DubboCAV1Alpha1Authentication + c := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy name := c.Resource().Kind() t.Run(name, func(t *testing.T) { r := c.Resource() @@ -94,7 +94,7 @@ func TestAuthentication(t *testing.T) { func TestAuthorization(t *testing.T) { configName := "name" configNamespace := "namespace" - c := collections.DubboCAV1Alpha1Authorization + c := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy name := c.Resource().Kind() t.Run(name, func(t *testing.T) { r := c.Resource() @@ -186,7 +186,49 @@ func TestAuthorization(t *testing.T) { }) } -// nolint +func TestAuthorizationNilField(t *testing.T) { + configName := "name" + configNamespace := "namespace" + c := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy + name := c.Resource().Kind() + t.Run(name, func(t *testing.T) { + r := c.Resource() + configMeta := model.Meta{ + GroupVersionKind: r.GroupVersionKind(), + Name: configName, + } + if !r.IsClusterScoped() { + configMeta.Namespace = configNamespace + } + + pb, err := r.NewInstance() + if err != nil { + t.Fatal(err) + } + authorizationPolicy := pb.(*dubbo_apache_org_v1alpha1.AuthorizationPolicy) + authorizationPolicy.Action = "DENY" + authorizationPolicy.Rules = []*dubbo_apache_org_v1alpha1.AuthorizationPolicyRule{ + { + From: &dubbo_apache_org_v1alpha1.AuthorizationPolicySource{ + Namespaces: []string{"dubbo-system"}, + }, + To: &dubbo_apache_org_v1alpha1.AuthorizationPolicyTarget{ + Namespaces: []string{"ns"}, + }, + }, + } + + config := model.Config{ + Meta: configMeta, + Spec: authorizationPolicy, + } + + m := authorization(config, "dubbo-system") + afterPolicy := m.Spec.(*dubbo_apache_org_v1alpha1.AuthorizationPolicy) + assert.Equal(t, afterPolicy.Rules[0].To.Namespaces[0], configNamespace) + }) +} + func TestNotifyWithIndex(t *testing.T) { store := makeClient(t, collections.Rule) configName := "name" diff --git a/pkg/dds/kube/crdclient/types.go b/pkg/dds/kube/crdclient/types.gen.go similarity index 74% rename from pkg/dds/kube/crdclient/types.go rename to pkg/dds/kube/crdclient/types.gen.go index c2da626d2..8d8ef953e 100644 --- a/pkg/dds/kube/crdclient/types.go +++ b/pkg/dds/kube/crdclient/types.gen.go @@ -30,116 +30,109 @@ import ( "k8s.io/apimachinery/pkg/runtime" ) -// only for tests -// WARNING: if not test, do not use this function! func create(ic versioned.Interface, cfg model.Config, objMeta metav1.ObjectMeta) (metav1.Object, error) { switch cfg.GroupVersionKind { - case collections.DubboCAV1Alpha1Authorization.Resource().GroupVersionKind(): - return ic.DubboV1alpha1().AuthorizationPolicies(cfg.Namespace).Create(context.TODO(), &v1alpha1.AuthorizationPolicy{ - ObjectMeta: objMeta, - Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.AuthorizationPolicy)), - }, metav1.CreateOptions{}) - case collections.DubboCAV1Alpha1Authentication.Resource().GroupVersionKind(): + case collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource().GroupVersionKind(): return ic.DubboV1alpha1().AuthenticationPolicies(cfg.Namespace).Create(context.TODO(), &v1alpha1.AuthenticationPolicy{ ObjectMeta: objMeta, Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.AuthenticationPolicy)), }, metav1.CreateOptions{}) - case collections.DubboServiceV1Alpha1ServiceMapping.Resource().GroupVersionKind(): - return ic.DubboV1alpha1().ServiceNameMappings(cfg.Namespace).Create(context.TODO(), &v1alpha1.ServiceNameMapping{ + case collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource().GroupVersionKind(): + return ic.DubboV1alpha1().AuthorizationPolicies(cfg.Namespace).Create(context.TODO(), &v1alpha1.AuthorizationPolicy{ ObjectMeta: objMeta, - Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.ServiceNameMapping)), + Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.AuthorizationPolicy)), }, metav1.CreateOptions{}) - case collections.DubboNetWorkV1Alpha1TagRoute.Resource().GroupVersionKind(): - return ic.DubboV1alpha1().TagRoutes(cfg.Namespace).Create(context.TODO(), &v1alpha1.TagRoute{ + case collections.DubboApacheOrgV1Alpha1ConditionRoute.Resource().GroupVersionKind(): + return ic.DubboV1alpha1().ConditionRoutes(cfg.Namespace).Create(context.TODO(), &v1alpha1.ConditionRoute{ ObjectMeta: objMeta, - Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.TagRoute)), + Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.ConditionRoute)), }, metav1.CreateOptions{}) - case collections.DubboNetWorkV1Alpha1DynamicConfig.Resource().GroupVersionKind(): + case collections.DubboApacheOrgV1Alpha1DynamicConfig.Resource().GroupVersionKind(): return ic.DubboV1alpha1().DynamicConfigs(cfg.Namespace).Create(context.TODO(), &v1alpha1.DynamicConfig{ ObjectMeta: objMeta, Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.DynamicConfig)), }, metav1.CreateOptions{}) - case collections.DubboNetWorkV1Alpha1ConditionRoute.Resource().GroupVersionKind(): - return ic.DubboV1alpha1().ConditionRoutes(cfg.Namespace).Create(context.TODO(), &v1alpha1.ConditionRoute{ + case collections.DubboApacheOrgV1Alpha1ServiceNameMapping.Resource().GroupVersionKind(): + return ic.DubboV1alpha1().ServiceNameMappings(cfg.Namespace).Create(context.TODO(), &v1alpha1.ServiceNameMapping{ ObjectMeta: objMeta, - Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.ConditionRoute)), + Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.ServiceNameMapping)), + }, metav1.CreateOptions{}) + case collections.DubboApacheOrgV1Alpha1TagRoute.Resource().GroupVersionKind(): + return ic.DubboV1alpha1().TagRoutes(cfg.Namespace).Create(context.TODO(), &v1alpha1.TagRoute{ + ObjectMeta: objMeta, + Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.TagRoute)), }, metav1.CreateOptions{}) default: return nil, fmt.Errorf("unsupported type: %v", cfg.GroupVersionKind) } } -// only for test -// WARNING: if not test, do not use this function! func update(ic versioned.Interface, cfg model.Config, objMeta metav1.ObjectMeta) (metav1.Object, error) { switch cfg.GroupVersionKind { - case collections.DubboCAV1Alpha1Authorization.Resource().GroupVersionKind(): - return ic.DubboV1alpha1().AuthorizationPolicies(cfg.Namespace).Update(context.TODO(), &v1alpha1.AuthorizationPolicy{ - ObjectMeta: objMeta, - Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.AuthorizationPolicy)), - }, metav1.UpdateOptions{}) - case collections.DubboCAV1Alpha1Authentication.Resource().GroupVersionKind(): + case collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource().GroupVersionKind(): return ic.DubboV1alpha1().AuthenticationPolicies(cfg.Namespace).Update(context.TODO(), &v1alpha1.AuthenticationPolicy{ ObjectMeta: objMeta, Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.AuthenticationPolicy)), }, metav1.UpdateOptions{}) - case collections.DubboServiceV1Alpha1ServiceMapping.Resource().GroupVersionKind(): - return ic.DubboV1alpha1().ServiceNameMappings(cfg.Namespace).Update(context.TODO(), &v1alpha1.ServiceNameMapping{ + case collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource().GroupVersionKind(): + return ic.DubboV1alpha1().AuthorizationPolicies(cfg.Namespace).Update(context.TODO(), &v1alpha1.AuthorizationPolicy{ ObjectMeta: objMeta, - Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.ServiceNameMapping)), + Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.AuthorizationPolicy)), }, metav1.UpdateOptions{}) - case collections.DubboNetWorkV1Alpha1TagRoute.Resource().GroupVersionKind(): - return ic.DubboV1alpha1().TagRoutes(cfg.Namespace).Update(context.TODO(), &v1alpha1.TagRoute{ + case collections.DubboApacheOrgV1Alpha1ConditionRoute.Resource().GroupVersionKind(): + return ic.DubboV1alpha1().ConditionRoutes(cfg.Namespace).Update(context.TODO(), &v1alpha1.ConditionRoute{ ObjectMeta: objMeta, - Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.TagRoute)), + Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.ConditionRoute)), }, metav1.UpdateOptions{}) - case collections.DubboNetWorkV1Alpha1DynamicConfig.Resource().GroupVersionKind(): + case collections.DubboApacheOrgV1Alpha1DynamicConfig.Resource().GroupVersionKind(): return ic.DubboV1alpha1().DynamicConfigs(cfg.Namespace).Update(context.TODO(), &v1alpha1.DynamicConfig{ ObjectMeta: objMeta, Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.DynamicConfig)), }, metav1.UpdateOptions{}) - case collections.DubboNetWorkV1Alpha1ConditionRoute.Resource().GroupVersionKind(): - return ic.DubboV1alpha1().ConditionRoutes(cfg.Namespace).Update(context.TODO(), &v1alpha1.ConditionRoute{ + case collections.DubboApacheOrgV1Alpha1ServiceNameMapping.Resource().GroupVersionKind(): + return ic.DubboV1alpha1().ServiceNameMappings(cfg.Namespace).Update(context.TODO(), &v1alpha1.ServiceNameMapping{ ObjectMeta: objMeta, - Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.ConditionRoute)), + Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.ServiceNameMapping)), + }, metav1.UpdateOptions{}) + case collections.DubboApacheOrgV1Alpha1TagRoute.Resource().GroupVersionKind(): + return ic.DubboV1alpha1().TagRoutes(cfg.Namespace).Update(context.TODO(), &v1alpha1.TagRoute{ + ObjectMeta: objMeta, + Spec: *(cfg.Spec.(*dubbo_apache_org_v1alpha1.TagRoute)), }, metav1.UpdateOptions{}) default: return nil, fmt.Errorf("unsupported type: %v", cfg.GroupVersionKind) } } -// only for test -// WARNING: if not test, do not use this function! func delete(ic versioned.Interface, typ model.GroupVersionKind, name, namespace string, resourceVersion *string) error { var deleteOptions metav1.DeleteOptions if resourceVersion != nil { deleteOptions.Preconditions = &metav1.Preconditions{ResourceVersion: resourceVersion} } switch typ { - case collections.DubboCAV1Alpha1Authorization.Resource().GroupVersionKind(): - return ic.DubboV1alpha1().AuthorizationPolicies(namespace).Delete(context.TODO(), name, deleteOptions) - case collections.DubboCAV1Alpha1Authentication.Resource().GroupVersionKind(): + case collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource().GroupVersionKind(): return ic.DubboV1alpha1().AuthenticationPolicies(namespace).Delete(context.TODO(), name, deleteOptions) - case collections.DubboServiceV1Alpha1ServiceMapping.Resource().GroupVersionKind(): - return ic.DubboV1alpha1().ServiceNameMappings(namespace).Delete(context.TODO(), name, deleteOptions) - case collections.DubboNetWorkV1Alpha1TagRoute.Resource().GroupVersionKind(): - return ic.DubboV1alpha1().TagRoutes(namespace).Delete(context.TODO(), name, deleteOptions) - case collections.DubboNetWorkV1Alpha1ConditionRoute.Resource().GroupVersionKind(): + case collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource().GroupVersionKind(): + return ic.DubboV1alpha1().AuthorizationPolicies(namespace).Delete(context.TODO(), name, deleteOptions) + case collections.DubboApacheOrgV1Alpha1ConditionRoute.Resource().GroupVersionKind(): return ic.DubboV1alpha1().ConditionRoutes(namespace).Delete(context.TODO(), name, deleteOptions) - case collections.DubboNetWorkV1Alpha1DynamicConfig.Resource().GroupVersionKind(): + case collections.DubboApacheOrgV1Alpha1DynamicConfig.Resource().GroupVersionKind(): return ic.DubboV1alpha1().DynamicConfigs(namespace).Delete(context.TODO(), name, deleteOptions) + case collections.DubboApacheOrgV1Alpha1ServiceNameMapping.Resource().GroupVersionKind(): + return ic.DubboV1alpha1().ServiceNameMappings(namespace).Delete(context.TODO(), name, deleteOptions) + case collections.DubboApacheOrgV1Alpha1TagRoute.Resource().GroupVersionKind(): + return ic.DubboV1alpha1().TagRoutes(namespace).Delete(context.TODO(), name, deleteOptions) default: return fmt.Errorf("unsupported type: %v", typ) } } var translationMap = map[model.GroupVersionKind]func(r runtime.Object) *model.Config{ - collections.DubboCAV1Alpha1Authentication.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { + collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { obj := r.(*v1alpha1.AuthenticationPolicy) return &model.Config{ Meta: model.Meta{ - GroupVersionKind: collections.DubboCAV1Alpha1Authentication.Resource().GroupVersionKind(), - UID: string(obj.UID), + GroupVersionKind: collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource().GroupVersionKind(), Name: obj.Name, Namespace: obj.Namespace, Labels: obj.Labels, @@ -147,18 +140,17 @@ var translationMap = map[model.GroupVersionKind]func(r runtime.Object) *model.Co ResourceVersion: obj.ResourceVersion, CreationTimestamp: obj.CreationTimestamp.Time, OwnerReferences: obj.OwnerReferences, + UID: string(obj.UID), Generation: obj.Generation, }, Spec: &obj.Spec, } }, - - collections.DubboCAV1Alpha1Authorization.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { + collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { obj := r.(*v1alpha1.AuthorizationPolicy) return &model.Config{ Meta: model.Meta{ - GroupVersionKind: collections.DubboCAV1Alpha1Authorization.Resource().GroupVersionKind(), - UID: string(obj.UID), + GroupVersionKind: collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource().GroupVersionKind(), Name: obj.Name, Namespace: obj.Namespace, Labels: obj.Labels, @@ -166,18 +158,17 @@ var translationMap = map[model.GroupVersionKind]func(r runtime.Object) *model.Co ResourceVersion: obj.ResourceVersion, CreationTimestamp: obj.CreationTimestamp.Time, OwnerReferences: obj.OwnerReferences, + UID: string(obj.UID), Generation: obj.Generation, }, Spec: &obj.Spec, } }, - - collections.DubboServiceV1Alpha1ServiceMapping.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { - obj := r.(*v1alpha1.ServiceNameMapping) + collections.DubboApacheOrgV1Alpha1ConditionRoute.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { + obj := r.(*v1alpha1.ConditionRoute) return &model.Config{ Meta: model.Meta{ - GroupVersionKind: collections.DubboServiceV1Alpha1ServiceMapping.Resource().GroupVersionKind(), - UID: string(obj.UID), + GroupVersionKind: collections.DubboApacheOrgV1Alpha1ConditionRoute.Resource().GroupVersionKind(), Name: obj.Name, Namespace: obj.Namespace, Labels: obj.Labels, @@ -185,18 +176,17 @@ var translationMap = map[model.GroupVersionKind]func(r runtime.Object) *model.Co ResourceVersion: obj.ResourceVersion, CreationTimestamp: obj.CreationTimestamp.Time, OwnerReferences: obj.OwnerReferences, + UID: string(obj.UID), Generation: obj.Generation, }, Spec: &obj.Spec, } }, - - collections.DubboNetWorkV1Alpha1TagRoute.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { - obj := r.(*v1alpha1.TagRoute) + collections.DubboApacheOrgV1Alpha1DynamicConfig.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { + obj := r.(*v1alpha1.DynamicConfig) return &model.Config{ Meta: model.Meta{ - GroupVersionKind: collections.DubboNetWorkV1Alpha1TagRoute.Resource().GroupVersionKind(), - UID: string(obj.UID), + GroupVersionKind: collections.DubboApacheOrgV1Alpha1DynamicConfig.Resource().GroupVersionKind(), Name: obj.Name, Namespace: obj.Namespace, Labels: obj.Labels, @@ -204,18 +194,17 @@ var translationMap = map[model.GroupVersionKind]func(r runtime.Object) *model.Co ResourceVersion: obj.ResourceVersion, CreationTimestamp: obj.CreationTimestamp.Time, OwnerReferences: obj.OwnerReferences, + UID: string(obj.UID), Generation: obj.Generation, }, Spec: &obj.Spec, } }, - - collections.DubboNetWorkV1Alpha1DynamicConfig.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { - obj := r.(*v1alpha1.DynamicConfig) + collections.DubboApacheOrgV1Alpha1ServiceNameMapping.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { + obj := r.(*v1alpha1.ServiceNameMapping) return &model.Config{ Meta: model.Meta{ - GroupVersionKind: collections.DubboNetWorkV1Alpha1DynamicConfig.Resource().GroupVersionKind(), - UID: string(obj.UID), + GroupVersionKind: collections.DubboApacheOrgV1Alpha1ServiceNameMapping.Resource().GroupVersionKind(), Name: obj.Name, Namespace: obj.Namespace, Labels: obj.Labels, @@ -223,18 +212,17 @@ var translationMap = map[model.GroupVersionKind]func(r runtime.Object) *model.Co ResourceVersion: obj.ResourceVersion, CreationTimestamp: obj.CreationTimestamp.Time, OwnerReferences: obj.OwnerReferences, + UID: string(obj.UID), Generation: obj.Generation, }, Spec: &obj.Spec, } }, - - collections.DubboNetWorkV1Alpha1ConditionRoute.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { - obj := r.(*v1alpha1.ConditionRoute) + collections.DubboApacheOrgV1Alpha1TagRoute.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { + obj := r.(*v1alpha1.TagRoute) return &model.Config{ Meta: model.Meta{ - GroupVersionKind: collections.DubboNetWorkV1Alpha1ConditionRoute.Resource().GroupVersionKind(), - UID: string(obj.UID), + GroupVersionKind: collections.DubboApacheOrgV1Alpha1TagRoute.Resource().GroupVersionKind(), Name: obj.Name, Namespace: obj.Namespace, Labels: obj.Labels, @@ -242,6 +230,7 @@ var translationMap = map[model.GroupVersionKind]func(r runtime.Object) *model.Co ResourceVersion: obj.ResourceVersion, CreationTimestamp: obj.CreationTimestamp.Time, OwnerReferences: obj.OwnerReferences, + UID: string(obj.UID), Generation: obj.Generation, }, Spec: &obj.Spec, diff --git a/pkg/dds/server/server.go b/pkg/dds/server/server.go index 46f5e9b96..c1b31cd78 100644 --- a/pkg/dds/server/server.go +++ b/pkg/dds/server/server.go @@ -64,19 +64,19 @@ func (s *DdsServer) Observe(stream dds.RuleService_ObserveServer) error { p, ok := peer.FromContext(stream.Context()) if !ok { - logger.Sugar().Errorf("failed to get peer from context") + logger.Sugar().Errorf("[DDS] failed to get peer from context") return fmt.Errorf("failed to get peer from context") } endpoints, err := endpoint2.ExactEndpoint(stream.Context(), s.CertStorage, s.Config, s.CertClient) if err != nil { - logger.Sugar().Errorf("failed to get endpoint from context: %v. RemoteAddr: %s", err, p.Addr) + logger.Sugar().Errorf("[DDS] failed to get endpoint from context: %v. RemoteAddr: %s", err, p.Addr) return err } c.endpoint = endpoints - logger.Sugar().Infof("New observe storage from %s", endpoints) + logger.Sugar().Infof("[DDS] New observe storage from %s", endpoints) s.Storage.Connected(endpoints, c) <-c.stopChan @@ -114,7 +114,7 @@ func (c *GrpcEndpointConnection) Send(targetRule *storage.VersionedRule, cr *sto select { case <-t.C: - logger.Infof("Timeout writing %s", c.endpoint.ID) + logger.Infof("[DDS] Timeout writing %s", c.endpoint.ID) return status.Errorf(codes.DeadlineExceeded, "timeout sending") case err := <-errChan: if err == nil { diff --git a/pkg/dds/storage/generate.go b/pkg/dds/storage/generate.go index ea9a9e21e..58f968fd7 100644 --- a/pkg/dds/storage/generate.go +++ b/pkg/dds/storage/generate.go @@ -21,6 +21,7 @@ import ( api "github.com/apache/dubbo-admin/api/resource/v1alpha1" "github.com/apache/dubbo-admin/pkg/core/endpoint" "github.com/apache/dubbo-admin/pkg/core/model" + "github.com/apache/dubbo-admin/pkg/core/tools/generate" "google.golang.org/protobuf/types/known/anypb" ) @@ -33,8 +34,12 @@ type AuthenticationGenerator struct{} func (g *AuthenticationGenerator) Generate(data []model.Config, endpoint *endpoint.Endpoint) ([]*anypb.Any, error) { res := make([]*anypb.Any, 0) for _, v := range data { - deepCopy := v.DeepCopy() - policy := deepCopy.Spec.(*api.AuthenticationPolicy) + policy := v.Spec.(*api.AuthenticationPolicy) + toClient := &api.AuthenticationPolicyToClient{ + Spec: &api.AuthenticationSpecToClient{}, + } + key := generate.GenerateKey(v.Name, v.Namespace) + toClient.Key = key if policy.GetSelector() != nil { match := true for _, selector := range policy.Selector { @@ -47,8 +52,18 @@ func (g *AuthenticationGenerator) Generate(data []model.Config, endpoint *endpoi continue } } - policy.Selector = nil - gogo, err := model.ToProtoGogo(policy) + toClient.Spec.Action = policy.Action + if policy.GetPortLevel() != nil { + toClient.Spec.PortLevel = make([]*api.AuthenticationPolicyPortLevel, 0, len(policy.PortLevel)) + for _, portLevel := range policy.PortLevel { + toClient.Spec.PortLevel = append(toClient.Spec.PortLevel, &api.AuthenticationPolicyPortLevel{ + Port: portLevel.Port, + Action: portLevel.Action, + }) + } + } + + gogo, err := model.ToProtoGogo(toClient) if err != nil { return nil, err } @@ -62,22 +77,50 @@ type AuthorizationGenerator struct{} func (g *AuthorizationGenerator) Generate(data []model.Config, endpoint *endpoint.Endpoint) ([]*anypb.Any, error) { res := make([]*anypb.Any, 0) for _, v := range data { - deepCopy := v.DeepCopy() - policy := deepCopy.Spec.(*api.AuthorizationPolicy) + policy := v.Spec.(*api.AuthorizationPolicy) + toClient := &api.AuthorizationPolicyToClient{} + key := generate.GenerateKey(v.Name, v.Namespace) + toClient.Key = key if policy.GetRules() != nil { match := true for _, policyRule := range policy.Rules { + if policyRule.GetTo() == nil { + policyRule.To = &api.AuthorizationPolicyTarget{} + } if !MatchAuthrSelector(policyRule.To, endpoint) { match = false break } - policyRule.To = nil } if !match { continue } + + toClient.Spec = &api.AuthorizationPolicySpecToClient{} + + toClient.Spec.Action = policy.Action + toClient.Spec.Samples = policy.Samples + toClient.Spec.Order = policy.Order + toClient.Spec.MatchType = policy.MatchType + + if policy.Rules != nil { + toClient.Spec.Rules = make([]*api.AuthorizationPolicyRuleToClient, 0, len(policy.Rules)) + for _, rule := range policy.Rules { + if rule.GetFrom() == nil { + rule.From = &api.AuthorizationPolicySource{} + } + if rule.GetWhen() == nil { + rule.When = &api.AuthorizationPolicyCondition{} + } + ruleToClient := &api.AuthorizationPolicyRuleToClient{ + From: rule.From.DeepCopy(), + When: rule.When.DeepCopy(), + } + toClient.Spec.Rules = append(toClient.Spec.Rules, ruleToClient) + } + } } - gogo, err := model.ToProtoGogo(policy) + gogo, err := model.ToProtoGogo(toClient) if err != nil { return nil, err } @@ -91,7 +134,11 @@ type ConditionRoutesGenerator struct{} func (g *ConditionRoutesGenerator) Generate(data []model.Config, endpoint *endpoint.Endpoint) ([]*anypb.Any, error) { res := make([]*anypb.Any, 0) for _, config := range data { - gogo, err := model.ToProtoGogo(config.Spec.(*api.ConditionRoute)) + toClient := &api.ConditionRouteToClient{} + key := generate.GenerateKey(config.Name, config.Namespace) + toClient.Key = key + toClient.Spec = config.Spec.(*api.ConditionRoute) + gogo, err := model.ToProtoGogo(toClient) if err != nil { return nil, err } @@ -105,7 +152,11 @@ type DynamicConfigsGenerator struct{} func (g *DynamicConfigsGenerator) Generate(data []model.Config, endpoint *endpoint.Endpoint) ([]*anypb.Any, error) { res := make([]*anypb.Any, 0) for _, config := range data { - gogo, err := model.ToProtoGogo(config.Spec.(*api.DynamicConfig)) + toClient := &api.DynamicConfigToClient{} + key := generate.GenerateKey(config.Name, config.Namespace) + toClient.Key = key + toClient.Spec = config.Spec.(*api.DynamicConfig) + gogo, err := model.ToProtoGogo(toClient) if err != nil { return nil, err } @@ -119,7 +170,11 @@ type ServiceMappingGenerator struct{} func (g *ServiceMappingGenerator) Generate(data []model.Config, endpoint *endpoint.Endpoint) ([]*anypb.Any, error) { res := make([]*anypb.Any, 0) for _, config := range data { - gogo, err := model.ToProtoGogo(config.Spec.(*api.ServiceNameMapping)) + toClient := &api.ServiceNameMappingToClient{} + key := generate.GenerateKey(config.Name, config.Namespace) + toClient.Key = key + toClient.Spec = config.Spec.(*api.ServiceNameMapping) + gogo, err := model.ToProtoGogo(toClient) if err != nil { return nil, err } @@ -133,7 +188,11 @@ type TagRoutesGenerator struct{} func (g *TagRoutesGenerator) Generate(data []model.Config, endpoint *endpoint.Endpoint) ([]*anypb.Any, error) { res := make([]*anypb.Any, 0) for _, config := range data { - gogo, err := model.ToProtoGogo(config.Spec.(*api.TagRoute)) + toClient := &api.TagRouteToClient{} + key := generate.GenerateKey(config.Name, config.Namespace) + toClient.Key = key + toClient.Spec = config.Spec.(*api.TagRoute) + gogo, err := model.ToProtoGogo(toClient) if err != nil { return nil, err } diff --git a/pkg/dds/storage/storage.go b/pkg/dds/storage/storage.go index 3324b7e4b..dea519410 100644 --- a/pkg/dds/storage/storage.go +++ b/pkg/dds/storage/storage.go @@ -47,9 +47,9 @@ type Storage struct { } func TypeSupported(gvk string) bool { - return gvk == gvks.Authentication || - gvk == gvks.Authorization || - gvk == gvks.ServiceMapping || + return gvk == gvks.AuthenticationPolicy || + gvk == gvks.AuthorizationPolicy || + gvk == gvks.ServiceNameMapping || gvk == gvks.TagRoute || gvk == gvks.DynamicConfig || gvk == gvks.ConditionRoute @@ -63,9 +63,9 @@ func NewStorage(cfg *dubbo_cp.Config) *Storage { Config: cfg, Generators: map[string]DdsResourceGenerator{}, } - s.Generators[gvks.Authentication] = &AuthenticationGenerator{} - s.Generators[gvks.Authorization] = &AuthorizationGenerator{} - s.Generators[gvks.ServiceMapping] = &ServiceMappingGenerator{} + s.Generators[gvks.AuthenticationPolicy] = &AuthenticationGenerator{} + s.Generators[gvks.AuthorizationPolicy] = &AuthorizationGenerator{} + s.Generators[gvks.ServiceNameMapping] = &ServiceMappingGenerator{} s.Generators[gvks.ConditionRoute] = &ConditionRoutesGenerator{} s.Generators[gvks.TagRoute] = &TagRoutesGenerator{} s.Generators[gvks.DynamicConfig] = &DynamicConfigsGenerator{} @@ -84,8 +84,6 @@ func (s *Storage) Connected(endpoint *endpoint.Endpoint, connection EndpointConn RawRuleQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "raw-dds"), ExpectedRules: map[string]*VersionedRule{}, ClientRules: map[string]*ClientStatus{}, - DdsBlockMaxTime: s.Config.Options.DdsBlockMaxTime, - BlockedPushed: make([]Origin, 0), blockedPushedMutex: &sync.RWMutex{}, Generator: s.Generators, } @@ -124,13 +122,13 @@ func (s *Storage) listenConnection(c *Connection) { func (s *Storage) HandleRequest(c *Connection, req *dds.ObserveRequest) { if req.Type == "" { - logger.Sugar().Errorf("Empty request type from %v", c.Endpoint.ID) + logger.Sugar().Errorf("[DDS] Empty request type from %v", c.Endpoint.ID) return } if !TypeSupported(req.Type) { - logger.Sugar().Errorf("Unsupported request type %s from %s", req.Type, c.Endpoint.ID) + logger.Sugar().Errorf("[DDS] Unsupported request type %s from %s", req.Type, c.Endpoint.ID) return } @@ -141,13 +139,13 @@ func (s *Storage) HandleRequest(c *Connection, req *dds.ObserveRequest) { cr := c.ClientRules[req.Type] if cr == nil { - logger.Sugar().Errorf("Unexpected request type %s with nonce %s from %s", req.Type, req.Nonce, c.Endpoint.ID) + logger.Sugar().Errorf("[DDS] Unexpected request type %s with nonce %s from %s", req.Type, req.Nonce, c.Endpoint.ID) return } if cr.PushingStatus == Pushing { if cr.LastPushNonce != req.Nonce { - logger.Sugar().Errorf("Unexpected request nonce %s from %s", req.Nonce, c.Endpoint.ID) + logger.Sugar().Errorf("[DDS] Unexpected request nonce %s from %s", req.Nonce, c.Endpoint.ID) return } @@ -155,21 +153,13 @@ func (s *Storage) HandleRequest(c *Connection, req *dds.ObserveRequest) { cr.ClientVersion = cr.LastPushedVersion cr.PushingStatus = Pushed - cr.StatusChan <- struct{}{} - logger.Sugar().Infof("Client %s pushed %s dds %d success", c.Endpoint.Ips, req.Type, cr.ClientVersion.Revision) - // At this time, we should judge whether there is a blocked request in the blocking queue, - // and if so, it should be sent to the dubbo side - for len(c.BlockedPushed) > 0 { - rule := c.BlockedPushed[0] - c.RawRuleQueue.Add(rule) - c.BlockedPushed = c.BlockedPushed[1:] - } + logger.Sugar().Infof("[DDS] Client %s pushed %s dds %d success", c.Endpoint.Ips, req.Type, cr.ClientVersion.Revision) } return } if _, ok := c.TypeListened[req.Type]; !ok { - logger.Sugar().Infof("Client %s listen %s dds", c.Endpoint.Ips, req.Type) + logger.Sugar().Infof("[DDS] Client %s listen %s dds", c.Endpoint.Ips, req.Type) c.TypeListened[req.Type] = true c.ClientRules[req.Type] = &ClientStatus{ PushingStatus: Pushed, @@ -181,10 +171,7 @@ func (s *Storage) HandleRequest(c *Connection, req *dds.ObserveRequest) { LastPushedTime: 0, LastPushedVersion: nil, LastPushNonce: "", - StatusChan: make(chan struct{}, 1), } - cr := c.ClientRules[req.Type] - cr.StatusChan <- struct{}{} latestRule := s.LatestRules[req.Type] if latestRule != nil { c.RawRuleQueue.Add(latestRule) @@ -207,18 +194,18 @@ func (c *Connection) listenRule() { var ok bool if key, ok = obj.(Origin); !ok { - logger.Sugar().Errorf("expected dds.Origin in workqueue but got %#v", obj) + logger.Sugar().Errorf("[DDS] expected dds.Origin in workqueue but got %#v", obj) return } if err := c.handleRule(key); err != nil { - logger.Sugar().Errorf("error syncing '%s': %s", key, err.Error()) + logger.Sugar().Errorf("[DDS] error syncing '%s': %s", key, err.Error()) return } - logger.Sugar().Infof("Successfully synced '%s'", key) + logger.Sugar().Infof("[DDS] Successfully synced '%s'", key) }(obj) } } @@ -235,30 +222,17 @@ func (c *Connection) handleRule(rawRule Origin) error { cr := c.ClientRules[targetRule.Type] - maxBlockingTime := c.DdsBlockMaxTime - - // can be modified via environment - t := time.NewTimer(maxBlockingTime) - select { - case <-t.C: + // TODO how to improve this one + for cr.PushingStatus == Pushing { cr.PushQueued = true - // dds has been blocked for too long, perhaps because the dubbo side is very busy now, - // and we have not received the ACK of the last push. - // so, instead of pushing now, which may overload dubbo, - // we will wait until the last push is ACK and trigger the push - logger.Sugar().Warnf("QUEUE for node:%s", c.Endpoint.ID) - c.blockedPushedMutex.Lock() - c.BlockedPushed = append(c.BlockedPushed, rawRule) - c.blockedPushedMutex.Unlock() - // then we should return this function - return nil - case <-cr.StatusChan: - cr.PushQueued = false + time.Sleep(1 * time.Second) + logger.Sugar().Infof("[DDS] Client %s %s rule is pushing, wait for 1 second", c.Endpoint.Ips, targetRule.Type) } + cr.PushQueued = false if cr.ClientVersion.Data != nil && (reflect.DeepEqual(cr.ClientVersion.Data, targetRule.Data) || cr.ClientVersion.Revision >= targetRule.Revision) { - logger.Sugar().Infof("Client %s %s dds is up to date", c.Endpoint.Ips, targetRule.Type) + logger.Sugar().Infof("[DDS] Client %s %s dds is up to date", c.Endpoint.Ips, targetRule.Type) return nil } newVersion := atomic.AddInt64(&cr.NonceInc, 1) @@ -269,7 +243,7 @@ func (c *Connection) handleRule(rawRule Origin) error { Data: targetRule.Data, } - logger.Sugar().Infof("Receive new version dds. Client %s %s dds is pushing.", c.Endpoint.Ips, targetRule.Type) + logger.Sugar().Infof("[DDS] Receive new version dds. Client %s %s dds is pushing.", c.Endpoint.Ips, targetRule.Type) return c.EndpointConnection.Send(targetRule, cr, r) } @@ -309,15 +283,9 @@ type Connection struct { TypeListened map[string]bool - RawRuleQueue workqueue.RateLimitingInterface - ExpectedRules map[string]*VersionedRule - ClientRules map[string]*ClientStatus - DdsBlockMaxTime time.Duration - - // blockedPushes is a map of TypeUrl to push request. This is set when we attempt to push to a busy Dubbo - // (last push not ACKed). When we get an ACK from Dubbo, if the type is populated here, we will trigger - // the push. - BlockedPushed []Origin + RawRuleQueue workqueue.RateLimitingInterface + ExpectedRules map[string]*VersionedRule + ClientRules map[string]*ClientStatus blockedPushedMutex *sync.RWMutex } @@ -338,7 +306,6 @@ type ClientStatus struct { sync.RWMutex PushQueued bool PushingStatus PushingStatus - StatusChan chan struct{} NonceInc int64 diff --git a/pkg/dds/storage/storage_test.go b/pkg/dds/storage/storage_test.go index f92b6716d..e6fc6f530 100644 --- a/pkg/dds/storage/storage_test.go +++ b/pkg/dds/storage/storage_test.go @@ -25,6 +25,8 @@ import ( "testing" "time" + "github.com/apache/dubbo-admin/pkg/config/option" + "github.com/apache/dubbo-admin/api/dds" dubboapacheorgv1alpha1 "github.com/apache/dubbo-admin/api/resource/v1alpha1" dubbocp "github.com/apache/dubbo-admin/pkg/config/app/dubbo-cp" @@ -77,7 +79,11 @@ func (f *fakeConnection) Disconnect() { func TestStorage_CloseEOF(t *testing.T) { t.Parallel() - s := storage.NewStorage(&dubbocp.Config{}) + s := storage.NewStorage(&dubbocp.Config{ + Options: option.Options{ + DdsBlockMaxTime: 15000000000, + }, + }) fake := &fakeConnection{ recvChan: make(chan recvResult, 1), } @@ -103,7 +109,11 @@ func TestStorage_CloseEOF(t *testing.T) { func TestStorage_CloseErr(t *testing.T) { t.Parallel() - s := storage.NewStorage(&dubbocp.Config{}) + s := storage.NewStorage(&dubbocp.Config{ + Options: option.Options{ + DdsBlockMaxTime: 15000000000, + }, + }) fake := &fakeConnection{ recvChan: make(chan recvResult, 1), } @@ -129,7 +139,11 @@ func TestStorage_CloseErr(t *testing.T) { func TestStorage_UnknowType(t *testing.T) { t.Parallel() - s := storage.NewStorage(&dubbocp.Config{}) + s := storage.NewStorage(&dubbocp.Config{ + Options: option.Options{ + DdsBlockMaxTime: 15000000000, + }, + }) fake := &fakeConnection{ recvChan: make(chan recvResult, 1), } @@ -173,7 +187,11 @@ func TestStorage_UnknowType(t *testing.T) { func TestStorage_StartNonEmptyNonce(t *testing.T) { t.Parallel() - s := storage.NewStorage(&dubbocp.Config{}) + s := storage.NewStorage(&dubbocp.Config{ + Options: option.Options{ + DdsBlockMaxTime: 15000000000, + }, + }) fake := &fakeConnection{ recvChan: make(chan recvResult, 1), } @@ -185,7 +203,7 @@ func TestStorage_StartNonEmptyNonce(t *testing.T) { fake.recvChan <- recvResult{ request: &dds.ObserveRequest{ Nonce: "test", - Type: gvk.Authentication, + Type: gvk.AuthenticationPolicy, }, err: nil, } @@ -208,7 +226,11 @@ func TestStorage_StartNonEmptyNonce(t *testing.T) { func TestStorage_Listen(t *testing.T) { t.Parallel() - s := storage.NewStorage(&dubbocp.Config{}) + s := storage.NewStorage(&dubbocp.Config{ + Options: option.Options{ + DdsBlockMaxTime: 15000000000, + }, + }) fake := &fakeConnection{ recvChan: make(chan recvResult, 1), } @@ -220,7 +242,7 @@ func TestStorage_Listen(t *testing.T) { fake.recvChan <- recvResult{ request: &dds.ObserveRequest{ Nonce: "", - Type: gvk.Authorization, + Type: gvk.AuthorizationPolicy, }, err: nil, } @@ -240,7 +262,7 @@ func TestStorage_Listen(t *testing.T) { t.Error("expected type listened") } - if !conn.TypeListened[gvk.Authorization] { + if !conn.TypeListened[gvk.AuthorizationPolicy] { t.Error("expected type listened") } } @@ -315,7 +337,11 @@ func TestStorage_PreNotify(t *testing.T) { } return nil }, timeout) - s := storage.NewStorage(&dubbocp.Config{}) + s := storage.NewStorage(&dubbocp.Config{ + Options: option.Options{ + DdsBlockMaxTime: 15000000000, + }, + }) handler := crdclient.NewHandler(s, "dubbo-demo", store) err = handler.NotifyWithIndex(c) @@ -416,7 +442,7 @@ func TestStorage_AfterNotify(t *testing.T) { if err != nil { t.Fatal(err) } - if r.GroupVersionKind().String() == gvk.ServiceMapping { + if r.GroupVersionKind().String() == gvk.ServiceNameMapping { mapping := pb.(*dubboapacheorgv1alpha1.ServiceNameMapping) mapping.InterfaceName = "test" mapping.ApplicationNames = []string{ @@ -437,8 +463,11 @@ func TestStorage_AfterNotify(t *testing.T) { } return nil }, timeout) - s := storage.NewStorage(&dubbocp.Config{}) - + s := storage.NewStorage(&dubbocp.Config{ + Options: option.Options{ + DdsBlockMaxTime: 15000000000, + }, + }) handler := crdclient.NewHandler(s, "dubbo-demo", store) fake := &fakeConnection{ @@ -526,10 +555,10 @@ func TestStore_MissNotify(t *testing.T) { store := makeClient(t, collections.Rule) configName := "name" configNamespace := "namespace" - collection.NewSchemasBuilder().MustAdd(collections.DubboNetWorkV1Alpha1TagRoute).Build() - tag := collections.DubboNetWorkV1Alpha1TagRoute.Resource() - collection.NewSchemasBuilder().MustAdd(collections.DubboNetWorkV1Alpha1ConditionRoute).Build() - condition := collections.DubboNetWorkV1Alpha1ConditionRoute.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1TagRoute).Build() + tag := collections.DubboApacheOrgV1Alpha1TagRoute.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1ConditionRoute).Build() + condition := collections.DubboApacheOrgV1Alpha1ConditionRoute.Resource() tagconfigMeta := model.Meta{ GroupVersionKind: tag.GroupVersionKind(), Name: configName, @@ -565,8 +594,11 @@ func TestStore_MissNotify(t *testing.T) { t.Fatalf("Create(%v) => got %v", tag.Kind(), err) } - s := storage.NewStorage(&dubbocp.Config{}) - + s := storage.NewStorage(&dubbocp.Config{ + Options: option.Options{ + DdsBlockMaxTime: 15000000000, + }, + }) tagHanlder := crdclient.NewHandler(s, "dubbo-demo", store) conditionHandler := crdclient.NewHandler(s, "dubbo-demo", store) @@ -592,10 +624,10 @@ func TestStore_MissNotify(t *testing.T) { return conn.TypeListened[condition.GroupVersionKind().String()] }, 10*time.Second, time.Millisecond) - if err := conditionHandler.NotifyWithIndex(collections.DubboNetWorkV1Alpha1ConditionRoute); err != nil { + if err := conditionHandler.NotifyWithIndex(collections.DubboApacheOrgV1Alpha1ConditionRoute); err != nil { t.Fatal(err) } - if err := tagHanlder.NotifyWithIndex(collections.DubboNetWorkV1Alpha1TagRoute); err != nil { + if err := tagHanlder.NotifyWithIndex(collections.DubboApacheOrgV1Alpha1TagRoute); err != nil { t.Fatal(err) } @@ -690,8 +722,11 @@ func (e errOrigin) Exact(gen map[string]storage.DdsResourceGenerator, endpoint * func TestStorage_MulitiNotify(t *testing.T) { t.Parallel() - s := storage.NewStorage(&dubbocp.Config{}) - + s := storage.NewStorage(&dubbocp.Config{ + Options: option.Options{ + DdsBlockMaxTime: 15000000000, + }, + }) fake := &fakeConnection{ recvChan: make(chan recvResult, 1), } @@ -832,9 +867,9 @@ func TestStorage_Exact(t *testing.T) { } gen := map[string]storage.DdsResourceGenerator{} - gen[gvk.Authentication] = &storage.AuthenticationGenerator{} - gen[gvk.Authorization] = &storage.AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &storage.ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &storage.AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &storage.AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &storage.ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &storage.ConditionRoutesGenerator{} gen[gvk.TagRoute] = &storage.TagRoutesGenerator{} gen[gvk.DynamicConfig] = &storage.DynamicConfigsGenerator{} @@ -854,8 +889,8 @@ func TestStorage_ReturnMisNonce(t *testing.T) { store := makeClient(t, collections.Rule) configName := "name" configNamespace := "namespace" - collection.NewSchemasBuilder().MustAdd(collections.DubboNetWorkV1Alpha1TagRoute).Build() - tag := collections.DubboNetWorkV1Alpha1TagRoute.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1TagRoute).Build() + tag := collections.DubboApacheOrgV1Alpha1TagRoute.Resource() tagconfigMeta := model.Meta{ GroupVersionKind: tag.GroupVersionKind(), Name: configName, @@ -877,10 +912,13 @@ func TestStorage_ReturnMisNonce(t *testing.T) { t.Fatalf("Create(%v) => got %v", tag.Kind(), err) } - s := storage.NewStorage(&dubbocp.Config{}) - + s := storage.NewStorage(&dubbocp.Config{ + Options: option.Options{ + DdsBlockMaxTime: 15000000000, + }, + }) tagHanlder := crdclient.NewHandler(s, "dubbo-system", store) - err = tagHanlder.NotifyWithIndex(collections.DubboNetWorkV1Alpha1TagRoute) + err = tagHanlder.NotifyWithIndex(collections.DubboApacheOrgV1Alpha1TagRoute) if err != nil { t.Fatal(err) } diff --git a/pkg/dds/storage/validate_test.go b/pkg/dds/storage/validate_test.go index 061b49497..1fc396831 100644 --- a/pkg/dds/storage/validate_test.go +++ b/pkg/dds/storage/validate_test.go @@ -33,8 +33,8 @@ import ( func TestAuthenticationSelect_Empty(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -55,7 +55,7 @@ func TestAuthenticationSelect_Empty(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -66,9 +66,9 @@ func TestAuthenticationSelect_Empty(t *testing.T) { } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -76,7 +76,7 @@ func TestAuthenticationSelect_Empty(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -84,14 +84,15 @@ func TestAuthenticationSelect_Empty(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) - assert.Equal(t, 1, len(authentication.PortLevel)) - assert.Equal(t, "DENY", authentication.PortLevel[0].Action) + assert.Equal(t, "name/ns", authentication.Key) + assert.Equal(t, "ALLOW", authentication.Spec.Action) + assert.Equal(t, 1, len(authentication.Spec.PortLevel)) + assert.Equal(t, "DENY", authentication.Spec.PortLevel[0].Action) } } } @@ -99,8 +100,8 @@ func TestAuthenticationSelect_Empty(t *testing.T) { func TestAuthenticationSelect_NoSelector(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -115,7 +116,7 @@ func TestAuthenticationSelect_NoSelector(t *testing.T) { policy.Action = "ALLOW" origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -125,9 +126,9 @@ func TestAuthenticationSelect_NoSelector(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -139,7 +140,7 @@ func TestAuthenticationSelect_NoSelector(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -147,12 +148,13 @@ func TestAuthenticationSelect_NoSelector(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "name/ns", authentication.Key) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } } @@ -160,8 +162,8 @@ func TestAuthenticationSelect_NoSelector(t *testing.T) { func TestAuthenticationSelect_Namespace(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -181,7 +183,7 @@ func TestAuthenticationSelect_Namespace(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -191,9 +193,9 @@ func TestAuthenticationSelect_Namespace(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -205,7 +207,7 @@ func TestAuthenticationSelect_Namespace(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -213,12 +215,12 @@ func TestAuthenticationSelect_Namespace(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } @@ -230,15 +232,15 @@ func TestAuthenticationSelect_Namespace(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) } func TestAuthenticationSelect_EndpointNil(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -258,7 +260,7 @@ func TestAuthenticationSelect_EndpointNil(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -268,9 +270,9 @@ func TestAuthenticationSelect_EndpointNil(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -278,7 +280,7 @@ func TestAuthenticationSelect_EndpointNil(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -286,12 +288,12 @@ func TestAuthenticationSelect_EndpointNil(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } } @@ -299,8 +301,8 @@ func TestAuthenticationSelect_EndpointNil(t *testing.T) { func TestAuthenticationSelect_NotNamespace(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -320,7 +322,7 @@ func TestAuthenticationSelect_NotNamespace(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -330,9 +332,9 @@ func TestAuthenticationSelect_NotNamespace(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -344,7 +346,7 @@ func TestAuthenticationSelect_NotNamespace(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -352,7 +354,7 @@ func TestAuthenticationSelect_NotNamespace(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) @@ -367,7 +369,7 @@ func TestAuthenticationSelect_NotNamespace(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data1 := generated.Data @@ -375,12 +377,12 @@ func TestAuthenticationSelect_NotNamespace(t *testing.T) { for _, anyMessage := range data1 { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } } @@ -388,8 +390,8 @@ func TestAuthenticationSelect_NotNamespace(t *testing.T) { func TestAuthenticationSelect_IpBlocks_ErrFmt(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -409,7 +411,7 @@ func TestAuthenticationSelect_IpBlocks_ErrFmt(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -419,9 +421,9 @@ func TestAuthenticationSelect_IpBlocks_ErrFmt(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -431,7 +433,7 @@ func TestAuthenticationSelect_IpBlocks_ErrFmt(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -439,7 +441,7 @@ func TestAuthenticationSelect_IpBlocks_ErrFmt(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) @@ -453,7 +455,7 @@ func TestAuthenticationSelect_IpBlocks_ErrFmt(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data1 := generated.Data @@ -461,7 +463,7 @@ func TestAuthenticationSelect_IpBlocks_ErrFmt(t *testing.T) { for _, anyMessage := range data1 { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) @@ -473,8 +475,8 @@ func TestAuthenticationSelect_IpBlocks_ErrFmt(t *testing.T) { func TestAuthenticationSelect_IpBlocks(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -494,7 +496,7 @@ func TestAuthenticationSelect_IpBlocks(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -504,9 +506,9 @@ func TestAuthenticationSelect_IpBlocks(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -516,7 +518,7 @@ func TestAuthenticationSelect_IpBlocks(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -524,12 +526,12 @@ func TestAuthenticationSelect_IpBlocks(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } @@ -539,7 +541,7 @@ func TestAuthenticationSelect_IpBlocks(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data1 := generated.Data @@ -547,7 +549,7 @@ func TestAuthenticationSelect_IpBlocks(t *testing.T) { for _, anyMessage := range data1 { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) @@ -560,8 +562,8 @@ func TestAuthenticationSelect_IpBlocks(t *testing.T) { func TestAuthenticationSelect_NotIpBlocks_ErrFmt(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -581,7 +583,7 @@ func TestAuthenticationSelect_NotIpBlocks_ErrFmt(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -591,9 +593,9 @@ func TestAuthenticationSelect_NotIpBlocks_ErrFmt(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -603,7 +605,7 @@ func TestAuthenticationSelect_NotIpBlocks_ErrFmt(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -611,12 +613,12 @@ func TestAuthenticationSelect_NotIpBlocks_ErrFmt(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } @@ -626,7 +628,7 @@ func TestAuthenticationSelect_NotIpBlocks_ErrFmt(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data1 := generated.Data @@ -634,12 +636,12 @@ func TestAuthenticationSelect_NotIpBlocks_ErrFmt(t *testing.T) { for _, anyMessage := range data1 { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } } @@ -647,8 +649,8 @@ func TestAuthenticationSelect_NotIpBlocks_ErrFmt(t *testing.T) { func TestAuthenticationSelect_Principals(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -668,7 +670,7 @@ func TestAuthenticationSelect_Principals(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -678,9 +680,9 @@ func TestAuthenticationSelect_Principals(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -690,7 +692,7 @@ func TestAuthenticationSelect_Principals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -698,7 +700,7 @@ func TestAuthenticationSelect_Principals(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) @@ -713,7 +715,7 @@ func TestAuthenticationSelect_Principals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data1 := generated.Data @@ -721,12 +723,12 @@ func TestAuthenticationSelect_Principals(t *testing.T) { for _, anyMessage := range data1 { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } @@ -736,18 +738,18 @@ func TestAuthenticationSelect_Principals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) for _, anyMessage := range data1 { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } } @@ -755,8 +757,8 @@ func TestAuthenticationSelect_Principals(t *testing.T) { func TestAuthenticationSelect_NotPrincipals(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -776,7 +778,7 @@ func TestAuthenticationSelect_NotPrincipals(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -786,9 +788,9 @@ func TestAuthenticationSelect_NotPrincipals(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -798,7 +800,7 @@ func TestAuthenticationSelect_NotPrincipals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -806,12 +808,12 @@ func TestAuthenticationSelect_NotPrincipals(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } @@ -821,7 +823,7 @@ func TestAuthenticationSelect_NotPrincipals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data1 := generated.Data @@ -829,7 +831,7 @@ func TestAuthenticationSelect_NotPrincipals(t *testing.T) { for _, anyMessage := range data1 { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) @@ -844,13 +846,13 @@ func TestAuthenticationSelect_NotPrincipals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) for _, anyMessage := range data1 { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) @@ -863,8 +865,8 @@ func TestAuthenticationSelect_NotPrincipals(t *testing.T) { func TestAuthenticationSelect_Extends(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -889,7 +891,7 @@ func TestAuthenticationSelect_Extends(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -899,9 +901,9 @@ func TestAuthenticationSelect_Extends(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -913,7 +915,7 @@ func TestAuthenticationSelect_Extends(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -921,12 +923,12 @@ func TestAuthenticationSelect_Extends(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } @@ -936,7 +938,7 @@ func TestAuthenticationSelect_Extends(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data1 := generated.Data @@ -944,7 +946,7 @@ func TestAuthenticationSelect_Extends(t *testing.T) { for _, anyMessage := range data1 { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) @@ -959,13 +961,13 @@ func TestAuthenticationSelect_Extends(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) for _, anyMessage := range data1 { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) @@ -978,8 +980,8 @@ func TestAuthenticationSelect_Extends(t *testing.T) { func TestAuthenticationSelect_NotExtends(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authentication).Build() - r := collections.DubboCAV1Alpha1Authentication.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthenticationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthenticationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -1004,7 +1006,7 @@ func TestAuthenticationSelect_NotExtends(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authentication, + Gvk: gvk.AuthenticationPolicy, Rev: 1, Data: []model.Config{ { @@ -1014,9 +1016,9 @@ func TestAuthenticationSelect_NotExtends(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -1028,7 +1030,7 @@ func TestAuthenticationSelect_NotExtends(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -1036,7 +1038,7 @@ func TestAuthenticationSelect_NotExtends(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) @@ -1053,7 +1055,7 @@ func TestAuthenticationSelect_NotExtends(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authentication) + assert.Equal(t, generated.Type, gvk.AuthenticationPolicy) assert.Equal(t, generated.Revision, int64(1)) data1 := generated.Data @@ -1061,12 +1063,12 @@ func TestAuthenticationSelect_NotExtends(t *testing.T) { for _, anyMessage := range data1 { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthenticationTypeUrl { - authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicy{} + authentication := &dubbo_apache_org_v1alpha1.AuthenticationPolicyToClient{} err := proto.Unmarshal(valBytes, authentication) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authentication.Action) + assert.Equal(t, "ALLOW", authentication.Spec.Action) } } } @@ -1074,8 +1076,8 @@ func TestAuthenticationSelect_NotExtends(t *testing.T) { func TestAuthorization_Empty(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authorization).Build() - r := collections.DubboCAV1Alpha1Authorization.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthorizationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -1091,7 +1093,7 @@ func TestAuthorization_Empty(t *testing.T) { policy.Rules = []*dubbo_apache_org_v1alpha1.AuthorizationPolicyRule{} origin := &OriginImpl{ - Gvk: gvk.Authorization, + Gvk: gvk.AuthorizationPolicy, Rev: 1, Data: []model.Config{ { @@ -1101,9 +1103,9 @@ func TestAuthorization_Empty(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -1111,7 +1113,7 @@ func TestAuthorization_Empty(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -1119,12 +1121,12 @@ func TestAuthorization_Empty(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } } @@ -1132,8 +1134,8 @@ func TestAuthorization_Empty(t *testing.T) { func TestAuthorization_Namespace(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authorization).Build() - r := collections.DubboCAV1Alpha1Authorization.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthorizationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -1156,7 +1158,7 @@ func TestAuthorization_Namespace(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authorization, + Gvk: gvk.AuthorizationPolicy, Rev: 1, Data: []model.Config{ { @@ -1166,9 +1168,9 @@ func TestAuthorization_Namespace(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -1177,7 +1179,7 @@ func TestAuthorization_Namespace(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -1185,12 +1187,12 @@ func TestAuthorization_Namespace(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -1203,7 +1205,7 @@ func TestAuthorization_Namespace(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1211,7 +1213,7 @@ func TestAuthorization_Namespace(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -1227,7 +1229,7 @@ func TestAuthorization_Namespace(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1235,7 +1237,7 @@ func TestAuthorization_Namespace(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -1248,8 +1250,8 @@ func TestAuthorization_Namespace(t *testing.T) { func TestAuthorization_NotNamespace(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authorization).Build() - r := collections.DubboCAV1Alpha1Authorization.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthorizationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -1274,7 +1276,7 @@ func TestAuthorization_NotNamespace(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authorization, + Gvk: gvk.AuthorizationPolicy, Rev: 1, Data: []model.Config{ { @@ -1284,9 +1286,9 @@ func TestAuthorization_NotNamespace(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -1299,7 +1301,7 @@ func TestAuthorization_NotNamespace(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -1307,12 +1309,12 @@ func TestAuthorization_NotNamespace(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -1325,7 +1327,7 @@ func TestAuthorization_NotNamespace(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1333,7 +1335,7 @@ func TestAuthorization_NotNamespace(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -1349,7 +1351,7 @@ func TestAuthorization_NotNamespace(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1357,12 +1359,12 @@ func TestAuthorization_NotNamespace(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } } @@ -1370,8 +1372,8 @@ func TestAuthorization_NotNamespace(t *testing.T) { func TestAuthorization_IPBlocks(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authorization).Build() - r := collections.DubboCAV1Alpha1Authorization.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthorizationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -1396,7 +1398,7 @@ func TestAuthorization_IPBlocks(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authorization, + Gvk: gvk.AuthorizationPolicy, Rev: 1, Data: []model.Config{ { @@ -1406,9 +1408,9 @@ func TestAuthorization_IPBlocks(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -1419,7 +1421,7 @@ func TestAuthorization_IPBlocks(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -1427,12 +1429,12 @@ func TestAuthorization_IPBlocks(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -1443,7 +1445,7 @@ func TestAuthorization_IPBlocks(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1451,7 +1453,7 @@ func TestAuthorization_IPBlocks(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -1467,7 +1469,7 @@ func TestAuthorization_IPBlocks(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1475,7 +1477,7 @@ func TestAuthorization_IPBlocks(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -1489,7 +1491,7 @@ func TestAuthorization_IPBlocks(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1497,7 +1499,7 @@ func TestAuthorization_IPBlocks(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -1510,8 +1512,8 @@ func TestAuthorization_IPBlocks(t *testing.T) { func TestAuthorization_ErrFmt(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authorization).Build() - r := collections.DubboCAV1Alpha1Authorization.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthorizationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -1536,7 +1538,7 @@ func TestAuthorization_ErrFmt(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authorization, + Gvk: gvk.AuthorizationPolicy, Rev: 1, Data: []model.Config{ { @@ -1546,9 +1548,9 @@ func TestAuthorization_ErrFmt(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -1559,7 +1561,7 @@ func TestAuthorization_ErrFmt(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -1567,7 +1569,7 @@ func TestAuthorization_ErrFmt(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -1583,7 +1585,7 @@ func TestAuthorization_ErrFmt(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1591,7 +1593,7 @@ func TestAuthorization_ErrFmt(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -1605,7 +1607,7 @@ func TestAuthorization_ErrFmt(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1613,7 +1615,7 @@ func TestAuthorization_ErrFmt(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -1626,8 +1628,8 @@ func TestAuthorization_ErrFmt(t *testing.T) { func TestAuthorization_NotIPBlocks(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authorization).Build() - r := collections.DubboCAV1Alpha1Authorization.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthorizationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -1652,7 +1654,7 @@ func TestAuthorization_NotIPBlocks(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authorization, + Gvk: gvk.AuthorizationPolicy, Rev: 1, Data: []model.Config{ { @@ -1662,9 +1664,9 @@ func TestAuthorization_NotIPBlocks(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -1675,7 +1677,7 @@ func TestAuthorization_NotIPBlocks(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -1683,12 +1685,12 @@ func TestAuthorization_NotIPBlocks(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -1699,7 +1701,7 @@ func TestAuthorization_NotIPBlocks(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1707,12 +1709,12 @@ func TestAuthorization_NotIPBlocks(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -1723,7 +1725,7 @@ func TestAuthorization_NotIPBlocks(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1731,7 +1733,7 @@ func TestAuthorization_NotIPBlocks(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -1744,8 +1746,8 @@ func TestAuthorization_NotIPBlocks(t *testing.T) { func TestAuthorization_NotIPBlocks_ErrFmt(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authorization).Build() - r := collections.DubboCAV1Alpha1Authorization.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthorizationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -1770,7 +1772,7 @@ func TestAuthorization_NotIPBlocks_ErrFmt(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authorization, + Gvk: gvk.AuthorizationPolicy, Rev: 1, Data: []model.Config{ { @@ -1780,9 +1782,9 @@ func TestAuthorization_NotIPBlocks_ErrFmt(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -1793,7 +1795,7 @@ func TestAuthorization_NotIPBlocks_ErrFmt(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -1801,12 +1803,12 @@ func TestAuthorization_NotIPBlocks_ErrFmt(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -1817,7 +1819,7 @@ func TestAuthorization_NotIPBlocks_ErrFmt(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1825,12 +1827,12 @@ func TestAuthorization_NotIPBlocks_ErrFmt(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -1839,7 +1841,7 @@ func TestAuthorization_NotIPBlocks_ErrFmt(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1847,12 +1849,12 @@ func TestAuthorization_NotIPBlocks_ErrFmt(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } } @@ -1860,8 +1862,8 @@ func TestAuthorization_NotIPBlocks_ErrFmt(t *testing.T) { func TestAuthorization_Principals(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authorization).Build() - r := collections.DubboCAV1Alpha1Authorization.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthorizationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -1886,7 +1888,7 @@ func TestAuthorization_Principals(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authorization, + Gvk: gvk.AuthorizationPolicy, Rev: 1, Data: []model.Config{ { @@ -1896,9 +1898,9 @@ func TestAuthorization_Principals(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -1909,7 +1911,7 @@ func TestAuthorization_Principals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -1917,12 +1919,12 @@ func TestAuthorization_Principals(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -1933,7 +1935,7 @@ func TestAuthorization_Principals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1941,12 +1943,12 @@ func TestAuthorization_Principals(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -1957,7 +1959,7 @@ func TestAuthorization_Principals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1965,7 +1967,7 @@ func TestAuthorization_Principals(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -1979,7 +1981,7 @@ func TestAuthorization_Principals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -1987,7 +1989,7 @@ func TestAuthorization_Principals(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -2000,8 +2002,8 @@ func TestAuthorization_Principals(t *testing.T) { func TestAuthorization_NotPrincipals(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authorization).Build() - r := collections.DubboCAV1Alpha1Authorization.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthorizationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -2026,7 +2028,7 @@ func TestAuthorization_NotPrincipals(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authorization, + Gvk: gvk.AuthorizationPolicy, Rev: 1, Data: []model.Config{ { @@ -2036,9 +2038,9 @@ func TestAuthorization_NotPrincipals(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -2049,7 +2051,7 @@ func TestAuthorization_NotPrincipals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -2057,12 +2059,12 @@ func TestAuthorization_NotPrincipals(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -2073,7 +2075,7 @@ func TestAuthorization_NotPrincipals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -2081,12 +2083,12 @@ func TestAuthorization_NotPrincipals(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -2097,7 +2099,7 @@ func TestAuthorization_NotPrincipals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -2105,7 +2107,7 @@ func TestAuthorization_NotPrincipals(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -2121,7 +2123,7 @@ func TestAuthorization_NotPrincipals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -2129,7 +2131,7 @@ func TestAuthorization_NotPrincipals(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -2143,7 +2145,7 @@ func TestAuthorization_NotPrincipals(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -2151,12 +2153,12 @@ func TestAuthorization_NotPrincipals(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } } @@ -2164,8 +2166,8 @@ func TestAuthorization_NotPrincipals(t *testing.T) { func TestAuthorization_Extends(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authorization).Build() - r := collections.DubboCAV1Alpha1Authorization.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthorizationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -2195,7 +2197,7 @@ func TestAuthorization_Extends(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authorization, + Gvk: gvk.AuthorizationPolicy, Rev: 1, Data: []model.Config{ { @@ -2205,9 +2207,9 @@ func TestAuthorization_Extends(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -2220,7 +2222,7 @@ func TestAuthorization_Extends(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -2228,12 +2230,12 @@ func TestAuthorization_Extends(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -2246,7 +2248,7 @@ func TestAuthorization_Extends(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -2254,7 +2256,7 @@ func TestAuthorization_Extends(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -2268,7 +2270,7 @@ func TestAuthorization_Extends(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -2276,7 +2278,7 @@ func TestAuthorization_Extends(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -2289,8 +2291,8 @@ func TestAuthorization_Extends(t *testing.T) { func TestAuthorization_NotExtends(t *testing.T) { t.Parallel() - collection.NewSchemasBuilder().MustAdd(collections.DubboCAV1Alpha1Authorization).Build() - r := collections.DubboCAV1Alpha1Authorization.Resource() + collection.NewSchemasBuilder().MustAdd(collections.DubboApacheOrgV1Alpha1AuthorizationPolicy).Build() + r := collections.DubboApacheOrgV1Alpha1AuthorizationPolicy.Resource() configMeta := model.Meta{ Name: "name", Namespace: "ns", @@ -2320,7 +2322,7 @@ func TestAuthorization_NotExtends(t *testing.T) { } origin := &OriginImpl{ - Gvk: gvk.Authorization, + Gvk: gvk.AuthorizationPolicy, Rev: 1, Data: []model.Config{ { @@ -2330,9 +2332,9 @@ func TestAuthorization_NotExtends(t *testing.T) { }, } gen := map[string]DdsResourceGenerator{} - gen[gvk.Authentication] = &AuthenticationGenerator{} - gen[gvk.Authorization] = &AuthorizationGenerator{} - gen[gvk.ServiceMapping] = &ServiceMappingGenerator{} + gen[gvk.AuthenticationPolicy] = &AuthenticationGenerator{} + gen[gvk.AuthorizationPolicy] = &AuthorizationGenerator{} + gen[gvk.ServiceNameMapping] = &ServiceMappingGenerator{} gen[gvk.ConditionRoute] = &ConditionRoutesGenerator{} gen[gvk.TagRoute] = &TagRoutesGenerator{} gen[gvk.DynamicConfig] = &DynamicConfigsGenerator{} @@ -2345,7 +2347,7 @@ func TestAuthorization_NotExtends(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data := generated.Data @@ -2353,12 +2355,12 @@ func TestAuthorization_NotExtends(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } @@ -2371,7 +2373,7 @@ func TestAuthorization_NotExtends(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -2379,7 +2381,7 @@ func TestAuthorization_NotExtends(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) @@ -2393,7 +2395,7 @@ func TestAuthorization_NotExtends(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, generated) - assert.Equal(t, generated.Type, gvk.Authorization) + assert.Equal(t, generated.Type, gvk.AuthorizationPolicy) assert.Equal(t, generated.Revision, int64(1)) data = generated.Data @@ -2401,12 +2403,12 @@ func TestAuthorization_NotExtends(t *testing.T) { for _, anyMessage := range data { valBytes := anyMessage.Value if anyMessage.TypeUrl == model.AuthorizationTypeUrl { - authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicy{} + authorization := &dubbo_apache_org_v1alpha1.AuthorizationPolicyToClient{} err := proto.Unmarshal(valBytes, authorization) if err != nil { t.Fatal(err) } - assert.Equal(t, "ALLOW", authorization.Action) + assert.Equal(t, "ALLOW", authorization.Spec.Action) } } } diff --git a/pkg/snp/server/servicemapping.go b/pkg/snp/server/servicemapping.go index 8910a86fa..65afd6823 100644 --- a/pkg/snp/server/servicemapping.go +++ b/pkg/snp/server/servicemapping.go @@ -24,6 +24,10 @@ import ( "time" "github.com/apache/dubbo-admin/api/mesh" + cert "github.com/apache/dubbo-admin/pkg/core/cert/provider" + endpoint2 "github.com/apache/dubbo-admin/pkg/core/tools/endpoint" + "google.golang.org/grpc/peer" + api "github.com/apache/dubbo-admin/api/resource/v1alpha1" dubbo_cp "github.com/apache/dubbo-admin/pkg/config/app/dubbo-cp" apisv1alpha1 "github.com/apache/dubbo-admin/pkg/core/gen/apis/dubbo.apache.org/v1alpha1" @@ -42,8 +46,11 @@ type RegisterRequest struct { type Snp struct { mesh.UnimplementedServiceNameMappingServiceServer - queue chan *RegisterRequest - config *dubbo_cp.Config + queue chan *RegisterRequest + config *dubbo_cp.Config + CertClient cert.Client + CertStorage *cert.CertStorage + KubeClient versioned.Interface } @@ -61,6 +68,16 @@ func (s *Snp) RegisterServiceAppMapping(ctx context.Context, req *mesh.ServiceMa interfaces := req.GetInterfaceNames() applicationName := req.GetApplicationName() + p, _ := peer.FromContext(ctx) + _, err := endpoint2.ExactEndpoint(ctx, s.CertStorage, s.config, s.CertClient) + if err != nil { + logger.Sugar().Warnf("[ServiceMapping] Failed to exact endpoint from context: %v. RemoteAddr: %s", err, p.Addr.String()) + return &mesh.ServiceMappingResponse{ + Success: false, + Message: err.Error(), + }, nil + } + registerReq := &RegisterRequest{ConfigsUpdated: map[model.ConfigKey]map[string]struct{}{}} for _, interfaceName := range interfaces { key := model.ConfigKey{ @@ -74,7 +91,10 @@ func (s *Snp) RegisterServiceAppMapping(ctx context.Context, req *mesh.ServiceMa } s.queue <- registerReq - return &mesh.ServiceMappingResponse{}, nil + return &mesh.ServiceMappingResponse{ + Success: true, + Message: "success", + }, nil } func NewSnp(config *dubbo_cp.Config, kubeClient versioned.Interface) *Snp { @@ -108,7 +128,7 @@ func (s *Snp) push(req *RegisterRequest) { } for i := 0; i < 3; i++ { if err := tryRegister(s.KubeClient, key.Namespace, key.Name, appNames); err != nil { - logger.Errorf(" register [%v] failed: %v, try again later", key, err) + logger.Errorf("[ServiceMapping] register [%v] failed: %v, try again later", key, err) } else { break } @@ -143,7 +163,7 @@ func (s *Snp) debounce(stopCh <-chan struct{}, pushFn func(req *RegisterRequest) pushCounter++ if req.ConfigsUpdated != nil { - logger.Infof(" Push debounce stable[%d] %d for config %s: %v since last change, %v since last push", + logger.Infof("[ServiceMapping] Push debounce stable[%d] %d for config %s: %v since last change, %v since last push", pushCounter, debouncedEvents, configsUpdated(req), quietTime, eventDelay) } @@ -226,10 +246,10 @@ func getOrCreateSnp(kubeClient versioned.Interface, namespace string, interfaceN } func tryRegister(kubeClient versioned.Interface, namespace, interfaceName string, newApps []string) error { - logger.Debugf("try register [%s] in namespace [%s] with [%v] apps", interfaceName, namespace, len(newApps)) + logger.Debugf("[ServiceMapping] try register [%s] in namespace [%s] with [%v] apps", interfaceName, namespace, len(newApps)) snp, created, err := getOrCreateSnp(kubeClient, namespace, interfaceName, newApps) if created { - logger.Debugf("register success, revision:%s", snp.ResourceVersion) + logger.Debugf("[ServiceMapping] register success, revision:%s", snp.ResourceVersion) return nil } if err != nil { @@ -245,7 +265,7 @@ func tryRegister(kubeClient versioned.Interface, namespace, interfaceName string previousAppNames[newApp] = struct{}{} } if len(previousAppNames) == previousLen { - logger.Debugf("[%s] has been registered: %v", interfaceName, newApps) + logger.Debugf("[ServiceMapping] [%s] has been registered: %v", interfaceName, newApps) return nil } @@ -259,7 +279,7 @@ func tryRegister(kubeClient versioned.Interface, namespace, interfaceName string if err != nil { return errors.Wrap(err, " update failed") } - logger.Debugf("register update success, revision:%s", snp.ResourceVersion) + logger.Debugf("[ServiceMapping] register update success, revision:%s", snp.ResourceVersion) return nil } diff --git a/pkg/snp/setup.go b/pkg/snp/setup.go index 592c31e5a..47bb3b9b5 100644 --- a/pkg/snp/setup.go +++ b/pkg/snp/setup.go @@ -29,6 +29,8 @@ func Setup(rt core_runtime.Runtime) error { return nil } snp := server.NewSnp(rt.Config(), rt.KubeClient().DubboClientSet()) + snp.CertStorage = rt.CertStorage() + snp.CertClient = rt.CertClient() mesh.RegisterServiceNameMappingServiceServer(rt.GrpcServer().SecureServer, snp) mesh.RegisterServiceNameMappingServiceServer(rt.GrpcServer().PlainServer, snp) if err := rt.Add(snp); err != nil { diff --git a/test/testclient/ddsc.go b/test/testclient/ddsc.go new file mode 100644 index 000000000..7ec768bfd --- /dev/null +++ b/test/testclient/ddsc.go @@ -0,0 +1,411 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "context" + "fmt" + "net" + "sync" + "time" + + "github.com/apache/dubbo-admin/api/mesh" + gvks "github.com/apache/dubbo-admin/pkg/core/schema/gvk" + + "github.com/apache/dubbo-admin/api/dds" + api "github.com/apache/dubbo-admin/api/resource/v1alpha1" + "github.com/apache/dubbo-admin/pkg/core/logger" + "github.com/cenkalti/backoff" + "github.com/gogo/protobuf/proto" + "google.golang.org/grpc" +) + +var ( + // use plain server to test + grpcAddr = "127.0.0.1:30060" + grpcUpstreamAddr = grpcAddr +) + +type Config struct { + // InitialDiscoveryRequests is a list of resources to watch at first, represented as URLs (for new DDS resource naming) + // or type URLs. + InitialDiscoveryRequest []*dds.ObserveRequest + // BackoffPolicy determines the reconnect policy. Based on ddsclient. + BackoffPolicy backoff.BackOff + GrpcOpts []grpc.DialOption + + Namespace string + + // It is sent by ddsclient, must match a known endpoint IP. + IP string +} + +// DDSC implements a basic ddsclient for DDS, for use in stress tests and tools +// or libraries that need to connect to Dubbo admin or other DDS servers. +// Currently only for testing! +type DDSC struct { + // Stream is the GRPC connection stream, allowing direct GRPC send operations. + // Set after Dial is called. + stream dds.RuleService_ObserveClient + // dds ddsclient used to create a stream + ddsclient dds.RuleServiceClient + snpclient mesh.ServiceNameMappingServiceClient + conn *grpc.ClientConn + + // Indicates if the DDSC ddsclient is closed + closed bool + + // NodeID is the node identity sent to Admin + nodeID string + + url string + + authentication []*api.AuthenticationPolicyToClient + authorization []*api.AuthorizationPolicyToClient + conditionRoute []*api.ConditionRouteToClient + tagRoute []*api.TagRouteToClient + dynamicConfig []*api.DynamicConfigToClient + serviceMapping []*api.ServiceNameMappingToClient + + // Last received message, by type + Received map[string]*dds.ObserveResponse + + mutex sync.RWMutex + + // RecvWg is for letting goroutines know when the goroutine handling the DDS stream finishes. + RecvWg sync.WaitGroup + + cfg *Config +} + +func New(discoveryAddr string, opts *Config) (*DDSC, error) { + if opts == nil { + opts = &Config{} + } + // We want to recreate stream + if opts.BackoffPolicy == nil { + opts.BackoffPolicy = backoff.NewExponentialBackOff() + } + ddsc := &DDSC{ + url: discoveryAddr, + cfg: opts, + Received: map[string]*dds.ObserveResponse{}, + RecvWg: sync.WaitGroup{}, + } + + if opts.IP == "" { + opts.IP = getPrivateIPIfAvailable().String() + } + + ddsc.nodeID = fmt.Sprintf("%s~%s", opts.IP, opts.Namespace) + + if err := ddsc.Dial(); err != nil { + return nil, err + } + return ddsc, nil +} + +// Dial connects to a dds server +// nolint +func (a *DDSC) Dial() error { + opts := a.cfg + var err error + grpcDialOptions := opts.GrpcOpts + if len(grpcDialOptions) == 0 { + // Only disable transport security if the user didn't supply custom dial options + grpcDialOptions = append(grpcDialOptions, grpc.WithInsecure()) + } + + a.conn, err = grpc.Dial(a.url, grpcDialOptions...) + if err != nil { + return err + } + return nil +} + +func getPrivateIPIfAvailable() net.IP { + addrs, _ := net.InterfaceAddrs() + for _, addr := range addrs { + var ip net.IP + switch v := addr.(type) { + case *net.IPNet: + ip = v.IP + case *net.IPAddr: + ip = v.IP + default: + continue + } + if !ip.IsLoopback() { + return ip + } + } + return net.IPv4zero +} + +// reconnect will create a new stream +func (a *DDSC) reconnect() { + a.mutex.RLock() + if a.closed { + a.mutex.RUnlock() + return + } + a.mutex.RUnlock() + + err := a.Run() + if err == nil { + a.cfg.BackoffPolicy.Reset() + } else { + time.AfterFunc(a.cfg.BackoffPolicy.NextBackOff(), a.reconnect) + } +} + +func (a *DDSC) Run() error { + var err error + a.ddsclient = dds.NewRuleServiceClient(a.conn) + a.snpclient = mesh.NewServiceNameMappingServiceClient(a.conn) + a.stream, err = a.ddsclient.Observe(context.Background()) + if err != nil { + return err + } + // Send the snp message + a.sendSnp() + // Send the initial requests + for _, r := range a.cfg.InitialDiscoveryRequest { + err := a.Send(r) + if err != nil { + return err + } + } + // by default, we assume 1 goroutine decrements the waitgroup (go a.handleRecv()). + // for synchronizing when the goroutine finishes reading from the gRPC stream. + a.RecvWg.Add(1) + go a.handleRecv() + return nil +} + +func (a *DDSC) sendSnp() { + res, err := a.snpclient.RegisterServiceAppMapping(context.Background(), &mesh.ServiceMappingRequest{ + Namespace: "dubbo-system", + ApplicationName: "test-app", + InterfaceNames: []string{ + "test-interface1", + "test-interface2", + }, + }) + if err != nil || !res.Success { + a.sendSnp() + } +} + +// Send Raw send of request +func (a *DDSC) Send(req *dds.ObserveRequest) error { + return a.stream.Send(req) +} + +func (a *DDSC) handleRecv() { + for { + var err error + msg, err := a.stream.Recv() + if err != nil { + a.RecvWg.Done() + logger.Sugar().Infof("Connection closed for node %v with err: %v", a.nodeID, err) + // if 'reconnect' enabled - schedule a new Run + if a.cfg.BackoffPolicy != nil { + time.AfterFunc(a.cfg.BackoffPolicy.NextBackOff(), a.reconnect) + } else { + a.Close() + } + return + } + logger.Sugar().Info("Received ", a.url, " type ", msg.Type, + "nonce= ", msg.Nonce) + + // Process the resources + var authentication []*api.AuthenticationPolicyToClient + var authorization []*api.AuthorizationPolicyToClient + var serviceMapping []*api.ServiceNameMappingToClient + var conditionRoute []*api.ConditionRouteToClient + var tagRoute []*api.TagRouteToClient + var dynamicConfig []*api.DynamicConfigToClient + switch msg.Type { + case gvks.AuthenticationPolicy: + for _, d := range msg.Data { + valBytes := d.Value + auth := &api.AuthenticationPolicyToClient{} + err := proto.Unmarshal(valBytes, auth) + if err != nil { + return + } + authentication = append(authentication, auth) + a.handleAuthentication(authentication) + } + case gvks.AuthorizationPolicy: + for _, d := range msg.Data { + valBytes := d.Value + auth := &api.AuthorizationPolicyToClient{} + err := proto.Unmarshal(valBytes, auth) + if err != nil { + return + } + authorization = append(authorization, auth) + a.handleAuthorization(authorization) + } + case gvks.ServiceNameMapping: + for _, d := range msg.Data { + valBytes := d.Value + auth := &api.ServiceNameMappingToClient{} + err := proto.Unmarshal(valBytes, auth) + if err != nil { + return + } + serviceMapping = append(serviceMapping, auth) + a.handleServiceNameMapping(serviceMapping) + } + case gvks.ConditionRoute: + for _, d := range msg.Data { + valBytes := d.Value + auth := &api.ConditionRouteToClient{} + err := proto.Unmarshal(valBytes, auth) + if err != nil { + return + } + conditionRoute = append(conditionRoute, auth) + a.handleConditionRoute(conditionRoute) + } + case gvks.DynamicConfig: + for _, d := range msg.Data { + valBytes := d.Value + auth := &api.DynamicConfigToClient{} + err := proto.Unmarshal(valBytes, auth) + if err != nil { + return + } + dynamicConfig = append(dynamicConfig, auth) + a.handleDynamicConfig(dynamicConfig) + } + case gvks.TagRoute: + for _, d := range msg.Data { + valBytes := d.Value + auth := &api.TagRouteToClient{} + err := proto.Unmarshal(valBytes, auth) + if err != nil { + return + } + tagRoute = append(tagRoute, auth) + a.handleTagRoute(tagRoute) + } + } + + a.mutex.Lock() + a.Received[msg.Type] = msg + err = a.ack(msg) + if err != nil { + return + } + a.mutex.Unlock() + } +} + +func (a *DDSC) ack(msg *dds.ObserveResponse) error { + return a.stream.Send(&dds.ObserveRequest{ + Nonce: msg.Nonce, + Type: msg.Type, + }) +} + +// Close the stream +func (a *DDSC) Close() { + a.mutex.Lock() + err := a.conn.Close() + if err != nil { + return + } + a.closed = true + a.mutex.Unlock() +} + +func (a *DDSC) handleAuthentication(ll []*api.AuthenticationPolicyToClient) { + a.authentication = ll + logger.Sugar().Info(ll) +} + +func (a *DDSC) handleAuthorization(ll []*api.AuthorizationPolicyToClient) { + a.authorization = ll + logger.Sugar().Info(ll) +} + +func (a *DDSC) handleServiceNameMapping(ll []*api.ServiceNameMappingToClient) { + a.serviceMapping = ll + logger.Sugar().Info(ll) +} + +func (a *DDSC) handleConditionRoute(ll []*api.ConditionRouteToClient) { + a.conditionRoute = ll + logger.Sugar().Info(ll) +} + +func (a *DDSC) handleTagRoute(ll []*api.TagRouteToClient) { + a.tagRoute = ll + logger.Sugar().Info(ll) +} + +func (a *DDSC) handleDynamicConfig(ll []*api.DynamicConfigToClient) { + a.dynamicConfig = ll + logger.Sugar().Info(ll) +} + +func main() { + initialWatch := []*dds.ObserveRequest{ + { + Nonce: "", + Type: gvks.AuthorizationPolicy, + }, + { + Nonce: "", + Type: gvks.AuthenticationPolicy, + }, + { + Nonce: "", + Type: gvks.DynamicConfig, + }, + { + Nonce: "", + Type: gvks.TagRoute, + }, + { + Nonce: "", + Type: gvks.ConditionRoute, + }, + { + Nonce: "", + Type: gvks.ServiceNameMapping, + }, + } + ddscConn, err := New(grpcUpstreamAddr, &Config{ + InitialDiscoveryRequest: initialWatch, + Namespace: "dubbo-system", + }) + if err != nil { + panic(err) + } + err = ddscConn.Run() + if err != nil { + panic("DDSC: failed running") + } + ddscConn.RecvWg.Wait() +} diff --git a/test/testclient/test.yml b/test/testclient/test.yml new file mode 100644 index 000000000..cc88d3ae7 --- /dev/null +++ b/test/testclient/test.yml @@ -0,0 +1,64 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# It is only for test + +admin: + admin-port: 38080 + config-center: nacos://127.0.0.1:8848 + metadata-report: + address: nacos://127.0.0.1:8848 + registry: + address: nacos://127.0.0.1:8848 + prometheus: + ip: 127.0.0.1 + port: 9090 + monitor-port: 22222 +# mysql-dsn: root:password@tcp(127.0.0.1:3306)/dubbo-admin?charset=utf8&parseTime=true +security: + ca-validity: 2592000000 #30 * 24 * 60 * 60 * 1000ms + cert-validity: 3600000 #1 * 60 * 60 * 1000ms + enable-oidc-check: true + webhook-port: 30080 + webhook-allow-on-err: true + # we trust anyone when test + is-trust-anyone: true +kube-config: + namespace: dubbo-system + service-name: dubbo-cp + in-pod-env: false + rest-config-qps: 50 + rest-config-burst: 100 + kube-file-config: "" + domain-suffix: cluster.local +grpc-cp-server: + plain-server-port: 30060 + secure-server-port: 30062 + debug-port: 30070 +options: + debounce-after: 100000000 + debounce-max: 10000000000 + enable-debounce: true + send-timeout: 5000000000 + dds-block-max-time: 15000000000 +dubbo: + registries: + demoZK: + protocol: zookeeper + address: 127.0.0.1:2181 + protocols: + triple: + name: tri + port: 20000 \ No newline at end of file diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 000000000..9bd647601 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,84 @@ +# Use the tools tool to quickly add dubbo resources + +- define a crd + +- Generate the crd definition in the form of proto + + For example: + + This is the crd definition of ServiceNameMapping: + + ```yaml + apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + metadata: + name: servicenamemappings.dubbo.apache.org + spec: + group: dubbo.apache.org + versions: + - name: v1alpha1 + served: true + storage: true + schema: + openAPIV3Schema: + properties: + spec: + description: + 'Spec defines the behavior of a service mapping. + https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status' + properties: + applicationNames: + items: + type: string + type: array + interfaceName: + type: string + type: object + type: object + scope: Namespaced + names: + plural: servicenamemappings + singular: servicenamemapping + kind: ServiceNameMapping + shortNames: + - snp + + ``` + + It is correspondingly written as pb: + + ```protobuf + syntax = "proto3"; + + package dubbo.apache.org.v1alpha1; + + option java_multiple_files = true; + + message ServiceNameMappingToClient { + string key = 1; + ServiceNameMapping spec = 2; + } + + message ServiceNameMapping { + string interfaceName = 1; + repeated string applicationNames = 2; + } + ``` + + Use `protoc-gen-gogo` to generate it under `api/resource/v1alpha1` + +- Go to the `tools/resource-gen` directory and write metadata.yaml. `dds: true` means that this resource will be included in the push scope. validate: Represents the validation function. Each resource can have a different validation function. If you don't need a validation function, just fill in `EmptyValidate`. Validation functions are written in `validation.go` of `pkg/core/validation`. + +- ```sh + cd tools + chmod a+x gen.sh + ./gen.sh + ``` + +- You can see that something is being generated under `pkg/core/gen` at this point. At this point, you can use the code-generator officially provided by k8s to generate the corresponding generated through types.go, **note that it must be named generated**. + + > Why do you need code-generator? + > + > The reason is simple, we have no way of knowing where your code-generator's code warehouse is installed. + +- Write `pkg/dds/storage/generate.go`, refer to other resources. \ No newline at end of file diff --git a/tools/code-generator-gen/main.go b/tools/code-generator-gen/main.go new file mode 100644 index 000000000..d2ba12bf7 --- /dev/null +++ b/tools/code-generator-gen/main.go @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "bytes" + "flag" + "fmt" + "go/format" + "log" + "os" + "text/template" + + "github.com/apache/dubbo-admin/pkg/core/schema/collections" +) + +type ConfigData struct { + Kind string +} + +func main() { + outputFiletypes := flag.String("ot", "../../pkg/core/gen/apis/dubbo.apache.org/v1alpha1/types.go", "gen types.go") + outputFileregister := flag.String("or", "../../pkg/core/gen/apis/dubbo.apache.org/v1alpha1/register.go", "gen register.go") + templateType := flag.String("tt", "./typesgen.go.tmpl", "type.go Template") + templateRegister := flag.String("tr", "./register.go.tmpl", "register.go Template") + flag.Parse() + + var kindList []ConfigData + + for _, s := range collections.Rule.All() { + kindList = append(kindList, ConfigData{Kind: s.Resource().Kind()}) + } + + tmpltypes := template.Must(template.ParseFiles(*templateType)) + tmplregister := template.Must(template.ParseFiles(*templateRegister)) + var buffertypes bytes.Buffer + if err := tmpltypes.Execute(&buffertypes, kindList); err != nil { + log.Fatal(fmt.Errorf("template: %v", err)) + } + + var bufferregister bytes.Buffer + if err := tmplregister.Execute(&bufferregister, kindList); err != nil { + log.Fatal(fmt.Errorf("template: %v", err)) + } + + outtypes, err := format.Source(buffertypes.Bytes()) + if err != nil { + log.Fatal(err) + } + outregister, err := format.Source(bufferregister.Bytes()) + if err != nil { + log.Fatal(err) + } + + if outputFiletypes == nil || *outputFiletypes == "" { + fmt.Println(outputFiletypes) + } + file, err := os.Create(*outputFiletypes) + if err != nil { + panic(err) + } + defer file.Close() + + _, err = file.Write(outtypes) + if err != nil { + panic(err) + } + + if outputFileregister == nil || *outputFileregister == "" { + fmt.Println(outputFileregister) + } + file, err = os.Create(*outputFileregister) + if err != nil { + panic(err) + } + defer file.Close() + + _, err = file.Write(outregister) + if err != nil { + panic(err) + } +} diff --git a/tools/code-generator-gen/register.go.tmpl b/tools/code-generator-gen/register.go.tmpl new file mode 100644 index 000000000..64c716e19 --- /dev/null +++ b/tools/code-generator-gen/register.go.tmpl @@ -0,0 +1,54 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: "dubbo.apache.org", Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder initializes a scheme builder + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + {{range $index, $element := .}} + &{{.Kind}}{}, + &{{.Kind}}List{}, + {{end}} + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/tools/code-generator-gen/typesgen.go.tmpl b/tools/code-generator-gen/typesgen.go.tmpl new file mode 100644 index 000000000..d7cf4d3c5 --- /dev/null +++ b/tools/code-generator-gen/typesgen.go.tmpl @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package v1alpha1 + + import ( + api "github.com/apache/dubbo-admin/api/resource/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + ) + + {{range $index, $element := .}} + // +genclient +// +kubebuilder:object:root=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + + type {{.Kind}} struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec api.{{.Kind}} `json:"spec"` + } + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + type {{.Kind}}List struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []{{.Kind}} `json:"items"` + } + {{end}} \ No newline at end of file diff --git a/tools/deepcopy-gen/generate.go b/tools/deepcopy-gen/generate.go index 599dffc23..4aa004676 100644 --- a/tools/deepcopy-gen/generate.go +++ b/tools/deepcopy-gen/generate.go @@ -26,76 +26,45 @@ import ( "os" "text/template" - "gopkg.in/yaml.v2" + "github.com/apache/dubbo-admin/pkg/core/schema/collections" ) type ConfigData struct { - ProtoResource string -} - -type Resource struct { - OutPut string `yaml:"out-put"` - Name []string `yaml:"name"` -} - -func readYAMLFile(filePath string) (*Resource, error) { - yamlFile, err := os.ReadFile(filePath) - if err != nil { - return nil, err - } - - var config Resource - - err = yaml.Unmarshal(yamlFile, &config) - if err != nil { - return nil, err - } - - return &config, nil + Kind string } func main() { - config, err := readYAMLFile("tools/deepcopy-gen/metadata.yaml") - if err != nil { - panic(err) - } - outputFile := config.OutPut - names := config.Name + output := flag.String("output", "../../api/resource/v1alpha1/resource_deepcopy.go", "output Path") + tem := flag.String("template", "./template.go.tmpl", "Template file") flag.Parse() - tmpl := template.Must(template.ParseFiles("tools/deepcopy-gen/template.go.tmpl")) + var kindList []ConfigData - var typeList []ConfigData - - for _, name := range names { - data := ConfigData{ - ProtoResource: name, - } - typeList = append(typeList, data) + for _, s := range collections.Rule.All() { + kindList = append(kindList, ConfigData{Kind: s.Resource().Kind()}) } + tmpl := template.Must(template.ParseFiles(*tem)) var buffer bytes.Buffer - if err := tmpl.Execute(&buffer, typeList); err != nil { - log.Fatal(err) + if err := tmpl.Execute(&buffer, kindList); err != nil { + log.Fatal(fmt.Errorf("template: %v", err)) } out, err := format.Source(buffer.Bytes()) if err != nil { log.Fatal(err) } - // Output - if outputFile == "" { - fmt.Println(string(out)) - } else { - file, err := os.Create(outputFile) - if err != nil { - panic(err) - } - defer file.Close() + if output == nil || *output == "" { + fmt.Println(output) + } + file, err := os.Create(*output) + if err != nil { + panic(err) + } + defer file.Close() - _, err = file.Write(out) - if err != nil { - panic(err) - } + _, err = file.Write(out) + if err != nil { + panic(err) } } diff --git a/tools/deepcopy-gen/metadata.yaml b/tools/deepcopy-gen/metadata.yaml deleted file mode 100644 index 61ac0357c..000000000 --- a/tools/deepcopy-gen/metadata.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -out-put: api/resource/v1alpha1/servicemapping_deepcopy.go -name: - - ServiceNameMapping \ No newline at end of file diff --git a/tools/deepcopy-gen/template.go.tmpl b/tools/deepcopy-gen/template.go.tmpl index c383ac740..ea88c0648 100644 --- a/tools/deepcopy-gen/template.go.tmpl +++ b/tools/deepcopy-gen/template.go.tmpl @@ -21,9 +21,10 @@ import ( fmt "fmt" + math "math" + proto "github.com/gogo/protobuf/proto" _ "github.com/gogo/protobuf/types" - math "math" ) // Reference imports to suppress errors if they are not otherwise used. @@ -32,24 +33,24 @@ var _ = fmt.Errorf var _ = math.Inf {{range $index, $element := .}} -// DeepCopyInto supports using {{ .ProtoResource }} within kubernetes types, where deepcopy-gen is used. -func (in *{{ .ProtoResource }}) DeepCopyInto(out *{{ .ProtoResource }}) { - p := proto.Clone(in).(*{{ .ProtoResource }}) +// DeepCopyInto supports using {{ .Kind }} within kubernetes types, where deepcopy-gen is used. +func (in *{{ .Kind }}) DeepCopyInto(out *{{ .Kind }}) { + p := proto.Clone(in).(*{{ .Kind }}) *out = *p } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new {{ .ProtoResource }}. -func (in *{{ .ProtoResource }}) DeepCopy() *{{ .ProtoResource }} { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new {{ .Kind }}. +func (in *{{ .Kind }}) DeepCopy() *{{ .Kind }} { if in == nil { return nil } - out := new({{ .ProtoResource }}) + out := new({{ .Kind }}) in.DeepCopyInto(out) return out } -// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new {{ .ProtoResource }}. -func (in *{{ .ProtoResource }}) DeepCopyInterface() interface{} { +// DeepCopyInterface is an autogenerated deepcopy function, copying the receiver, creating a new {{ .Kind }}. +func (in *{{ .Kind }}) DeepCopyInterface() interface{} { return in.DeepCopy() } {{end}} diff --git a/tools/gen.sh b/tools/gen.sh new file mode 100644 index 000000000..912ef71bf --- /dev/null +++ b/tools/gen.sh @@ -0,0 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#! /bin/bash + +echo "Running Resource-gen collections" +go run ./resource-gen/cmd/cmd.go collections ./resource-gen/metadata.yaml ../pkg/core/schema/collections/collections.gen.go + +echo "Sleep for a short time to wait collections.gen.go update" +sleep 5 + +echo "Running Resource-gen gvk" +go run ./resource-gen/cmd/cmd.go gvk ./resource-gen/metadata.yaml ../pkg/core/schema/gvk/gvk.gen.go + +echo "Running Types-gen" +go run ./types-gen/main.go --template ./types-gen/types.go.tmpl --output ../pkg/dds/kube/crdclient/types.gen.go + +echo "Running Resource Deepcopy" +go run ./deepcopy-gen/generate.go --output ../api/resource/v1alpha1/resource_deepcopy.go --template ./deepcopy-gen/template.go.tmpl + +echo "Running Code-generator-gen" +go run ./code-generator-gen/main.go --ot ../pkg/core/gen/apis/dubbo.apache.org/v1alpha1/types.go --or ../pkg/core/gen/apis/dubbo.apache.org/v1alpha1/register.go --tt ./code-generator-gen/typesgen.go.tmpl --tr ./code-generator-gen/register.go.tmpl + +echo "Running code-generator to gen deepcopy and generated" diff --git a/tools/resource-gen/cmd/cmd.go b/tools/resource-gen/cmd/cmd.go new file mode 100644 index 000000000..31d10c8f9 --- /dev/null +++ b/tools/resource-gen/cmd/cmd.go @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "fmt" + "os" + + "github.com/apache/dubbo-admin/pkg/core/schema" + "github.com/apache/dubbo-admin/pkg/core/schema/ast" + "github.com/apache/dubbo-admin/tools/resource-gen" +) + +func main() { + if len(os.Args) != 4 { + fmt.Printf("Invalid args: %v", os.Args) + os.Exit(-1) + } + pkg := os.Args[1] + input := os.Args[2] + output := os.Args[3] + + // Read the input file + b, err := os.ReadFile(input) + if err != nil { + fmt.Printf("unable to read input file: %v", err) + os.Exit(-2) + } + + // Parse the file. + m, err := ast.Parse(string(b)) + if err != nil { + fmt.Printf("failed parsing input file: %v", err) + os.Exit(-3) + } + + // Validate the input. + if _, err := schema.Build(m); err != nil { + fmt.Printf("failed building metadata: %v", err) + os.Exit(-4) + } + + if pkg == "gvk" { + contents, err := resource.WriteGvk(m) + if err != nil { + fmt.Printf("Error applying static init template: %v", err) + os.Exit(-3) + } + if err = os.WriteFile(output, []byte(contents), os.ModePerm); err != nil { + fmt.Printf("Error writing output file: %v", err) + os.Exit(-4) + } + return + } else { + contents, err := resource.StaticCollections(m) + if err != nil { + fmt.Printf("Error applying static init template: %v", err) + os.Exit(-3) + } + if err = os.WriteFile(output, []byte(contents), os.ModePerm); err != nil { + fmt.Printf("Error writing output file: %v", err) + os.Exit(-4) + } + } +} diff --git a/tools/resource-gen/collections.go b/tools/resource-gen/collections.go new file mode 100644 index 000000000..6be36c812 --- /dev/null +++ b/tools/resource-gen/collections.go @@ -0,0 +1,181 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package resource + +import ( + "fmt" + "sort" + "strings" + + "github.com/apache/dubbo-admin/pkg/core/schema/ast" +) + +const staticResourceTemplate = ` +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package gvk + +import "github.com/apache/dubbo-admin/pkg/core/model" + +var ( +{{- range .Entries }} + {{.Type}} = model.GroupVersionKind{Group: "{{.Resource.Group}}", Version: "{{.Resource.Version}}", Kind: "{{.Resource.Kind}}"}.String() +{{- end }} +) +` + +const staticCollectionsTemplate = ` +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package collections + +import ( + "reflect" + + api "github.com/apache/dubbo-admin/api/resource/v1alpha1" + "github.com/apache/dubbo-admin/pkg/core/schema/collection" + "github.com/apache/dubbo-admin/pkg/core/schema/resource" + "github.com/apache/dubbo-admin/pkg/core/validation" +) + +var ( +{{ range .Entries }} + {{ .Collection.VariableName }} = collection.Builder { + Name: "{{ .Collection.Name }}", + VariableName: "{{ .Collection.VariableName }}", + Resource: resource.Builder { + Group: "{{ .Resource.Group }}", + Kind: "{{ .Resource.Kind }}", + Plural: "{{ .Resource.Plural }}", + Version: "{{ .Resource.Version }}", + Proto: "{{ .Resource.Proto }}", + ReflectType: {{ .Type }}, + ClusterScoped: {{ .Resource.ClusterScoped }}, + ValidateProto: validation.{{ .Resource.Validate }}, + }.MustBuild(), + }.MustBuild() +{{ end }} + + Rule = collection.NewSchemasBuilder(). + {{- range .Entries }} + {{- if .Collection.Dds }} + MustAdd({{ .Collection.VariableName }}). + {{- end}} + {{- end }} + Build() +) +` + +type colEntry struct { + Collection *ast.Collection + Resource *ast.Resource + Type string +} + +func WriteGvk(m *ast.Metadata) (string, error) { + entries := make([]colEntry, 0, len(m.Collections)) + for _, c := range m.Collections { + // Filter out Dds ones, as these are duplicated + if !c.Dds { + continue + } + r := m.FindResourceForGroupKind(c.Group, c.Kind) + if r == nil { + return "", fmt.Errorf("failed to find resource (%s/%s) for collection %s", c.Group, c.Kind, c.Name) + } + + name := r.Kind + entries = append(entries, colEntry{ + Type: name, + Resource: r, + }) + } + + sort.Slice(entries, func(i, j int) bool { + return strings.Compare(entries[i].Type, entries[j].Type) < 0 + }) + + context := struct { + Entries []colEntry + }{ + Entries: entries, + } + + return applyTemplate(staticResourceTemplate, context) +} + +// StaticCollections generates a Go file for static-importing Proto packages, so that they get registered statically. +func StaticCollections(m *ast.Metadata) (string, error) { + entries := make([]colEntry, 0, len(m.Collections)) + for _, c := range m.Collections { + r := m.FindResourceForGroupKind(c.Group, c.Kind) + if r == nil { + return "", fmt.Errorf("failed to find resource (%s/%s) for collection %s", c.Group, c.Kind, c.Name) + } + spl := strings.Split(r.Proto, ".") + tname := spl[len(spl)-1] + e := colEntry{ + Collection: c, + Resource: r, + Type: fmt.Sprintf("reflect.TypeOf(&api.%s{}).Elem()", tname), + } + entries = append(entries, e) + } + + sort.Slice(entries, func(i, j int) bool { + return strings.Compare(entries[i].Collection.Name, entries[j].Collection.Name) < 0 + }) + + context := struct { + Entries []colEntry + }{ + Entries: entries, + } + + return applyTemplate(staticCollectionsTemplate, context) +} diff --git a/tools/resource-gen/collections_test.go b/tools/resource-gen/collections_test.go new file mode 100644 index 000000000..21205ecc2 --- /dev/null +++ b/tools/resource-gen/collections_test.go @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package resource + +import ( + "strings" + "testing" + + "github.com/apache/dubbo-admin/pkg/core/schema/ast" + + "github.com/google/go-cmp/cmp" + . "github.com/onsi/gomega" +) + +func TestStaticCollections(t *testing.T) { + cases := []struct { + packageName string + m *ast.Metadata + err string + output string + }{ + { + packageName: "pkg", + m: &ast.Metadata{ + Collections: []*ast.Collection{ + { + Name: "foo", + VariableName: "Foo", + Group: "foo.group", + Kind: "fookind", + }, + { + Name: "bar", + VariableName: "Bar", + Group: "bar.group", + Kind: "barkind", + }, + }, + Resources: []*ast.Resource{ + { + Group: "foo.group", + Version: "v1", + Kind: "fookind", + Plural: "fookinds", + ClusterScoped: true, + Proto: "google.protobuf.Struct", + Validate: "EmptyValidate", + }, + { + Group: "bar.group", + Version: "v1", + Kind: "barkind", + Plural: "barkinds", + ClusterScoped: false, + Proto: "google.protobuf.Struct", + Validate: "EmptyValidate", + }, + }, + }, + output: ` +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package collections + +import ( + "reflect" + + api "github.com/apache/dubbo-admin/api/resource/v1alpha1" + "github.com/apache/dubbo-admin/pkg/core/schema/collection" + "github.com/apache/dubbo-admin/pkg/core/schema/resource" + "github.com/apache/dubbo-admin/pkg/core/validation" +) + +var ( + + Bar = collection.Builder { + Name: "bar", + VariableName: "Bar", + Resource: resource.Builder { + Group: "bar.group", + Kind: "barkind", + Plural: "barkinds", + Version: "v1", + Proto: "google.protobuf.Struct", + ReflectType: reflect.TypeOf(&api.Struct{}).Elem(), + ClusterScoped: false, + ValidateProto: validation.EmptyValidate, + }.MustBuild(), + }.MustBuild() + + Foo = collection.Builder { + Name: "foo", + VariableName: "Foo", + Resource: resource.Builder { + Group: "foo.group", + Kind: "fookind", + Plural: "fookinds", + Version: "v1", + Proto: "google.protobuf.Struct", + ReflectType: reflect.TypeOf(&api.Struct{}).Elem(), + ClusterScoped: true, + ValidateProto: validation.EmptyValidate, + }.MustBuild(), + }.MustBuild() + + + Rule = collection.NewSchemasBuilder(). + Build() +) + +`, + }, + } + + for _, c := range cases { + t.Run("", func(t *testing.T) { + g := NewWithT(t) + + s, err := StaticCollections(c.m) + if c.err != "" { + g.Expect(err).NotTo(BeNil()) + g.Expect(err.Error()).To(Equal(s)) + } else { + g.Expect(err).To(BeNil()) + if diff := cmp.Diff(strings.TrimSpace(s), strings.TrimSpace(c.output)); diff != "" { + t.Fatal(diff) + } + } + }) + } +} diff --git a/tools/resource-gen/common.go b/tools/resource-gen/common.go new file mode 100644 index 000000000..2840020ff --- /dev/null +++ b/tools/resource-gen/common.go @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package resource + +import ( + "bytes" + "strings" + "text/template" +) + +const ( + commentLinePrefix = "// " +) + +func applyTemplate(tmpl string, i interface{}) (string, error) { + t := template.New("tmpl").Funcs(template.FuncMap{ + "wordWrap": wordWrap, + "commentBlock": commentBlock, + "hasPrefix": strings.HasPrefix, + }) + + t2 := template.Must(t.Parse(tmpl)) + + var b bytes.Buffer + if err := t2.Execute(&b, i); err != nil { + return "", err + } + + return b.String(), nil +} + +func commentBlock(in []string, indentTabs int) string { + // Copy the input array. + in = append([]string{}, in...) + + // Apply the tabs and comment prefix to each line. + for lineIndex := range in { + prefix := "" + for tabIndex := 0; lineIndex > 0 && tabIndex < indentTabs; tabIndex++ { + prefix += "\t" + } + prefix += commentLinePrefix + in[lineIndex] = prefix + in[lineIndex] + } + + // Join the lines with carriage returns. + return strings.Join(in, "\n") +} + +func wordWrap(in string, maxLineLength int) []string { + // First, split the input based on any user-created lines (i.e. the string contains "\n"). + inputLines := strings.Split(in, "\n") + outputLines := make([]string, 0) + + line := "" + for i, inputLine := range inputLines { + if i > 0 { + // Process a user-defined carriage return. + outputLines = append(outputLines, line) + line = "" + } + + words := strings.Split(inputLine, " ") + + for len(words) > 0 { + // Take the next word. + word := words[0] + words = words[1:] + + if len(line)+len(word) > maxLineLength { + // Need to word wrap - emit the current line. + outputLines = append(outputLines, line) + line = "" + } + + // Add the word to the current line. + if len(line) > 0 { + line += " " + } + line += word + } + } + + // Emit the final line + outputLines = append(outputLines, line) + + return outputLines +} diff --git a/tools/resource-gen/common_test.go b/tools/resource-gen/common_test.go new file mode 100644 index 000000000..a70dd371f --- /dev/null +++ b/tools/resource-gen/common_test.go @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package resource + +import ( + "testing" + + . "github.com/onsi/gomega" +) + +func TestCommentBlock(t *testing.T) { + cases := []struct { + name string + input []string + indentTabs int + expected string + }{ + { + name: "single line", + input: []string{ + "single line comment", + }, + indentTabs: 1, + expected: "// single line comment", + }, + { + name: "single line", + input: []string{ + "first line no indent", + "second line has indent", + }, + indentTabs: 3, + expected: "// first line no indent\n" + + "\t\t\t// second line has indent", + }, + } + + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + g := NewWithT(t) + output := commentBlock(c.input, c.indentTabs) + g.Expect(output).To(Equal(c.expected)) + }) + } +} + +func TestWordWrap(t *testing.T) { + cases := []struct { + name string + input string + maxLineLength int + expected []string + }{ + { + name: "no wrap", + input: "no wrap is required", + maxLineLength: 100, + expected: []string{ + "no wrap is required", + }, + }, + { + name: "wrap after word", + input: "wrap after word", + maxLineLength: 11, + expected: []string{ + "wrap after", + "word", + }, + }, + { + name: "wrap mid word", + input: "wrap mid-word", + maxLineLength: 10, + expected: []string{ + "wrap", + "mid-word", + }, + }, + { + name: "user carriage return", + input: "user carriage\nreturn", + maxLineLength: 100, + expected: []string{ + "user carriage", + "return", + }, + }, + { + name: "multiple lines", + input: "This is a long-winded example.\nIt shows:\n -user-defined carriage returns\n " + + "-wrapping at the max line length\n -removal of extra whitespace around words", + maxLineLength: 22, + expected: []string{ + "This is a long-winded", + "example.", + "It shows:", + "-user-defined carriage", + "returns", + "-wrapping at the max", + "line length", + "-removal of extra", + "whitespace around words", + }, + }, + } + + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + g := NewWithT(t) + output := wordWrap(c.input, c.maxLineLength) + g.Expect(output).To(Equal(c.expected)) + }) + } +} diff --git a/tools/resource-gen/metadata.yaml b/tools/resource-gen/metadata.yaml new file mode 100644 index 000000000..b35a79ce1 --- /dev/null +++ b/tools/resource-gen/metadata.yaml @@ -0,0 +1,92 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The total set of collections +collections: + - name: "dubbo/apache/org/v1alpha1/AuthenticationPolicy" + kind: "AuthenticationPolicy" + group: "dubbo.apache.org" + dds: true + + - name: "dubbo/apache/org/v1alpha1/AuthorizationPolicy" + kind: "AuthorizationPolicy" + group: "dubbo.apache.org" + dds: true + + - name: "dubbo/apache/org/v1alpha1/ConditionRoute" + kind: "ConditionRoute" + group: "dubbo.apache.org" + dds: true + + - name: "dubbo/apache/org/v1alpha1/TagRoute" + kind: "TagRoute" + group: "dubbo.apache.org" + dds: true + + - name: "dubbo/apache/org/v1alpha1/DynamicConfig" + kind: "DynamicConfig" + group: "dubbo.apache.org" + dds: true + + - name: "dubbo/apache/org/v1alpha1/ServiceNameMapping" + kind: "ServiceNameMapping" + group: "dubbo.apache.org" + dds: true + + + +# Configuration for resource types +resources: + - kind: "AuthenticationPolicy" + plural: "authenticationpolicies" + group: "dubbo.apache.org" + version: "v1alpha1" + validate: "EmptyValidate" + proto: "dubbo.apache.org.v1alpha1.AuthenticationPolicy" + + - kind: "AuthorizationPolicy" + plural: "authorizationpolicies" + group: "dubbo.apache.org" + version: "v1alpha1" + validate: "EmptyValidate" + proto: "dubbo.apache.org.v1alpha1.AuthorizationPolicy" + + - kind: "ConditionRoute" + plural: "conditionroutes" + group: "dubbo.apache.org" + version: "v1alpha1" + validate: "EmptyValidate" + proto: "dubbo.apache.org.v1alpha1.ConditionRoute" + + - kind: "TagRoute" + plural: "tagroutes" + group: "dubbo.apache.org" + version: "v1alpha1" + validate: "EmptyValidate" + proto: "dubbo.apache.org.v1alpha1.TagRoute" + + - kind: "DynamicConfig" + plural: "dynamicconfigs" + group: "dubbo.apache.org" + version: "v1alpha1" + validate: "EmptyValidate" + proto: "dubbo.apache.org.v1alpha1.DynamicConfig" + + - kind: "ServiceNameMapping" + plural: "servicenamemappings" + group: "dubbo.apache.org" + version: "v1alpha1" + validate: "EmptyValidate" + proto: "dubbo.apache.org.v1alpha1.ServiceNameMapping" diff --git a/tools/types-gen/main.go b/tools/types-gen/main.go new file mode 100644 index 000000000..ecc09dafb --- /dev/null +++ b/tools/types-gen/main.go @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "bytes" + "flag" + "fmt" + "go/format" + "log" + "os" + "text/template" + + "github.com/apache/dubbo-admin/pkg/core/schema/collection" + "github.com/apache/dubbo-admin/pkg/core/schema/collections" +) + +// ConfigData is data struct to feed to types.go template +type ConfigData struct { + Namespaced bool + VariableName string + APIImport string + ClientImport string + Kind string + ClientGroupPath string + ClientTypePath string + + Client string + TypeSuffix string +} + +// MakeConfigData prepare data for code generation for the given schema. +func MakeConfigData(schema collection.Schema) ConfigData { + out := ConfigData{ + Namespaced: !schema.Resource().IsClusterScoped(), + VariableName: schema.VariableName(), + APIImport: "dubbo_apache_org_v1alpha1", + Kind: schema.Resource().Kind(), + ClientImport: "v1alpha1", + ClientTypePath: clientGoTypePath[schema.Resource().Plural()], + ClientGroupPath: "DubboV1alpha1", + Client: "ic", + TypeSuffix: "", + } + log.Printf("Generating Dubbo type %s for %s/%s CRD\n", out.VariableName, out.APIImport, out.Kind) + return out +} + +// Translates a plural type name to the type path in client-go +// TODO: can we automatically derive this? I don't think we can, its internal to the kubegen +var clientGoTypePath = map[string]string{ + "authenticationpolicies": "AuthenticationPolicies", + "authorizationpolicies": "AuthorizationPolicies", + "conditionroutes": "ConditionRoutes", + "tagroutes": "TagRoutes", + "dynamicconfigs": "DynamicConfigs", + "servicenamemappings": "ServiceNameMappings", +} + +func main() { + tempateFile := flag.String("template", "./types.go.tmpl", "Template file") + outputFile := flag.String("output", "../../pkg/dds/kube/crdclient/types.gen.go", "Output file. Leave blank to go to stdout") + flag.Parse() + + tmpl := template.Must(template.ParseFiles(*tempateFile)) + + var typeList []ConfigData + for _, s := range collections.Rule.All() { + typeList = append(typeList, MakeConfigData(s)) + } + var buffer bytes.Buffer + if err := tmpl.Execute(&buffer, typeList); err != nil { + log.Fatal(fmt.Errorf("template: %v", err)) + } + + // Format source code. + out, err := format.Source(buffer.Bytes()) + if err != nil { + log.Fatal(err) + } + // Output + if *outputFile == "" || outputFile == nil { + fmt.Println(string(out)) + } else { + file, err := os.Create(*outputFile) + if err != nil { + panic(err) + } + defer file.Close() + + _, err = file.Write(out) + if err != nil { + panic(err) + } + } +} diff --git a/tools/types-gen/types.go.tmpl b/tools/types-gen/types.go.tmpl new file mode 100644 index 000000000..1add0b35e --- /dev/null +++ b/tools/types-gen/types.go.tmpl @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package crdclient + + import ( + "context" + "fmt" + + dubbo_apache_org_v1alpha1 "github.com/apache/dubbo-admin/api/resource/v1alpha1" + "github.com/apache/dubbo-admin/pkg/core/gen/apis/dubbo.apache.org/v1alpha1" + "github.com/apache/dubbo-admin/pkg/core/gen/generated/clientset/versioned" + "github.com/apache/dubbo-admin/pkg/core/model" + "github.com/apache/dubbo-admin/pkg/core/schema/collections" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + ) + + func create(ic versioned.Interface, cfg model.Config, objMeta metav1.ObjectMeta) (metav1.Object, error) { + switch cfg.GroupVersionKind { + {{- range . }} + case collections.{{ .VariableName }}.Resource().GroupVersionKind(): + return {{.Client}}.{{ .ClientGroupPath }}().{{ .ClientTypePath }}({{if .Namespaced}}cfg.Namespace{{end}}).Create(context.TODO(), &{{ .ClientImport }}.{{ .Kind }}{ + ObjectMeta: objMeta, + Spec: *(cfg.Spec.(*{{ .APIImport }}.{{ .Kind }}{{ .TypeSuffix }})), + }, metav1.CreateOptions{}) + {{- end }} + default: + return nil, fmt.Errorf("unsupported type: %v", cfg.GroupVersionKind) + } + } + + func update(ic versioned.Interface, cfg model.Config, objMeta metav1.ObjectMeta) (metav1.Object, error) { + switch cfg.GroupVersionKind { + {{- range . }} + case collections.{{ .VariableName }}.Resource().GroupVersionKind(): + return {{.Client}}.{{ .ClientGroupPath }}().{{ .ClientTypePath }}({{if .Namespaced}}cfg.Namespace{{end}}).Update(context.TODO(), &{{ .ClientImport }}.{{ .Kind }}{ + ObjectMeta: objMeta, + Spec: *(cfg.Spec.(*{{ .APIImport }}.{{ .Kind }}{{ .TypeSuffix }})), + }, metav1.UpdateOptions{}) + {{- end }} + default: + return nil, fmt.Errorf("unsupported type: %v", cfg.GroupVersionKind) + } + } + + func delete(ic versioned.Interface, typ model.GroupVersionKind, name, namespace string, resourceVersion *string) error { + var deleteOptions metav1.DeleteOptions + if resourceVersion != nil { + deleteOptions.Preconditions = &metav1.Preconditions{ResourceVersion: resourceVersion} + } + switch typ { + {{- range . }} + case collections.{{ .VariableName }}.Resource().GroupVersionKind(): + return {{.Client}}.{{ .ClientGroupPath }}().{{ .ClientTypePath }}({{if .Namespaced}}namespace{{end}}).Delete(context.TODO(), name, deleteOptions) + {{- end }} + default: + return fmt.Errorf("unsupported type: %v", typ) + } + } + + var translationMap = map[model.GroupVersionKind]func(r runtime.Object) *model.Config{ + {{- range . }} + collections.{{ .VariableName }}.Resource().GroupVersionKind(): func(r runtime.Object) *model.Config { + obj := r.(*{{ .ClientImport }}.{{ .Kind }}) + return &model.Config{ + Meta: model.Meta{ + GroupVersionKind: collections.{{ .VariableName }}.Resource().GroupVersionKind(), + Name: obj.Name, + Namespace: obj.Namespace, + Labels: obj.Labels, + Annotations: obj.Annotations, + ResourceVersion: obj.ResourceVersion, + CreationTimestamp: obj.CreationTimestamp.Time, + OwnerReferences: obj.OwnerReferences, + UID: string(obj.UID), + Generation: obj.Generation, + }, + Spec: &obj.Spec, + } + }, + {{- end }} + }