From e3c84d53cd281633ea3916846813d9810d9fa996 Mon Sep 17 00:00:00 2001 From: Jakub Dyszkiewicz Date: Tue, 9 Aug 2022 12:30:42 +0200 Subject: [PATCH 1/3] feat(kuma-cp): enrich policies endpoint Signed-off-by: Jakub Dyszkiewicz --- api/mesh/options.pb.go | 94 ++- api/mesh/options.proto | 5 +- api/mesh/v1alpha1/gateway.pb.go | 20 +- api/mesh/v1alpha1/gateway.proto | 1 + api/mesh/v1alpha1/gateway_route.pb.go | 23 +- api/mesh/v1alpha1/gateway_route.proto | 1 + api/mesh/v1alpha1/retry.proto | 2 +- docs/generated/resources/other_mesh.md | 242 ++---- pkg/api-server/policies_endpoints.go | 10 +- .../testdata/policies_list.golden.json | 62 +- pkg/api-server/types/policies.go | 10 +- .../apis/mesh/zz_generated.resources.go | 774 ++++++++++-------- .../apis/system/zz_generated.resources.go | 134 +-- pkg/core/resources/model/resource.go | 6 +- .../api/v1alpha1/zz_generated.resource.go | 24 +- .../protoc-gen-kumapolicy/resource.go | 4 +- .../policy-gen/protoc-gen-kumapolicy/utils.go | 23 +- tools/resource-gen/genutils/util.go | 25 +- tools/resource-gen/main.go | 4 +- 19 files changed, 742 insertions(+), 722 deletions(-) diff --git a/api/mesh/options.pb.go b/api/mesh/options.pb.go index a0edd32c216f..78f4c5c0b7a8 100644 --- a/api/mesh/options.pb.go +++ b/api/mesh/options.pb.go @@ -49,7 +49,9 @@ type KumaResourceOptions struct { StorageVersion bool `protobuf:"varint,14,opt,name=storage_version,json=storageVersion,proto3" json:"storage_version,omitempty"` // The name of the policy showed as plural to be displayed in the UI and maybe // CLI - DisplayName string `protobuf:"bytes,15,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"` + PluralDisplayName string `protobuf:"bytes,15,opt,name=plural_display_name,json=pluralDisplayName,proto3" json:"plural_display_name,omitempty"` + // Is Experimental indicates if a policy is in experimental state (might not be production ready). + IsExperimental bool `protobuf:"varint,16,opt,name=is_experimental,json=isExperimental,proto3" json:"is_experimental,omitempty"` } func (x *KumaResourceOptions) Reset() { @@ -161,13 +163,20 @@ func (x *KumaResourceOptions) GetStorageVersion() bool { return false } -func (x *KumaResourceOptions) GetDisplayName() string { +func (x *KumaResourceOptions) GetPluralDisplayName() string { if x != nil { - return x.DisplayName + return x.PluralDisplayName } return "" } +func (x *KumaResourceOptions) GetIsExperimental() bool { + if x != nil { + return x.IsExperimental + } + return false +} + type KumaWsOptions struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -394,7 +403,7 @@ var file_mesh_options_proto_rawDesc = []byte{ 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6b, 0x75, 0x6d, 0x61, 0x2e, 0x6d, 0x65, 0x73, 0x68, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0xcc, 0x03, 0x0a, 0x13, 0x4b, 0x75, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x6f, 0x22, 0x82, 0x04, 0x0a, 0x13, 0x4b, 0x75, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, @@ -420,43 +429,46 @@ var file_mesh_options_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x54, 0x6f, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x73, - 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, - 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0f, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, - 0x22, 0x77, 0x0a, 0x0d, 0x4b, 0x75, 0x6d, 0x61, 0x57, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x12, 0x1b, 0x0a, - 0x09, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x64, - 0x6d, 0x69, 0x6e, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, - 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x4f, 0x6e, 0x6c, 0x79, 0x22, 0x58, 0x0a, 0x0e, 0x4b, 0x75, 0x6d, - 0x61, 0x4b, 0x64, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x73, - 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x6f, 0x5f, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x47, 0x6c, 0x6f, 0x62, 0x61, - 0x6c, 0x12, 0x20, 0x0a, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x6f, 0x5f, 0x7a, 0x6f, 0x6e, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x5a, - 0x6f, 0x6e, 0x65, 0x22, 0x58, 0x0a, 0x11, 0x4b, 0x75, 0x6d, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, - 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x73, 0x6b, 0x69, 0x70, - 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x10, 0x73, 0x6b, 0x69, 0x70, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x3a, 0x5e, 0x0a, - 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc5, 0x91, 0xe1, 0x14, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6b, 0x75, 0x6d, 0x61, 0x2e, 0x6d, 0x65, 0x73, 0x68, 0x2e, - 0x4b, 0x75, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x3a, 0x58, 0x0a, - 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc6, 0x91, 0xe1, 0x14, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1c, 0x2e, 0x6b, 0x75, 0x6d, 0x61, 0x2e, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x4b, 0x75, - 0x6d, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, - 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x6d, 0x61, 0x68, 0x71, 0x2f, 0x6b, 0x75, 0x6d, - 0x61, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x65, 0x73, 0x68, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x0a, + 0x13, 0x70, 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x5f, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x70, 0x6c, 0x75, 0x72, + 0x61, 0x6c, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x27, 0x0a, + 0x0f, 0x69, 0x73, 0x5f, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, + 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x69, 0x73, 0x45, 0x78, 0x70, 0x65, 0x72, 0x69, + 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x22, 0x77, 0x0a, 0x0d, 0x4b, 0x75, 0x6d, 0x61, 0x57, 0x73, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, + 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x6c, 0x75, + 0x72, 0x61, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, + 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x4f, 0x6e, 0x6c, 0x79, 0x22, + 0x58, 0x0a, 0x0e, 0x4b, 0x75, 0x6d, 0x61, 0x4b, 0x64, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x73, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x6f, 0x5f, 0x67, 0x6c, 0x6f, + 0x62, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x54, + 0x6f, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x12, 0x20, 0x0a, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x5f, + 0x74, 0x6f, 0x5f, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, + 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x5a, 0x6f, 0x6e, 0x65, 0x22, 0x58, 0x0a, 0x11, 0x4b, 0x75, 0x6d, + 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2b, + 0x0a, 0x11, 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x73, 0x6b, 0x69, 0x70, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x70, + 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x6c, 0x75, + 0x72, 0x61, 0x6c, 0x3a, 0x5e, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, + 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0xc5, 0x91, 0xe1, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6b, 0x75, 0x6d, 0x61, + 0x2e, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x4b, 0x75, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x3a, 0x58, 0x0a, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x1f, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc6, + 0x91, 0xe1, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6b, 0x75, 0x6d, 0x61, 0x2e, 0x6d, + 0x65, 0x73, 0x68, 0x2e, 0x4b, 0x75, 0x6d, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x4f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x42, 0x21, 0x5a, + 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x6d, 0x61, + 0x68, 0x71, 0x2f, 0x6b, 0x75, 0x6d, 0x61, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x65, 0x73, 0x68, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/mesh/options.proto b/api/mesh/options.proto index 4e1484a2ee63..6141070b513d 100644 --- a/api/mesh/options.proto +++ b/api/mesh/options.proto @@ -40,7 +40,10 @@ message KumaResourceOptions { // The name of the policy showed as plural to be displayed in the UI and maybe // CLI - string display_name = 15; + string plural_display_name = 15; + + // Is Experimental indicates if a policy is in experimental state (might not be production ready). + bool is_experimental = 16; } message KumaWsOptions { diff --git a/api/mesh/v1alpha1/gateway.pb.go b/api/mesh/v1alpha1/gateway.pb.go index bee6c952eb86..99a8154e290f 100644 --- a/api/mesh/v1alpha1/gateway.pb.go +++ b/api/mesh/v1alpha1/gateway.pb.go @@ -602,7 +602,7 @@ var file_mesh_v1alpha1_gateway_proto_rawDesc = []byte{ 0x6f, 0x1a, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa0, 0x0a, 0x0a, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa9, 0x0a, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x68, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x44, 0x0a, 0x09, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6b, 0x75, 0x6d, 0x61, 0x2e, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, @@ -679,18 +679,18 @@ var file_mesh_v1alpha1_gateway_proto_rawDesc = []byte{ 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x3a, 0x59, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x15, 0x0a, 0x13, 0x4d, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x3a, 0x62, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x15, 0x0a, 0x13, 0x4d, 0x65, 0x73, 0x68, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x0d, 0x12, 0x0b, 0x4d, 0x65, 0x73, 0x68, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x06, 0x22, 0x04, 0x6d, 0x65, 0x73, 0x68, - 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x04, 0x52, 0x02, 0x10, 0x01, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x0f, - 0x3a, 0x0d, 0x0a, 0x0b, 0x6d, 0x65, 0x73, 0x68, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x42, - 0x4c, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, - 0x6d, 0x61, 0x68, 0x71, 0x2f, 0x6b, 0x75, 0x6d, 0x61, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x65, - 0x73, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x8a, 0xb5, 0x18, 0x1e, 0x50, - 0x01, 0xa2, 0x01, 0x0b, 0x4d, 0x65, 0x73, 0x68, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0xf2, - 0x01, 0x0b, 0x6d, 0x65, 0x73, 0x68, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x03, 0x80, 0x01, 0x01, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x04, 0x52, + 0x02, 0x10, 0x01, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x0f, 0x3a, 0x0d, 0x0a, 0x0b, 0x6d, 0x65, 0x73, + 0x68, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x42, 0x4c, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x6d, 0x61, 0x68, 0x71, 0x2f, 0x6b, 0x75, + 0x6d, 0x61, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x8a, 0xb5, 0x18, 0x1e, 0x50, 0x01, 0xa2, 0x01, 0x0b, 0x4d, 0x65, 0x73, + 0x68, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0xf2, 0x01, 0x0b, 0x6d, 0x65, 0x73, 0x68, 0x67, + 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/mesh/v1alpha1/gateway.proto b/api/mesh/v1alpha1/gateway.proto index f82dbdce14b7..735f4d80fe7b 100644 --- a/api/mesh/v1alpha1/gateway.proto +++ b/api/mesh/v1alpha1/gateway.proto @@ -29,6 +29,7 @@ message MeshGateway { option (kuma.mesh.resource).name = "MeshGatewayResource"; option (kuma.mesh.resource).type = "MeshGateway"; option (kuma.mesh.resource).package = "mesh"; + option (kuma.mesh.resource).is_experimental = true; option (kuma.mesh.resource).kds.send_to_zone = true; option (kuma.mesh.resource).ws.name = "meshgateway"; diff --git a/api/mesh/v1alpha1/gateway_route.pb.go b/api/mesh/v1alpha1/gateway_route.pb.go index d1c696ea42fa..a99852363718 100644 --- a/api/mesh/v1alpha1/gateway_route.pb.go +++ b/api/mesh/v1alpha1/gateway_route.pb.go @@ -1701,7 +1701,7 @@ var file_mesh_v1alpha1_gateway_route_proto_rawDesc = []byte{ 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x89, 0x21, 0x0a, 0x10, 0x4d, 0x65, 0x73, 0x68, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, + 0x6f, 0x22, 0x92, 0x21, 0x0a, 0x10, 0x4d, 0x65, 0x73, 0x68, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x48, 0x0a, 0x09, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6b, 0x75, 0x6d, 0x61, 0x2e, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, @@ -1959,19 +1959,20 @@ var file_mesh_v1alpha1_gateway_route_proto_rawDesc = []byte{ 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x65, 0x73, 0x68, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x48, 0x00, 0x52, 0x04, 0x68, 0x74, 0x74, 0x70, 0x42, 0x07, 0x0a, 0x05, 0x72, 0x6f, - 0x75, 0x74, 0x65, 0x3a, 0x68, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x1a, 0x0a, 0x18, 0x4d, 0x65, 0x73, + 0x75, 0x74, 0x65, 0x3a, 0x71, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x1a, 0x0a, 0x18, 0x4d, 0x65, 0x73, 0x68, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x12, 0x12, 0x10, 0x4d, 0x65, 0x73, 0x68, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x6f, 0x75, 0x74, 0x65, 0xaa, 0x8c, 0x89, - 0xa6, 0x01, 0x06, 0x22, 0x04, 0x6d, 0x65, 0x73, 0x68, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x04, 0x52, - 0x02, 0x10, 0x01, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x14, 0x3a, 0x12, 0x0a, 0x10, 0x6d, 0x65, 0x73, - 0x68, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x42, 0x56, 0x5a, - 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x6d, 0x61, - 0x68, 0x71, 0x2f, 0x6b, 0x75, 0x6d, 0x61, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x65, 0x73, 0x68, - 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x8a, 0xb5, 0x18, 0x28, 0x50, 0x01, 0xa2, - 0x01, 0x10, 0x4d, 0x65, 0x73, 0x68, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x6f, 0x75, - 0x74, 0x65, 0xf2, 0x01, 0x10, 0x6d, 0x65, 0x73, 0x68, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, - 0x72, 0x6f, 0x75, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0xa6, 0x01, 0x06, 0x22, 0x04, 0x6d, 0x65, 0x73, 0x68, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x03, 0x80, + 0x01, 0x01, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x04, 0x52, 0x02, 0x10, 0x01, 0xaa, 0x8c, 0x89, 0xa6, + 0x01, 0x14, 0x3a, 0x12, 0x0a, 0x10, 0x6d, 0x65, 0x73, 0x68, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, + 0x79, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x42, 0x56, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x6d, 0x61, 0x68, 0x71, 0x2f, 0x6b, 0x75, 0x6d, 0x61, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x8a, 0xb5, 0x18, 0x28, 0x50, 0x01, 0xa2, 0x01, 0x10, 0x4d, 0x65, 0x73, 0x68, 0x47, + 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x6f, 0x75, 0x74, 0x65, 0xf2, 0x01, 0x10, 0x6d, 0x65, + 0x73, 0x68, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/mesh/v1alpha1/gateway_route.proto b/api/mesh/v1alpha1/gateway_route.proto index 96f72f3db8d5..b9fb56a404af 100644 --- a/api/mesh/v1alpha1/gateway_route.proto +++ b/api/mesh/v1alpha1/gateway_route.proto @@ -22,6 +22,7 @@ message MeshGatewayRoute { option (kuma.mesh.resource).name = "MeshGatewayRouteResource"; option (kuma.mesh.resource).type = "MeshGatewayRoute"; option (kuma.mesh.resource).package = "mesh"; + option (kuma.mesh.resource).is_experimental = true; option (kuma.mesh.resource).kds.send_to_zone = true; option (kuma.mesh.resource).ws.name = "meshgatewayroute"; diff --git a/api/mesh/v1alpha1/retry.proto b/api/mesh/v1alpha1/retry.proto index 81382899afb8..fad860382bdf 100644 --- a/api/mesh/v1alpha1/retry.proto +++ b/api/mesh/v1alpha1/retry.proto @@ -38,7 +38,7 @@ message Retry { option (kuma.mesh.resource).name = "RetryResource"; option (kuma.mesh.resource).type = "Retry"; - option (kuma.mesh.resource).display_name = "Retries"; + option (kuma.mesh.resource).plural_display_name = "Retries"; option (kuma.mesh.resource).package = "mesh"; option (kuma.mesh.resource).kds.send_to_zone = true; option (kuma.mesh.resource).ws.name = "retry"; diff --git a/docs/generated/resources/other_mesh.md b/docs/generated/resources/other_mesh.md index 3244d72ab99e..97a146fd52b6 100644 --- a/docs/generated/resources/other_mesh.md +++ b/docs/generated/resources/other_mesh.md @@ -3,121 +3,47 @@ - `mtls` (optional) mTLS settings. - +optional + +optional + + Child properties: - - `enabledBackend` (required) + - `enabledbackend` (required) Name of the enabled backend - `backends` (required, repeated) - List of available Certificate Authority backends - - - `name` (required) - - Name of the backend - - - `type` (required) - - Type of the backend. Has to be one of the loaded plugins (Kuma ships with - builtin and provided) - - - `dpCert` (optional) - - Dataplane certificate settings - - - `rotation` (optional) - - Rotation settings - - - `expiration` (optional) - - Time after which generated certificate for Dataplane will expire - - - `requestTimeout` (optional) - - Timeout on request to CA for DP certificate generation and retrieval - - - `conf` (optional) - - Configuration of the backend - - - `mode` (optional, enum) - - Mode defines the behaviour of inbound listeners with regard to traffic - encryption - - - `STRICT` - - - `PERMISSIVE` - - - `rootChain` (optional) - - - `requestTimeout` (optional) - - Timeout on request for to CA for root certificate chain. + List of available Certificate Authority backends - `tracing` (optional) Tracing settings. - +optional + +optional + + Child properties: - - `defaultBackend` (required) + - `defaultbackend` (required) Name of the default backend - `backends` (required, repeated) - List of available tracing backends - - - `name` (required) - - Name of the backend, can be then used in Mesh.tracing.defaultBackend or in - TrafficTrace - - - `sampling` (optional) - - Percentage of traces that will be sent to the backend (range 0.0 - 100.0). - Empty value defaults to 100.0% - - - `type` (required) - - Type of the backend (Kuma ships with 'zipkin') - - - `conf` (required) - - Configuration of the backend + List of available tracing backends - `logging` (optional) Logging settings. - +optional + +optional + + Child properties: - - `defaultBackend` (required) + - `defaultbackend` (required) Name of the default backend - `backends` (required, repeated) - List of available logging backends - - - `name` (required) - - Name of the backend, can be then used in Mesh.logging.defaultBackend or in - TrafficLogging - - - `format` (optional) - - Format of access logs. Placeholders available on - https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log - - - `type` (required) - - Type of the backend (Kuma ships with 'tcp' and 'file') - - - `conf` (required) - - Configuration of the backend + List of available logging backends - `metrics` (optional) @@ -126,35 +52,29 @@ Settings defined here become defaults for every dataplane in a given Mesh. Additionally, it is also possible to further customize this configuration for each dataplane individually using Dataplane resource. - +optional + +optional + + Child properties: - - `enabledBackend` (optional) + - `enabledbackend` (optional) Name of the enabled backend - `backends` (optional, repeated) - List of available Metrics backends - - - `name` (optional) - - Name of the backend, can be then used in Mesh.metrics.enabledBackend - - - `type` (optional) - - Type of the backend (Kuma ships with 'prometheus') - - - `conf` (optional) - - Configuration of the backend + List of available Metrics backends - `networking` (optional) - Networking settings of the mesh + Networking settings of the mesh + + Child properties: - `outbound` (optional) - Outbound settings + Outbound settings + + Child properties: - `passthrough` (optional) @@ -162,25 +82,31 @@ - `routing` (optional) - Routing settings of the mesh + Routing settings of the mesh + + Child properties: - - `localityAwareLoadBalancing` (optional) + - `localityawareloadbalancing` (optional) Enable the Locality Aware Load Balancing - - `zoneEgress` (optional) + - `zoneegress` (optional) Enable routing traffic to services in other zone or external services through ZoneEgress. Default: false - `constraints` (optional) - Constraints that applies to the mesh and its entities + Constraints that applies to the mesh and its entities + + Child properties: - - `dataplaneProxy` (required) + - `dataplaneproxy` (required) DataplaneProxyMembership defines a set of requirements for data plane - proxies to be a member of the mesh. + proxies to be a member of the mesh. + + Child properties: - `requirements` (optional, repeated) @@ -188,23 +114,13 @@ fulfill in order to join the mesh. A data plane proxy must fulfill at least one requirement in order to join the mesh. Empty list of allowed requirements means that any proxy that is not explicitly denied can join. - - - `tags` (required) - - Tags defines set of required tags. You can specify '*' in value to - require non empty value of tag - `restrictions` (optional, repeated) Restrictions defines a set of restrictions that data plane proxies cannot fulfill in order to join the mesh. A data plane proxy cannot fulfill any requirement in order to join the mesh. - Restrictions takes precedence over requirements. - - - `tags` (required) - - Tags defines set of required tags. You can specify '*' in value to - require non empty value of tag + Restrictions takes precedence over requirements. ## CertificateAuthorityBackend - `name` (required) @@ -216,19 +132,23 @@ Type of the backend. Has to be one of the loaded plugins (Kuma ships with builtin and provided) -- `dpCert` (optional) +- `dpcert` (optional) + + Dataplane certificate settings - Dataplane certificate settings + Child properties: - `rotation` (optional) - Rotation settings + Rotation settings + + Child properties: - `expiration` (optional) Time after which generated certificate for Dataplane will expire - - `requestTimeout` (optional) + - `requesttimeout` (optional) Timeout on request to CA for DP certificate generation and retrieval @@ -236,56 +156,44 @@ Configuration of the backend -- `mode` (optional, enum) +- `mode` (optional) Mode defines the behaviour of inbound listeners with regard to traffic encryption + Supported values: + - `STRICT` - `PERMISSIVE` -- `rootChain` (optional) +- `rootchain` (optional) + + Child properties: - - `requestTimeout` (optional) + - `requesttimeout` (optional) Timeout on request for to CA for root certificate chain. ## Networking - `outbound` (optional) - Outbound settings + Outbound settings + + Child properties: - `passthrough` (optional) Control the passthrough cluster ## Tracing -- `defaultBackend` (required) +- `defaultbackend` (required) Name of the default backend - `backends` (required, repeated) - List of available tracing backends - - - `name` (required) - - Name of the backend, can be then used in Mesh.tracing.defaultBackend or in - TrafficTrace - - - `sampling` (optional) - - Percentage of traces that will be sent to the backend (range 0.0 - 100.0). - Empty value defaults to 100.0% - - - `type` (required) - - Type of the backend (Kuma ships with 'zipkin') - - - `conf` (required) - - Configuration of the backend + List of available tracing backends ## TracingBackend - `name` (required) @@ -320,48 +228,30 @@ Address of Zipkin collector. -- `traceId128bit` (optional) +- `traceid128bit` (optional) Generate 128bit traces. Default: false -- `apiVersion` (required) +- `apiversion` (required) Version of the API. values: httpJson, httpJsonV1, httpProto. Default: httpJson see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/trace/v3/trace.proto#envoy-v3-api-enum-config-trace-v3-zipkinconfig-collectorendpointversion -- `sharedSpanContext` (optional) +- `sharedspancontext` (optional) Determines whether client and server spans will share the same span context. Default: true. https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/trace/v3/zipkin.proto#config-trace-v3-zipkinconfig ## Logging -- `defaultBackend` (required) +- `defaultbackend` (required) Name of the default backend - `backends` (required, repeated) - List of available logging backends - - - `name` (required) - - Name of the backend, can be then used in Mesh.logging.defaultBackend or in - TrafficLogging - - - `format` (optional) - - Format of access logs. Placeholders available on - https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log - - - `type` (required) - - Type of the backend (Kuma ships with 'tcp' and 'file') - - - `conf` (required) - - Configuration of the backend + List of available logging backends ## LoggingBackend - `name` (required) @@ -393,11 +283,11 @@ Address to TCP service that will receive logs ## Routing -- `localityAwareLoadBalancing` (optional) +- `localityawareloadbalancing` (optional) Enable the Locality Aware Load Balancing -- `zoneEgress` (optional) +- `zoneegress` (optional) Enable routing traffic to services in other zone or external services through ZoneEgress. Default: false diff --git a/pkg/api-server/policies_endpoints.go b/pkg/api-server/policies_endpoints.go index 719f9f3a742b..0d1f6a242842 100644 --- a/pkg/api-server/policies_endpoints.go +++ b/pkg/api-server/policies_endpoints.go @@ -18,10 +18,12 @@ func addPoliciesWsEndpoints(ws *restful.WebService, mode core.CpMode, readOnly b continue } response.Policies = append(response.Policies, types.PolicyEntry{ - Name: string(def.Name), - ReadOnly: readOnly || core.Zone == mode || def.ReadOnly, - Path: def.WsPath, - DisplayName: def.DisplayName, + Name: string(def.Name), + ReadOnly: readOnly || core.Zone == mode || def.ReadOnly, + Path: def.WsPath, + SingularDisplayName: def.SingularDisplayName, + PluralDisplayName: def.PluralDisplayName, + IsExperimental: def.IsExperimental, }) } sort.SliceStable(response.Policies, func(i, j int) bool { diff --git a/pkg/api-server/testdata/policies_list.golden.json b/pkg/api-server/testdata/policies_list.golden.json index b2c5b7a782d3..77bc15d6a637 100644 --- a/pkg/api-server/testdata/policies_list.golden.json +++ b/pkg/api-server/testdata/policies_list.golden.json @@ -4,91 +4,113 @@ "name": "CircuitBreaker", "readOnly": false, "path": "circuit-breakers", - "displayName": "Circuit Breakers" - }, - { - "name": "ExternalService", - "readOnly": false, - "path": "external-services", - "displayName": "External Services" + "singularDisplayName": "Circuit Breaker", + "pluralDisplayName": "Circuit Breakers", + "isExperimental": false }, { "name": "FaultInjection", "readOnly": false, "path": "fault-injections", - "displayName": "Fault Injections" + "singularDisplayName": "Fault Injection", + "pluralDisplayName": "Fault Injections", + "isExperimental": false }, { "name": "HealthCheck", "readOnly": false, "path": "health-checks", - "displayName": "Health Checks" + "singularDisplayName": "Health Check", + "pluralDisplayName": "Health Checks", + "isExperimental": false }, { "name": "MeshGateway", "readOnly": false, "path": "meshgateways", - "displayName": "Mesh Gateways" + "singularDisplayName": "Mesh Gateway", + "pluralDisplayName": "Mesh Gateways", + "isExperimental": true }, { "name": "MeshGatewayRoute", "readOnly": false, "path": "meshgatewayroutes", - "displayName": "Mesh Gateway Routes" + "singularDisplayName": "Mesh Gateway Route", + "pluralDisplayName": "Mesh Gateway Routes", + "isExperimental": true }, { "name": "ProxyTemplate", "readOnly": false, "path": "proxytemplates", - "displayName": "Proxy Templates" + "singularDisplayName": "Proxy Template", + "pluralDisplayName": "Proxy Templates", + "isExperimental": false }, { "name": "RateLimit", "readOnly": false, "path": "rate-limits", - "displayName": "Rate Limits" + "singularDisplayName": "Rate Limit", + "pluralDisplayName": "Rate Limits", + "isExperimental": false }, { "name": "Retry", "readOnly": false, "path": "retries", - "displayName": "Retries" + "singularDisplayName": "Retry", + "pluralDisplayName": "Retries", + "isExperimental": false }, { "name": "Timeout", "readOnly": false, "path": "timeouts", - "displayName": "Timeouts" + "singularDisplayName": "Timeout", + "pluralDisplayName": "Timeouts", + "isExperimental": false }, { "name": "TrafficLog", "readOnly": false, "path": "traffic-logs", - "displayName": "Traffic Logs" + "singularDisplayName": "Traffic Log", + "pluralDisplayName": "Traffic Logs", + "isExperimental": false }, { "name": "TrafficPermission", "readOnly": false, "path": "traffic-permissions", - "displayName": "Traffic Permissions" + "singularDisplayName": "Traffic Permission", + "pluralDisplayName": "Traffic Permissions", + "isExperimental": false }, { "name": "TrafficRoute", "readOnly": false, "path": "traffic-routes", - "displayName": "Traffic Routes" + "singularDisplayName": "Traffic Route", + "pluralDisplayName": "Traffic Routes", + "isExperimental": false }, { "name": "TrafficTrace", "readOnly": false, "path": "traffic-traces", - "displayName": "Traffic Traces" + "singularDisplayName": "Traffic Trace", + "pluralDisplayName": "Traffic Traces", + "isExperimental": false }, { "name": "VirtualOutbound", "readOnly": false, "path": "virtual-outbounds", - "displayName": "Virtual Outbounds" + "singularDisplayName": "Virtual Outbound", + "pluralDisplayName": "Virtual Outbounds", + "isExperimental": false } ] } diff --git a/pkg/api-server/types/policies.go b/pkg/api-server/types/policies.go index d729cc7f6f75..ac14f72ecefc 100644 --- a/pkg/api-server/types/policies.go +++ b/pkg/api-server/types/policies.go @@ -5,8 +5,10 @@ type PoliciesResponse struct { } type PolicyEntry struct { - Name string `json:"name"` - ReadOnly bool `json:"readOnly"` - Path string `json:"path"` - DisplayName string `json:"displayName"` + Name string `json:"name"` + ReadOnly bool `json:"readOnly"` + Path string `json:"path"` + SingularDisplayName string `json:"singularDisplayName"` + PluralDisplayName string `json:"pluralDisplayName"` + IsExperimental bool `json:"isExperimental"` } diff --git a/pkg/core/resources/apis/mesh/zz_generated.resources.go b/pkg/core/resources/apis/mesh/zz_generated.resources.go index 1faafeebbf46..d3885f3dea3d 100644 --- a/pkg/core/resources/apis/mesh/zz_generated.resources.go +++ b/pkg/core/resources/apis/mesh/zz_generated.resources.go @@ -104,19 +104,21 @@ func (l *CircuitBreakerResourceList) GetPagination() *model.Pagination { } var CircuitBreakerResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: CircuitBreakerType, - Resource: NewCircuitBreakerResource(), - ResourceList: &CircuitBreakerResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "circuit-breakers", - KumactlArg: "circuit-breaker", - KumactlListArg: "circuit-breakers", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Circuit Breakers", + Name: CircuitBreakerType, + Resource: NewCircuitBreakerResource(), + ResourceList: &CircuitBreakerResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "circuit-breakers", + KumactlArg: "circuit-breaker", + KumactlListArg: "circuit-breakers", + AllowToInspect: true, + IsPolicy: true, + SingularDisplayName: "Circuit Breaker", + PluralDisplayName: "Circuit Breakers", + IsExperimental: false, } func init() { @@ -207,19 +209,21 @@ func (l *DataplaneResourceList) GetPagination() *model.Pagination { } var DataplaneResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: DataplaneType, - Resource: NewDataplaneResource(), - ResourceList: &DataplaneResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromZoneToGlobal, - WsPath: "dataplanes", - KumactlArg: "dataplane", - KumactlListArg: "dataplanes", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: DataplaneType, + Resource: NewDataplaneResource(), + ResourceList: &DataplaneResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromZoneToGlobal, + WsPath: "dataplanes", + KumactlArg: "dataplane", + KumactlListArg: "dataplanes", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Dataplane", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -310,19 +314,21 @@ func (l *DataplaneInsightResourceList) GetPagination() *model.Pagination { } var DataplaneInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: DataplaneInsightType, - Resource: NewDataplaneInsightResource(), - ResourceList: &DataplaneInsightResourceList{}, - ReadOnly: true, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromZoneToGlobal, - WsPath: "dataplane-insights", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: DataplaneInsightType, + Resource: NewDataplaneInsightResource(), + ResourceList: &DataplaneInsightResourceList{}, + ReadOnly: true, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromZoneToGlobal, + WsPath: "dataplane-insights", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Dataplane Insight", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -413,18 +419,20 @@ func (l *DataplaneOverviewResourceList) GetPagination() *model.Pagination { } var DataplaneOverviewResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: DataplaneOverviewType, - Resource: NewDataplaneOverviewResource(), - ResourceList: &DataplaneOverviewResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - WsPath: "", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: DataplaneOverviewType, + Resource: NewDataplaneOverviewResource(), + ResourceList: &DataplaneOverviewResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + WsPath: "", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Dataplane Overview", + PluralDisplayName: "", + IsExperimental: false, } const ( @@ -511,19 +519,21 @@ func (l *ExternalServiceResourceList) GetPagination() *model.Pagination { } var ExternalServiceResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ExternalServiceType, - Resource: NewExternalServiceResource(), - ResourceList: &ExternalServiceResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "external-services", - KumactlArg: "external-service", - KumactlListArg: "external-services", - AllowToInspect: false, - IsPolicy: true, - DisplayName: "External Services", + Name: ExternalServiceType, + Resource: NewExternalServiceResource(), + ResourceList: &ExternalServiceResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "external-services", + KumactlArg: "external-service", + KumactlListArg: "external-services", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "External Service", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -622,19 +632,21 @@ func (l *FaultInjectionResourceList) GetPagination() *model.Pagination { } var FaultInjectionResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: FaultInjectionType, - Resource: NewFaultInjectionResource(), - ResourceList: &FaultInjectionResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "fault-injections", - KumactlArg: "fault-injection", - KumactlListArg: "fault-injections", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Fault Injections", + Name: FaultInjectionType, + Resource: NewFaultInjectionResource(), + ResourceList: &FaultInjectionResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "fault-injections", + KumactlArg: "fault-injection", + KumactlListArg: "fault-injections", + AllowToInspect: true, + IsPolicy: true, + SingularDisplayName: "Fault Injection", + PluralDisplayName: "Fault Injections", + IsExperimental: false, } func init() { @@ -733,19 +745,21 @@ func (l *HealthCheckResourceList) GetPagination() *model.Pagination { } var HealthCheckResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: HealthCheckType, - Resource: NewHealthCheckResource(), - ResourceList: &HealthCheckResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "health-checks", - KumactlArg: "healthcheck", - KumactlListArg: "healthchecks", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Health Checks", + Name: HealthCheckType, + Resource: NewHealthCheckResource(), + ResourceList: &HealthCheckResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "health-checks", + KumactlArg: "healthcheck", + KumactlListArg: "healthchecks", + AllowToInspect: true, + IsPolicy: true, + SingularDisplayName: "Health Check", + PluralDisplayName: "Health Checks", + IsExperimental: false, } func init() { @@ -836,19 +850,21 @@ func (l *MeshResourceList) GetPagination() *model.Pagination { } var MeshResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: MeshType, - Resource: NewMeshResource(), - ResourceList: &MeshResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeGlobal, - KDSFlags: model.FromGlobalToZone, - WsPath: "meshes", - KumactlArg: "mesh", - KumactlListArg: "meshes", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: MeshType, + Resource: NewMeshResource(), + ResourceList: &MeshResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeGlobal, + KDSFlags: model.FromGlobalToZone, + WsPath: "meshes", + KumactlArg: "mesh", + KumactlListArg: "meshes", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Mesh", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -943,19 +959,21 @@ func (l *MeshGatewayResourceList) GetPagination() *model.Pagination { } var MeshGatewayResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: MeshGatewayType, - Resource: NewMeshGatewayResource(), - ResourceList: &MeshGatewayResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "meshgateways", - KumactlArg: "meshgateway", - KumactlListArg: "meshgateways", - AllowToInspect: false, - IsPolicy: true, - DisplayName: "Mesh Gateways", + Name: MeshGatewayType, + Resource: NewMeshGatewayResource(), + ResourceList: &MeshGatewayResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "meshgateways", + KumactlArg: "meshgateway", + KumactlListArg: "meshgateways", + AllowToInspect: false, + IsPolicy: true, + SingularDisplayName: "Mesh Gateway", + PluralDisplayName: "Mesh Gateways", + IsExperimental: true, } func init() { @@ -1050,19 +1068,21 @@ func (l *MeshGatewayRouteResourceList) GetPagination() *model.Pagination { } var MeshGatewayRouteResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: MeshGatewayRouteType, - Resource: NewMeshGatewayRouteResource(), - ResourceList: &MeshGatewayRouteResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "meshgatewayroutes", - KumactlArg: "meshgatewayroute", - KumactlListArg: "meshgatewayroutes", - AllowToInspect: false, - IsPolicy: true, - DisplayName: "Mesh Gateway Routes", + Name: MeshGatewayRouteType, + Resource: NewMeshGatewayRouteResource(), + ResourceList: &MeshGatewayRouteResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "meshgatewayroutes", + KumactlArg: "meshgatewayroute", + KumactlListArg: "meshgatewayroutes", + AllowToInspect: false, + IsPolicy: true, + SingularDisplayName: "Mesh Gateway Route", + PluralDisplayName: "Mesh Gateway Routes", + IsExperimental: true, } func init() { @@ -1153,18 +1173,20 @@ func (l *MeshInsightResourceList) GetPagination() *model.Pagination { } var MeshInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: MeshInsightType, - Resource: NewMeshInsightResource(), - ResourceList: &MeshInsightResourceList{}, - ReadOnly: true, - AdminOnly: false, - Scope: model.ScopeGlobal, - WsPath: "mesh-insights", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: MeshInsightType, + Resource: NewMeshInsightResource(), + ResourceList: &MeshInsightResourceList{}, + ReadOnly: true, + AdminOnly: false, + Scope: model.ScopeGlobal, + WsPath: "mesh-insights", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Mesh Insight", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -1259,19 +1281,21 @@ func (l *ProxyTemplateResourceList) GetPagination() *model.Pagination { } var ProxyTemplateResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ProxyTemplateType, - Resource: NewProxyTemplateResource(), - ResourceList: &ProxyTemplateResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "proxytemplates", - KumactlArg: "proxytemplate", - KumactlListArg: "proxytemplates", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Proxy Templates", + Name: ProxyTemplateType, + Resource: NewProxyTemplateResource(), + ResourceList: &ProxyTemplateResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "proxytemplates", + KumactlArg: "proxytemplate", + KumactlListArg: "proxytemplates", + AllowToInspect: true, + IsPolicy: true, + SingularDisplayName: "Proxy Template", + PluralDisplayName: "Proxy Templates", + IsExperimental: false, } func init() { @@ -1370,19 +1394,21 @@ func (l *RateLimitResourceList) GetPagination() *model.Pagination { } var RateLimitResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: RateLimitType, - Resource: NewRateLimitResource(), - ResourceList: &RateLimitResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "rate-limits", - KumactlArg: "rate-limit", - KumactlListArg: "rate-limits", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Rate Limits", + Name: RateLimitType, + Resource: NewRateLimitResource(), + ResourceList: &RateLimitResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "rate-limits", + KumactlArg: "rate-limit", + KumactlListArg: "rate-limits", + AllowToInspect: true, + IsPolicy: true, + SingularDisplayName: "Rate Limit", + PluralDisplayName: "Rate Limits", + IsExperimental: false, } func init() { @@ -1481,19 +1507,21 @@ func (l *RetryResourceList) GetPagination() *model.Pagination { } var RetryResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: RetryType, - Resource: NewRetryResource(), - ResourceList: &RetryResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "retries", - KumactlArg: "retry", - KumactlListArg: "retries", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Retries", + Name: RetryType, + Resource: NewRetryResource(), + ResourceList: &RetryResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "retries", + KumactlArg: "retry", + KumactlListArg: "retries", + AllowToInspect: true, + IsPolicy: true, + SingularDisplayName: "Retry", + PluralDisplayName: "Retries", + IsExperimental: false, } func init() { @@ -1584,19 +1612,21 @@ func (l *ServiceInsightResourceList) GetPagination() *model.Pagination { } var ServiceInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ServiceInsightType, - Resource: NewServiceInsightResource(), - ResourceList: &ServiceInsightResourceList{}, - ReadOnly: true, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "service-insights", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ServiceInsightType, + Resource: NewServiceInsightResource(), + ResourceList: &ServiceInsightResourceList{}, + ReadOnly: true, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "service-insights", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Service Insight", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -1687,18 +1717,20 @@ func (l *ServiceOverviewResourceList) GetPagination() *model.Pagination { } var ServiceOverviewResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ServiceOverviewType, - Resource: NewServiceOverviewResource(), - ResourceList: &ServiceOverviewResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - WsPath: "", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ServiceOverviewType, + Resource: NewServiceOverviewResource(), + ResourceList: &ServiceOverviewResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + WsPath: "", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Service Overview", + PluralDisplayName: "", + IsExperimental: false, } const ( @@ -1793,19 +1825,21 @@ func (l *TimeoutResourceList) GetPagination() *model.Pagination { } var TimeoutResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: TimeoutType, - Resource: NewTimeoutResource(), - ResourceList: &TimeoutResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "timeouts", - KumactlArg: "timeout", - KumactlListArg: "timeouts", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Timeouts", + Name: TimeoutType, + Resource: NewTimeoutResource(), + ResourceList: &TimeoutResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "timeouts", + KumactlArg: "timeout", + KumactlListArg: "timeouts", + AllowToInspect: true, + IsPolicy: true, + SingularDisplayName: "Timeout", + PluralDisplayName: "Timeouts", + IsExperimental: false, } func init() { @@ -1904,19 +1938,21 @@ func (l *TrafficLogResourceList) GetPagination() *model.Pagination { } var TrafficLogResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: TrafficLogType, - Resource: NewTrafficLogResource(), - ResourceList: &TrafficLogResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "traffic-logs", - KumactlArg: "traffic-log", - KumactlListArg: "traffic-logs", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Traffic Logs", + Name: TrafficLogType, + Resource: NewTrafficLogResource(), + ResourceList: &TrafficLogResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "traffic-logs", + KumactlArg: "traffic-log", + KumactlListArg: "traffic-logs", + AllowToInspect: true, + IsPolicy: true, + SingularDisplayName: "Traffic Log", + PluralDisplayName: "Traffic Logs", + IsExperimental: false, } func init() { @@ -2015,19 +2051,21 @@ func (l *TrafficPermissionResourceList) GetPagination() *model.Pagination { } var TrafficPermissionResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: TrafficPermissionType, - Resource: NewTrafficPermissionResource(), - ResourceList: &TrafficPermissionResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "traffic-permissions", - KumactlArg: "traffic-permission", - KumactlListArg: "traffic-permissions", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Traffic Permissions", + Name: TrafficPermissionType, + Resource: NewTrafficPermissionResource(), + ResourceList: &TrafficPermissionResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "traffic-permissions", + KumactlArg: "traffic-permission", + KumactlListArg: "traffic-permissions", + AllowToInspect: true, + IsPolicy: true, + SingularDisplayName: "Traffic Permission", + PluralDisplayName: "Traffic Permissions", + IsExperimental: false, } func init() { @@ -2126,19 +2164,21 @@ func (l *TrafficRouteResourceList) GetPagination() *model.Pagination { } var TrafficRouteResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: TrafficRouteType, - Resource: NewTrafficRouteResource(), - ResourceList: &TrafficRouteResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "traffic-routes", - KumactlArg: "traffic-route", - KumactlListArg: "traffic-routes", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Traffic Routes", + Name: TrafficRouteType, + Resource: NewTrafficRouteResource(), + ResourceList: &TrafficRouteResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "traffic-routes", + KumactlArg: "traffic-route", + KumactlListArg: "traffic-routes", + AllowToInspect: true, + IsPolicy: true, + SingularDisplayName: "Traffic Route", + PluralDisplayName: "Traffic Routes", + IsExperimental: false, } func init() { @@ -2233,19 +2273,21 @@ func (l *TrafficTraceResourceList) GetPagination() *model.Pagination { } var TrafficTraceResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: TrafficTraceType, - Resource: NewTrafficTraceResource(), - ResourceList: &TrafficTraceResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "traffic-traces", - KumactlArg: "traffic-trace", - KumactlListArg: "traffic-traces", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Traffic Traces", + Name: TrafficTraceType, + Resource: NewTrafficTraceResource(), + ResourceList: &TrafficTraceResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "traffic-traces", + KumactlArg: "traffic-trace", + KumactlListArg: "traffic-traces", + AllowToInspect: true, + IsPolicy: true, + SingularDisplayName: "Traffic Trace", + PluralDisplayName: "Traffic Traces", + IsExperimental: false, } func init() { @@ -2340,19 +2382,21 @@ func (l *VirtualOutboundResourceList) GetPagination() *model.Pagination { } var VirtualOutboundResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: VirtualOutboundType, - Resource: NewVirtualOutboundResource(), - ResourceList: &VirtualOutboundResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "virtual-outbounds", - KumactlArg: "virtual-outbound", - KumactlListArg: "virtual-outbounds", - AllowToInspect: false, - IsPolicy: true, - DisplayName: "Virtual Outbounds", + Name: VirtualOutboundType, + Resource: NewVirtualOutboundResource(), + ResourceList: &VirtualOutboundResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "virtual-outbounds", + KumactlArg: "virtual-outbound", + KumactlListArg: "virtual-outbounds", + AllowToInspect: false, + IsPolicy: true, + SingularDisplayName: "Virtual Outbound", + PluralDisplayName: "Virtual Outbounds", + IsExperimental: false, } func init() { @@ -2443,19 +2487,21 @@ func (l *ZoneEgressResourceList) GetPagination() *model.Pagination { } var ZoneEgressResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ZoneEgressType, - Resource: NewZoneEgressResource(), - ResourceList: &ZoneEgressResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeGlobal, - KDSFlags: model.FromZoneToGlobal, - WsPath: "zoneegresses", - KumactlArg: "zoneegress", - KumactlListArg: "zoneegresses", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ZoneEgressType, + Resource: NewZoneEgressResource(), + ResourceList: &ZoneEgressResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeGlobal, + KDSFlags: model.FromZoneToGlobal, + WsPath: "zoneegresses", + KumactlArg: "zoneegress", + KumactlListArg: "zoneegresses", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Zone Egress", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -2546,19 +2592,21 @@ func (l *ZoneEgressInsightResourceList) GetPagination() *model.Pagination { } var ZoneEgressInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ZoneEgressInsightType, - Resource: NewZoneEgressInsightResource(), - ResourceList: &ZoneEgressInsightResourceList{}, - ReadOnly: true, - AdminOnly: false, - Scope: model.ScopeGlobal, - KDSFlags: model.FromZoneToGlobal, - WsPath: "zoneegressinsights", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ZoneEgressInsightType, + Resource: NewZoneEgressInsightResource(), + ResourceList: &ZoneEgressInsightResourceList{}, + ReadOnly: true, + AdminOnly: false, + Scope: model.ScopeGlobal, + KDSFlags: model.FromZoneToGlobal, + WsPath: "zoneegressinsights", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Zone Egress Insight", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -2649,18 +2697,20 @@ func (l *ZoneEgressOverviewResourceList) GetPagination() *model.Pagination { } var ZoneEgressOverviewResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ZoneEgressOverviewType, - Resource: NewZoneEgressOverviewResource(), - ResourceList: &ZoneEgressOverviewResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeGlobal, - WsPath: "", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ZoneEgressOverviewType, + Resource: NewZoneEgressOverviewResource(), + ResourceList: &ZoneEgressOverviewResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeGlobal, + WsPath: "", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Zone Egress Overview", + PluralDisplayName: "", + IsExperimental: false, } const ( @@ -2747,19 +2797,21 @@ func (l *ZoneIngressResourceList) GetPagination() *model.Pagination { } var ZoneIngressResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ZoneIngressType, - Resource: NewZoneIngressResource(), - ResourceList: &ZoneIngressResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeGlobal, - KDSFlags: model.FromZoneToGlobal | model.FromGlobalToZone, - WsPath: "zone-ingresses", - KumactlArg: "zone-ingress", - KumactlListArg: "zone-ingresses", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ZoneIngressType, + Resource: NewZoneIngressResource(), + ResourceList: &ZoneIngressResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeGlobal, + KDSFlags: model.FromZoneToGlobal | model.FromGlobalToZone, + WsPath: "zone-ingresses", + KumactlArg: "zone-ingress", + KumactlListArg: "zone-ingresses", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Zone Ingress", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -2850,19 +2902,21 @@ func (l *ZoneIngressInsightResourceList) GetPagination() *model.Pagination { } var ZoneIngressInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ZoneIngressInsightType, - Resource: NewZoneIngressInsightResource(), - ResourceList: &ZoneIngressInsightResourceList{}, - ReadOnly: true, - AdminOnly: false, - Scope: model.ScopeGlobal, - KDSFlags: model.FromZoneToGlobal, - WsPath: "zone-ingress-insights", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ZoneIngressInsightType, + Resource: NewZoneIngressInsightResource(), + ResourceList: &ZoneIngressInsightResourceList{}, + ReadOnly: true, + AdminOnly: false, + Scope: model.ScopeGlobal, + KDSFlags: model.FromZoneToGlobal, + WsPath: "zone-ingress-insights", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Zone Ingress Insight", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -2953,16 +3007,18 @@ func (l *ZoneIngressOverviewResourceList) GetPagination() *model.Pagination { } var ZoneIngressOverviewResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ZoneIngressOverviewType, - Resource: NewZoneIngressOverviewResource(), - ResourceList: &ZoneIngressOverviewResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeGlobal, - WsPath: "", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ZoneIngressOverviewType, + Resource: NewZoneIngressOverviewResource(), + ResourceList: &ZoneIngressOverviewResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeGlobal, + WsPath: "", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Zone Ingress Overview", + PluralDisplayName: "", + IsExperimental: false, } diff --git a/pkg/core/resources/apis/system/zz_generated.resources.go b/pkg/core/resources/apis/system/zz_generated.resources.go index be615ee14940..1ac7d7cb47b9 100644 --- a/pkg/core/resources/apis/system/zz_generated.resources.go +++ b/pkg/core/resources/apis/system/zz_generated.resources.go @@ -96,19 +96,21 @@ func (l *ConfigResourceList) GetPagination() *model.Pagination { } var ConfigResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ConfigType, - Resource: NewConfigResource(), - ResourceList: &ConfigResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeGlobal, - KDSFlags: model.FromGlobalToZone, - WsPath: "", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ConfigType, + Resource: NewConfigResource(), + ResourceList: &ConfigResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeGlobal, + KDSFlags: model.FromGlobalToZone, + WsPath: "", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Config", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -199,19 +201,21 @@ func (l *SecretResourceList) GetPagination() *model.Pagination { } var SecretResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: SecretType, - Resource: NewSecretResource(), - ResourceList: &SecretResourceList{}, - ReadOnly: false, - AdminOnly: true, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "secrets", - KumactlArg: "secret", - KumactlListArg: "secrets", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: SecretType, + Resource: NewSecretResource(), + ResourceList: &SecretResourceList{}, + ReadOnly: false, + AdminOnly: true, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "secrets", + KumactlArg: "secret", + KumactlListArg: "secrets", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Secret", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -302,18 +306,20 @@ func (l *ZoneResourceList) GetPagination() *model.Pagination { } var ZoneResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ZoneType, - Resource: NewZoneResource(), - ResourceList: &ZoneResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeGlobal, - WsPath: "zones", - KumactlArg: "zone", - KumactlListArg: "zones", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ZoneType, + Resource: NewZoneResource(), + ResourceList: &ZoneResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeGlobal, + WsPath: "zones", + KumactlArg: "zone", + KumactlListArg: "zones", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Zone", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -404,18 +410,20 @@ func (l *ZoneInsightResourceList) GetPagination() *model.Pagination { } var ZoneInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ZoneInsightType, - Resource: NewZoneInsightResource(), - ResourceList: &ZoneInsightResourceList{}, - ReadOnly: true, - AdminOnly: false, - Scope: model.ScopeGlobal, - WsPath: "zone-insights", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ZoneInsightType, + Resource: NewZoneInsightResource(), + ResourceList: &ZoneInsightResourceList{}, + ReadOnly: true, + AdminOnly: false, + Scope: model.ScopeGlobal, + WsPath: "zone-insights", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Zone Insight", + PluralDisplayName: "", + IsExperimental: false, } func init() { @@ -506,16 +514,18 @@ func (l *ZoneOverviewResourceList) GetPagination() *model.Pagination { } var ZoneOverviewResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: ZoneOverviewType, - Resource: NewZoneOverviewResource(), - ResourceList: &ZoneOverviewResourceList{}, - ReadOnly: false, - AdminOnly: false, - Scope: model.ScopeGlobal, - WsPath: "", - KumactlArg: "", - KumactlListArg: "", - AllowToInspect: false, - IsPolicy: false, - DisplayName: "", + Name: ZoneOverviewType, + Resource: NewZoneOverviewResource(), + ResourceList: &ZoneOverviewResourceList{}, + ReadOnly: false, + AdminOnly: false, + Scope: model.ScopeGlobal, + WsPath: "", + KumactlArg: "", + KumactlListArg: "", + AllowToInspect: false, + IsPolicy: false, + SingularDisplayName: "Zone Overview", + PluralDisplayName: "", + IsExperimental: false, } diff --git a/pkg/core/resources/model/resource.go b/pkg/core/resources/model/resource.go index 7f9467c2be58..de39109bbf8c 100644 --- a/pkg/core/resources/model/resource.go +++ b/pkg/core/resources/model/resource.go @@ -103,7 +103,11 @@ type ResourceTypeDescriptor struct { // IsPolicy if this type is a policy (Dataplanes, Insights, Ingresses are not policies as they describe either metadata or workload, Retries are policies). IsPolicy bool // DisplayName the name of the policy showed as plural to be displayed in the UI and maybe CLI - DisplayName string + SingularDisplayName string + // PluralDisplayName the name of the policy showed as plural to be displayed in the UI and maybe CLI + PluralDisplayName string + // IsExperimental indicates if a policy is in experimental state (might not be production ready). + IsExperimental bool } func (d ResourceTypeDescriptor) NewObject() Resource { diff --git a/pkg/plugins/policies/donothingpolicy/api/v1alpha1/zz_generated.resource.go b/pkg/plugins/policies/donothingpolicy/api/v1alpha1/zz_generated.resource.go index d405be85b7ed..8b175c250529 100644 --- a/pkg/plugins/policies/donothingpolicy/api/v1alpha1/zz_generated.resource.go +++ b/pkg/plugins/policies/donothingpolicy/api/v1alpha1/zz_generated.resource.go @@ -102,15 +102,17 @@ func (l *DoNothingPolicyResourceList) GetPagination() *model.Pagination { } var DoNothingPolicyResourceTypeDescriptor = model.ResourceTypeDescriptor{ - Name: DoNothingPolicyType, - Resource: NewDoNothingPolicyResource(), - ResourceList: &DoNothingPolicyResourceList{}, - Scope: model.ScopeMesh, - KDSFlags: model.FromGlobalToZone, - WsPath: "donothingpolicies", - KumactlArg: "donothingpolicy", - KumactlListArg: "donothingpolicies", - AllowToInspect: true, - IsPolicy: true, - DisplayName: "Do Nothing Policies", + Name: DoNothingPolicyType, + Resource: NewDoNothingPolicyResource(), + ResourceList: &DoNothingPolicyResourceList{}, + Scope: model.ScopeMesh, + KDSFlags: model.FromGlobalToZone, + WsPath: "donothingpolicies", + KumactlArg: "donothingpolicy", + KumactlListArg: "donothingpolicies", + AllowToInspect: true, + IsPolicy: true, + IsExperimental: false, + SingularDisplayName: "Do Nothing Policy", + PluralDisplayName: "Do Nothing Policies", } diff --git a/tools/policy-gen/protoc-gen-kumapolicy/resource.go b/tools/policy-gen/protoc-gen-kumapolicy/resource.go index c38632a2a82f..8b979b2f851b 100644 --- a/tools/policy-gen/protoc-gen-kumapolicy/resource.go +++ b/tools/policy-gen/protoc-gen-kumapolicy/resource.go @@ -127,7 +127,9 @@ var {{.Name}}ResourceTypeDescriptor = model.ResourceTypeDescriptor{ KumactlListArg: "{{.Path}}", AllowToInspect: true, IsPolicy: true, - DisplayName: "{{.DisplayName}}", + IsExperimental: false, + SingularDisplayName: "{{.SingularDisplayName}}", + PluralDisplayName: "{{.PluralDisplayName}}", } {{end}} `)) diff --git a/tools/policy-gen/protoc-gen-kumapolicy/utils.go b/tools/policy-gen/protoc-gen-kumapolicy/utils.go index 4dc7e7c59dd5..23ba84d7d69f 100644 --- a/tools/policy-gen/protoc-gen-kumapolicy/utils.go +++ b/tools/policy-gen/protoc-gen-kumapolicy/utils.go @@ -11,12 +11,13 @@ import ( ) type PolicyConfig struct { - Name string - Plural string - SkipRegistration bool - DisplayName string - Path string - AlternativeNames []string + Name string + Plural string + SkipRegistration bool + SingularDisplayName string + PluralDisplayName string + Path string + AlternativeNames []string } func NewPolicyConfig(desc protoreflect.MessageDescriptor) PolicyConfig { @@ -40,11 +41,17 @@ func NewPolicyConfig(desc protoreflect.MessageDescriptor) PolicyConfig { res.Plural = res.Name + "s" } } + for i, c := range res.Name { + if unicode.IsUpper(c) && i != 0 { + res.SingularDisplayName += " " + } + res.SingularDisplayName += string(c) + } for i, c := range res.Plural { if unicode.IsUpper(c) && i != 0 { - res.DisplayName += " " + res.PluralDisplayName += " " } - res.DisplayName += string(c) + res.PluralDisplayName += string(c) } res.Path = strings.ToLower(res.Plural) res.AlternativeNames = []string{strings.ToLower(res.Name)} diff --git a/tools/resource-gen/genutils/util.go b/tools/resource-gen/genutils/util.go index d67fbafc909f..8bb281eab035 100644 --- a/tools/resource-gen/genutils/util.go +++ b/tools/resource-gen/genutils/util.go @@ -58,7 +58,9 @@ type ResourceInfo struct { AllowToInspect bool StorageVersion bool IsPolicy bool - DisplayName string + SingularDisplayName string + PluralDisplayName string + IsExperimental bool } func ToResourceInfo(desc protoreflect.MessageDescriptor) ResourceInfo { @@ -75,7 +77,8 @@ func ToResourceInfo(desc protoreflect.MessageDescriptor) ResourceInfo { ScopeNamespace: r.ScopeNamespace, AllowToInspect: r.AllowToInspect, StorageVersion: r.StorageVersion, - DisplayName: r.DisplayName, + PluralDisplayName: r.PluralDisplayName, + IsExperimental: r.IsExperimental, } if r.Ws != nil { pluralResourceName := r.Ws.Plural @@ -95,17 +98,17 @@ func ToResourceInfo(desc protoreflect.MessageDescriptor) ResourceInfo { } } } + for i, c := range out.ResourceType { + if unicode.IsUpper(c) && i != 0 { + out.SingularDisplayName += " " + } + out.SingularDisplayName += string(c) + } // Working around the fact we don't really differentiate policies from the rest of resources: // Anything global can't be a policy as it need to be on a mesh. Anything with locked Ws config is something internal and therefore not a policy - out.IsPolicy = !out.SkipRegistration && !out.Global && !out.WsAdminOnly && !out.WsReadOnly && out.ResourceType != "Dataplane" - if out.DisplayName == "" && out.IsPolicy { - for i, c := range out.ResourceType { - if unicode.IsUpper(c) && i != 0 { - out.DisplayName += " " - } - out.DisplayName += string(c) - } - out.DisplayName += "s" + out.IsPolicy = !out.SkipRegistration && !out.Global && !out.WsAdminOnly && !out.WsReadOnly && out.ResourceType != "Dataplane" && out.ResourceType != "ExternalService" + if out.PluralDisplayName == "" && out.IsPolicy { + out.PluralDisplayName = out.SingularDisplayName + "s" } switch { case r.Kds == nil || (!r.Kds.SendToZone && !r.Kds.SendToGlobal): diff --git a/tools/resource-gen/main.go b/tools/resource-gen/main.go index 5ef88054ee4e..3820921a60fe 100644 --- a/tools/resource-gen/main.go +++ b/tools/resource-gen/main.go @@ -302,7 +302,9 @@ var {{.ResourceName}}TypeDescriptor = model.ResourceTypeDescriptor{ KumactlListArg: "{{.KumactlPlural}}", AllowToInspect: {{.AllowToInspect}}, IsPolicy: {{.IsPolicy}}, - DisplayName: "{{.DisplayName}}", + SingularDisplayName: "{{.SingularDisplayName}}", + PluralDisplayName: "{{.PluralDisplayName}}", + IsExperimental: {{.IsExperimental}}, } {{- if not .SkipRegistration}} From b6fe36bd42c0bedcb4238f0318ca5026f6cb1246 Mon Sep 17 00:00:00 2001 From: Jakub Dyszkiewicz Date: Tue, 9 Aug 2022 12:59:15 +0200 Subject: [PATCH 2/3] chore: make check Signed-off-by: Jakub Dyszkiewicz --- api/mesh/options.pb.go | 3 +- api/mesh/options.proto | 3 +- docs/generated/resources/other_mesh.md | 242 ++++++++++++++++++------- 3 files changed, 180 insertions(+), 68 deletions(-) diff --git a/api/mesh/options.pb.go b/api/mesh/options.pb.go index 78f4c5c0b7a8..dc35688c1da3 100644 --- a/api/mesh/options.pb.go +++ b/api/mesh/options.pb.go @@ -50,7 +50,8 @@ type KumaResourceOptions struct { // The name of the policy showed as plural to be displayed in the UI and maybe // CLI PluralDisplayName string `protobuf:"bytes,15,opt,name=plural_display_name,json=pluralDisplayName,proto3" json:"plural_display_name,omitempty"` - // Is Experimental indicates if a policy is in experimental state (might not be production ready). + // Is Experimental indicates if a policy is in experimental state (might not + // be production ready). IsExperimental bool `protobuf:"varint,16,opt,name=is_experimental,json=isExperimental,proto3" json:"is_experimental,omitempty"` } diff --git a/api/mesh/options.proto b/api/mesh/options.proto index 6141070b513d..ccacab5080ff 100644 --- a/api/mesh/options.proto +++ b/api/mesh/options.proto @@ -42,7 +42,8 @@ message KumaResourceOptions { // CLI string plural_display_name = 15; - // Is Experimental indicates if a policy is in experimental state (might not be production ready). + // Is Experimental indicates if a policy is in experimental state (might not + // be production ready). bool is_experimental = 16; } diff --git a/docs/generated/resources/other_mesh.md b/docs/generated/resources/other_mesh.md index 97a146fd52b6..3244d72ab99e 100644 --- a/docs/generated/resources/other_mesh.md +++ b/docs/generated/resources/other_mesh.md @@ -3,47 +3,121 @@ - `mtls` (optional) mTLS settings. - +optional - - Child properties: + +optional - - `enabledbackend` (required) + - `enabledBackend` (required) Name of the enabled backend - `backends` (required, repeated) - List of available Certificate Authority backends + List of available Certificate Authority backends + + - `name` (required) + + Name of the backend + + - `type` (required) + + Type of the backend. Has to be one of the loaded plugins (Kuma ships with + builtin and provided) + + - `dpCert` (optional) + + Dataplane certificate settings + + - `rotation` (optional) + + Rotation settings + + - `expiration` (optional) + + Time after which generated certificate for Dataplane will expire + + - `requestTimeout` (optional) + + Timeout on request to CA for DP certificate generation and retrieval + + - `conf` (optional) + + Configuration of the backend + + - `mode` (optional, enum) + + Mode defines the behaviour of inbound listeners with regard to traffic + encryption + + - `STRICT` + + - `PERMISSIVE` + + - `rootChain` (optional) + + - `requestTimeout` (optional) + + Timeout on request for to CA for root certificate chain. - `tracing` (optional) Tracing settings. - +optional - - Child properties: + +optional - - `defaultbackend` (required) + - `defaultBackend` (required) Name of the default backend - `backends` (required, repeated) - List of available tracing backends + List of available tracing backends + + - `name` (required) + + Name of the backend, can be then used in Mesh.tracing.defaultBackend or in + TrafficTrace + + - `sampling` (optional) + + Percentage of traces that will be sent to the backend (range 0.0 - 100.0). + Empty value defaults to 100.0% + + - `type` (required) + + Type of the backend (Kuma ships with 'zipkin') + + - `conf` (required) + + Configuration of the backend - `logging` (optional) Logging settings. - +optional - - Child properties: + +optional - - `defaultbackend` (required) + - `defaultBackend` (required) Name of the default backend - `backends` (required, repeated) - List of available logging backends + List of available logging backends + + - `name` (required) + + Name of the backend, can be then used in Mesh.logging.defaultBackend or in + TrafficLogging + + - `format` (optional) + + Format of access logs. Placeholders available on + https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log + + - `type` (required) + + Type of the backend (Kuma ships with 'tcp' and 'file') + + - `conf` (required) + + Configuration of the backend - `metrics` (optional) @@ -52,29 +126,35 @@ Settings defined here become defaults for every dataplane in a given Mesh. Additionally, it is also possible to further customize this configuration for each dataplane individually using Dataplane resource. - +optional - - Child properties: + +optional - - `enabledbackend` (optional) + - `enabledBackend` (optional) Name of the enabled backend - `backends` (optional, repeated) - List of available Metrics backends + List of available Metrics backends + + - `name` (optional) + + Name of the backend, can be then used in Mesh.metrics.enabledBackend + + - `type` (optional) + + Type of the backend (Kuma ships with 'prometheus') + + - `conf` (optional) + + Configuration of the backend - `networking` (optional) - Networking settings of the mesh - - Child properties: + Networking settings of the mesh - `outbound` (optional) - Outbound settings - - Child properties: + Outbound settings - `passthrough` (optional) @@ -82,31 +162,25 @@ - `routing` (optional) - Routing settings of the mesh - - Child properties: + Routing settings of the mesh - - `localityawareloadbalancing` (optional) + - `localityAwareLoadBalancing` (optional) Enable the Locality Aware Load Balancing - - `zoneegress` (optional) + - `zoneEgress` (optional) Enable routing traffic to services in other zone or external services through ZoneEgress. Default: false - `constraints` (optional) - Constraints that applies to the mesh and its entities - - Child properties: + Constraints that applies to the mesh and its entities - - `dataplaneproxy` (required) + - `dataplaneProxy` (required) DataplaneProxyMembership defines a set of requirements for data plane - proxies to be a member of the mesh. - - Child properties: + proxies to be a member of the mesh. - `requirements` (optional, repeated) @@ -114,13 +188,23 @@ fulfill in order to join the mesh. A data plane proxy must fulfill at least one requirement in order to join the mesh. Empty list of allowed requirements means that any proxy that is not explicitly denied can join. + + - `tags` (required) + + Tags defines set of required tags. You can specify '*' in value to + require non empty value of tag - `restrictions` (optional, repeated) Restrictions defines a set of restrictions that data plane proxies cannot fulfill in order to join the mesh. A data plane proxy cannot fulfill any requirement in order to join the mesh. - Restrictions takes precedence over requirements. + Restrictions takes precedence over requirements. + + - `tags` (required) + + Tags defines set of required tags. You can specify '*' in value to + require non empty value of tag ## CertificateAuthorityBackend - `name` (required) @@ -132,23 +216,19 @@ Type of the backend. Has to be one of the loaded plugins (Kuma ships with builtin and provided) -- `dpcert` (optional) - - Dataplane certificate settings +- `dpCert` (optional) - Child properties: + Dataplane certificate settings - `rotation` (optional) - Rotation settings - - Child properties: + Rotation settings - `expiration` (optional) Time after which generated certificate for Dataplane will expire - - `requesttimeout` (optional) + - `requestTimeout` (optional) Timeout on request to CA for DP certificate generation and retrieval @@ -156,44 +236,56 @@ Configuration of the backend -- `mode` (optional) +- `mode` (optional, enum) Mode defines the behaviour of inbound listeners with regard to traffic encryption - Supported values: - - `STRICT` - `PERMISSIVE` -- `rootchain` (optional) - - Child properties: +- `rootChain` (optional) - - `requesttimeout` (optional) + - `requestTimeout` (optional) Timeout on request for to CA for root certificate chain. ## Networking - `outbound` (optional) - Outbound settings - - Child properties: + Outbound settings - `passthrough` (optional) Control the passthrough cluster ## Tracing -- `defaultbackend` (required) +- `defaultBackend` (required) Name of the default backend - `backends` (required, repeated) - List of available tracing backends + List of available tracing backends + + - `name` (required) + + Name of the backend, can be then used in Mesh.tracing.defaultBackend or in + TrafficTrace + + - `sampling` (optional) + + Percentage of traces that will be sent to the backend (range 0.0 - 100.0). + Empty value defaults to 100.0% + + - `type` (required) + + Type of the backend (Kuma ships with 'zipkin') + + - `conf` (required) + + Configuration of the backend ## TracingBackend - `name` (required) @@ -228,30 +320,48 @@ Address of Zipkin collector. -- `traceid128bit` (optional) +- `traceId128bit` (optional) Generate 128bit traces. Default: false -- `apiversion` (required) +- `apiVersion` (required) Version of the API. values: httpJson, httpJsonV1, httpProto. Default: httpJson see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/trace/v3/trace.proto#envoy-v3-api-enum-config-trace-v3-zipkinconfig-collectorendpointversion -- `sharedspancontext` (optional) +- `sharedSpanContext` (optional) Determines whether client and server spans will share the same span context. Default: true. https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/trace/v3/zipkin.proto#config-trace-v3-zipkinconfig ## Logging -- `defaultbackend` (required) +- `defaultBackend` (required) Name of the default backend - `backends` (required, repeated) - List of available logging backends + List of available logging backends + + - `name` (required) + + Name of the backend, can be then used in Mesh.logging.defaultBackend or in + TrafficLogging + + - `format` (optional) + + Format of access logs. Placeholders available on + https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log + + - `type` (required) + + Type of the backend (Kuma ships with 'tcp' and 'file') + + - `conf` (required) + + Configuration of the backend ## LoggingBackend - `name` (required) @@ -283,11 +393,11 @@ Address to TCP service that will receive logs ## Routing -- `localityawareloadbalancing` (optional) +- `localityAwareLoadBalancing` (optional) Enable the Locality Aware Load Balancing -- `zoneegress` (optional) +- `zoneEgress` (optional) Enable routing traffic to services in other zone or external services through ZoneEgress. Default: false From 9fccef6016eb4922cfc786cb8e2c16867f05129e Mon Sep 17 00:00:00 2001 From: Jakub Dyszkiewicz Date: Wed, 10 Aug 2022 10:16:54 +0200 Subject: [PATCH 3/3] chore(tools): generalize plural name util Signed-off-by: Jakub Dyszkiewicz --- api/mesh/v1alpha1/retry.pb.go | 51 +++++++++---------- api/mesh/v1alpha1/retry.proto | 1 - .../apis/mesh/zz_generated.resources.go | 28 +++++----- .../apis/system/zz_generated.resources.go | 10 ++-- pkg/core/resources/model/display_name.go | 34 +++++++++++++ .../policy-gen/protoc-gen-kumapolicy/utils.go | 25 ++------- tools/resource-gen/genutils/util.go | 13 ++--- 7 files changed, 86 insertions(+), 76 deletions(-) create mode 100644 pkg/core/resources/model/display_name.go diff --git a/api/mesh/v1alpha1/retry.pb.go b/api/mesh/v1alpha1/retry.pb.go index b1920cb03c29..cf2f2e3a17f5 100644 --- a/api/mesh/v1alpha1/retry.pb.go +++ b/api/mesh/v1alpha1/retry.pb.go @@ -572,7 +572,7 @@ var file_mesh_v1alpha1_retry_proto_rawDesc = []byte{ 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcd, 0x0b, 0x0a, 0x05, 0x52, 0x65, + 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x0b, 0x0a, 0x05, 0x52, 0x65, 0x74, 0x72, 0x79, 0x12, 0x44, 0x0a, 0x07, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6b, 0x75, 0x6d, 0x61, 0x2e, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, @@ -658,33 +658,32 @@ var file_mesh_v1alpha1_retry_proto_rawDesc = []byte{ 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x10, 0x02, 0x12, 0x16, 0x0a, 0x12, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x65, 0x78, 0x68, 0x61, 0x75, 0x73, 0x74, 0x65, 0x64, 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x75, 0x6e, 0x61, 0x76, 0x61, - 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x10, 0x04, 0x3a, 0x6f, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x0f, + 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x10, 0x04, 0x3a, 0x60, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x0f, 0x0a, 0x0d, 0x52, 0x65, 0x74, 0x72, 0x79, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x07, 0x12, 0x05, 0x52, 0x65, 0x74, 0x72, 0x79, 0xaa, 0x8c, 0x89, 0xa6, - 0x01, 0x09, 0x7a, 0x07, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x73, 0xaa, 0x8c, 0x89, 0xa6, 0x01, - 0x06, 0x22, 0x04, 0x6d, 0x65, 0x73, 0x68, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x04, 0x52, 0x02, 0x10, - 0x01, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x09, 0x3a, 0x07, 0x0a, 0x05, 0x72, 0x65, 0x74, 0x72, 0x79, - 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x0b, 0x3a, 0x09, 0x12, 0x07, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, - 0x73, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x02, 0x68, 0x01, 0x2a, 0xde, 0x01, 0x0a, 0x0b, 0x48, 0x74, - 0x74, 0x70, 0x52, 0x65, 0x74, 0x72, 0x79, 0x4f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x61, 0x6c, 0x6c, - 0x5f, 0x35, 0x78, 0x78, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, - 0x79, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x72, 0x65, 0x73, - 0x65, 0x74, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, - 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x65, 0x6e, 0x76, - 0x6f, 0x79, 0x5f, 0x72, 0x61, 0x74, 0x65, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x65, 0x64, 0x10, 0x04, - 0x12, 0x11, 0x0a, 0x0d, 0x72, 0x65, 0x74, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x34, 0x78, - 0x78, 0x10, 0x05, 0x12, 0x12, 0x0a, 0x0e, 0x72, 0x65, 0x66, 0x75, 0x73, 0x65, 0x64, 0x5f, 0x73, - 0x74, 0x72, 0x65, 0x61, 0x6d, 0x10, 0x06, 0x12, 0x1a, 0x0a, 0x16, 0x72, 0x65, 0x74, 0x72, 0x69, - 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, - 0x73, 0x10, 0x07, 0x12, 0x15, 0x0a, 0x11, 0x72, 0x65, 0x74, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, - 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x10, 0x08, 0x12, 0x1e, 0x0a, 0x1a, 0x68, 0x74, - 0x74, 0x70, 0x33, 0x5f, 0x70, 0x6f, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0x09, 0x42, 0x40, 0x5a, 0x28, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x6d, 0x61, 0x68, 0x71, 0x2f, - 0x6b, 0x75, 0x6d, 0x61, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x8a, 0xb5, 0x18, 0x12, 0x50, 0x01, 0xa2, 0x01, 0x05, 0x52, - 0x65, 0x74, 0x72, 0x79, 0xf2, 0x01, 0x05, 0x72, 0x65, 0x74, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x06, 0x22, 0x04, 0x6d, 0x65, 0x73, 0x68, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x04, 0x52, 0x02, + 0x10, 0x01, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x09, 0x3a, 0x07, 0x0a, 0x05, 0x72, 0x65, 0x74, 0x72, + 0x79, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x0b, 0x3a, 0x09, 0x12, 0x07, 0x72, 0x65, 0x74, 0x72, 0x69, + 0x65, 0x73, 0xaa, 0x8c, 0x89, 0xa6, 0x01, 0x02, 0x68, 0x01, 0x2a, 0xde, 0x01, 0x0a, 0x0b, 0x48, + 0x74, 0x74, 0x70, 0x52, 0x65, 0x74, 0x72, 0x79, 0x4f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x61, 0x6c, + 0x6c, 0x5f, 0x35, 0x78, 0x78, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x67, 0x61, 0x74, 0x65, 0x77, + 0x61, 0x79, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x72, 0x65, + 0x73, 0x65, 0x74, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, + 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x65, 0x6e, + 0x76, 0x6f, 0x79, 0x5f, 0x72, 0x61, 0x74, 0x65, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x65, 0x64, 0x10, + 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x72, 0x65, 0x74, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x34, + 0x78, 0x78, 0x10, 0x05, 0x12, 0x12, 0x0a, 0x0e, 0x72, 0x65, 0x66, 0x75, 0x73, 0x65, 0x64, 0x5f, + 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x10, 0x06, 0x12, 0x1a, 0x0a, 0x16, 0x72, 0x65, 0x74, 0x72, + 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, + 0x65, 0x73, 0x10, 0x07, 0x12, 0x15, 0x0a, 0x11, 0x72, 0x65, 0x74, 0x72, 0x69, 0x61, 0x62, 0x6c, + 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x10, 0x08, 0x12, 0x1e, 0x0a, 0x1a, 0x68, + 0x74, 0x74, 0x70, 0x33, 0x5f, 0x70, 0x6f, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, + 0x74, 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0x09, 0x42, 0x40, 0x5a, 0x28, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x6d, 0x61, 0x68, 0x71, + 0x2f, 0x6b, 0x75, 0x6d, 0x61, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x8a, 0xb5, 0x18, 0x12, 0x50, 0x01, 0xa2, 0x01, 0x05, + 0x52, 0x65, 0x74, 0x72, 0x79, 0xf2, 0x01, 0x05, 0x72, 0x65, 0x74, 0x72, 0x79, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/mesh/v1alpha1/retry.proto b/api/mesh/v1alpha1/retry.proto index fad860382bdf..c5880b0471f8 100644 --- a/api/mesh/v1alpha1/retry.proto +++ b/api/mesh/v1alpha1/retry.proto @@ -38,7 +38,6 @@ message Retry { option (kuma.mesh.resource).name = "RetryResource"; option (kuma.mesh.resource).type = "Retry"; - option (kuma.mesh.resource).plural_display_name = "Retries"; option (kuma.mesh.resource).package = "mesh"; option (kuma.mesh.resource).kds.send_to_zone = true; option (kuma.mesh.resource).ws.name = "retry"; diff --git a/pkg/core/resources/apis/mesh/zz_generated.resources.go b/pkg/core/resources/apis/mesh/zz_generated.resources.go index d3885f3dea3d..146518fa4d48 100644 --- a/pkg/core/resources/apis/mesh/zz_generated.resources.go +++ b/pkg/core/resources/apis/mesh/zz_generated.resources.go @@ -222,7 +222,7 @@ var DataplaneResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Dataplane", - PluralDisplayName: "", + PluralDisplayName: "Dataplanes", IsExperimental: false, } @@ -327,7 +327,7 @@ var DataplaneInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Dataplane Insight", - PluralDisplayName: "", + PluralDisplayName: "Dataplane Insights", IsExperimental: false, } @@ -431,7 +431,7 @@ var DataplaneOverviewResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Dataplane Overview", - PluralDisplayName: "", + PluralDisplayName: "Dataplane Overviews", IsExperimental: false, } @@ -532,7 +532,7 @@ var ExternalServiceResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "External Service", - PluralDisplayName: "", + PluralDisplayName: "External Services", IsExperimental: false, } @@ -863,7 +863,7 @@ var MeshResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Mesh", - PluralDisplayName: "", + PluralDisplayName: "Meshes", IsExperimental: false, } @@ -1185,7 +1185,7 @@ var MeshInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Mesh Insight", - PluralDisplayName: "", + PluralDisplayName: "Mesh Insights", IsExperimental: false, } @@ -1625,7 +1625,7 @@ var ServiceInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Service Insight", - PluralDisplayName: "", + PluralDisplayName: "Service Insights", IsExperimental: false, } @@ -1729,7 +1729,7 @@ var ServiceOverviewResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Service Overview", - PluralDisplayName: "", + PluralDisplayName: "Service Overviews", IsExperimental: false, } @@ -2500,7 +2500,7 @@ var ZoneEgressResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Zone Egress", - PluralDisplayName: "", + PluralDisplayName: "Zone Egresses", IsExperimental: false, } @@ -2605,7 +2605,7 @@ var ZoneEgressInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Zone Egress Insight", - PluralDisplayName: "", + PluralDisplayName: "Zone Egress Insights", IsExperimental: false, } @@ -2709,7 +2709,7 @@ var ZoneEgressOverviewResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Zone Egress Overview", - PluralDisplayName: "", + PluralDisplayName: "Zone Egress Overviews", IsExperimental: false, } @@ -2810,7 +2810,7 @@ var ZoneIngressResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Zone Ingress", - PluralDisplayName: "", + PluralDisplayName: "Zone Ingresses", IsExperimental: false, } @@ -2915,7 +2915,7 @@ var ZoneIngressInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Zone Ingress Insight", - PluralDisplayName: "", + PluralDisplayName: "Zone Ingress Insights", IsExperimental: false, } @@ -3019,6 +3019,6 @@ var ZoneIngressOverviewResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Zone Ingress Overview", - PluralDisplayName: "", + PluralDisplayName: "Zone Ingress Overviews", IsExperimental: false, } diff --git a/pkg/core/resources/apis/system/zz_generated.resources.go b/pkg/core/resources/apis/system/zz_generated.resources.go index 1ac7d7cb47b9..1f8c35c520a3 100644 --- a/pkg/core/resources/apis/system/zz_generated.resources.go +++ b/pkg/core/resources/apis/system/zz_generated.resources.go @@ -109,7 +109,7 @@ var ConfigResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Config", - PluralDisplayName: "", + PluralDisplayName: "Configs", IsExperimental: false, } @@ -214,7 +214,7 @@ var SecretResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Secret", - PluralDisplayName: "", + PluralDisplayName: "Secrets", IsExperimental: false, } @@ -318,7 +318,7 @@ var ZoneResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Zone", - PluralDisplayName: "", + PluralDisplayName: "Zones", IsExperimental: false, } @@ -422,7 +422,7 @@ var ZoneInsightResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Zone Insight", - PluralDisplayName: "", + PluralDisplayName: "Zone Insights", IsExperimental: false, } @@ -526,6 +526,6 @@ var ZoneOverviewResourceTypeDescriptor = model.ResourceTypeDescriptor{ AllowToInspect: false, IsPolicy: false, SingularDisplayName: "Zone Overview", - PluralDisplayName: "", + PluralDisplayName: "Zone Overviews", IsExperimental: false, } diff --git a/pkg/core/resources/model/display_name.go b/pkg/core/resources/model/display_name.go new file mode 100644 index 000000000000..f3d71ff2e79e --- /dev/null +++ b/pkg/core/resources/model/display_name.go @@ -0,0 +1,34 @@ +package model + +import ( + "strings" + "unicode" +) + +func DisplayName(resType string) string { + displayName := "" + for i, c := range resType { + if unicode.IsUpper(c) && i != 0 { + displayName += " " + } + displayName += string(c) + } + return displayName +} + +func PluralType(resType string) string { + switch { + case strings.HasSuffix(resType, "ay"): + return resType + "s" + case strings.HasSuffix(resType, "y"): + return strings.TrimSuffix(resType, "y") + "ies" + case strings.HasSuffix(resType, "s"), strings.HasSuffix(resType, "sh"): + return resType + "es" + default: + return resType + "s" + } +} + +func PluralDisplayName(resType string) string { + return DisplayName(PluralType(resType)) +} diff --git a/tools/policy-gen/protoc-gen-kumapolicy/utils.go b/tools/policy-gen/protoc-gen-kumapolicy/utils.go index 23ba84d7d69f..487f92442d30 100644 --- a/tools/policy-gen/protoc-gen-kumapolicy/utils.go +++ b/tools/policy-gen/protoc-gen-kumapolicy/utils.go @@ -2,12 +2,12 @@ package main import ( "strings" - "unicode" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" "github.com/kumahq/kuma/api/mesh" + core_model "github.com/kumahq/kuma/pkg/core/resources/model" ) type PolicyConfig struct { @@ -32,27 +32,10 @@ func NewPolicyConfig(desc protoreflect.MessageDescriptor) PolicyConfig { Plural: resOption.Plural, } if resOption.Plural == "" { - switch { - case strings.HasSuffix(res.Name, "y"): - res.Plural = strings.TrimSuffix(res.Name, "y") + "ies" - case strings.HasSuffix(res.Name, "s"): - res.Plural = res.Name + "es" - default: - res.Plural = res.Name + "s" - } - } - for i, c := range res.Name { - if unicode.IsUpper(c) && i != 0 { - res.SingularDisplayName += " " - } - res.SingularDisplayName += string(c) - } - for i, c := range res.Plural { - if unicode.IsUpper(c) && i != 0 { - res.PluralDisplayName += " " - } - res.PluralDisplayName += string(c) + res.Plural = core_model.PluralType(res.Name) } + res.SingularDisplayName = core_model.DisplayName(res.Name) + res.PluralDisplayName = core_model.PluralDisplayName(res.Name) res.Path = strings.ToLower(res.Plural) res.AlternativeNames = []string{strings.ToLower(res.Name)} return res diff --git a/tools/resource-gen/genutils/util.go b/tools/resource-gen/genutils/util.go index 8bb281eab035..22c5b14067f4 100644 --- a/tools/resource-gen/genutils/util.go +++ b/tools/resource-gen/genutils/util.go @@ -3,12 +3,12 @@ package genutils import ( "fmt" "strings" - "unicode" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" "github.com/kumahq/kuma/api/mesh" + core_model "github.com/kumahq/kuma/pkg/core/resources/model" ) // KumaResourceForMessage fetches the Kuma resource option out of a message. @@ -77,6 +77,7 @@ func ToResourceInfo(desc protoreflect.MessageDescriptor) ResourceInfo { ScopeNamespace: r.ScopeNamespace, AllowToInspect: r.AllowToInspect, StorageVersion: r.StorageVersion, + SingularDisplayName: core_model.DisplayName(r.Type), PluralDisplayName: r.PluralDisplayName, IsExperimental: r.IsExperimental, } @@ -98,18 +99,12 @@ func ToResourceInfo(desc protoreflect.MessageDescriptor) ResourceInfo { } } } - for i, c := range out.ResourceType { - if unicode.IsUpper(c) && i != 0 { - out.SingularDisplayName += " " - } - out.SingularDisplayName += string(c) + if out.PluralDisplayName == "" { + out.PluralDisplayName = core_model.PluralDisplayName(r.Type) } // Working around the fact we don't really differentiate policies from the rest of resources: // Anything global can't be a policy as it need to be on a mesh. Anything with locked Ws config is something internal and therefore not a policy out.IsPolicy = !out.SkipRegistration && !out.Global && !out.WsAdminOnly && !out.WsReadOnly && out.ResourceType != "Dataplane" && out.ResourceType != "ExternalService" - if out.PluralDisplayName == "" && out.IsPolicy { - out.PluralDisplayName = out.SingularDisplayName + "s" - } switch { case r.Kds == nil || (!r.Kds.SendToZone && !r.Kds.SendToGlobal): out.KdsDirection = ""