diff --git a/api/v1alpha1/conversion_hub.go b/api/v1alpha1/conversion_hub.go index edf00d7e..f9d46c05 100644 --- a/api/v1alpha1/conversion_hub.go +++ b/api/v1alpha1/conversion_hub.go @@ -29,33 +29,40 @@ const ( ownerUsersAnnotation = "owners.capsule.clastix.io/user" ownerServiceAccountAnnotation = "owners.capsule.clastix.io/serviceaccount" - enableNodeListingAnnotation = "capsule.clastix.io/enable-node-listing" - enableNodeUpdateAnnotation = "capsule.clastix.io/enable-node-update" - enableNodeDeletionAnnotation = "capsule.clastix.io/enable-node-deletion" - enableStorageClassListingAnnotation = "capsule.clastix.io/enable-storageclass-listing" - enableStorageClassUpdateAnnotation = "capsule.clastix.io/enable-storageclass-update" - enableStorageClassDeletionAnnotation = "capsule.clastix.io/enable-storageclass-deletion" - enableIngressClassListingAnnotation = "capsule.clastix.io/enable-ingressclass-listing" - enableIngressClassUpdateAnnotation = "capsule.clastix.io/enable-ingressclass-update" - enableIngressClassDeletionAnnotation = "capsule.clastix.io/enable-ingressclass-deletion" + enableNodeListingAnnotation = "capsule.clastix.io/enable-node-listing" + enableNodeUpdateAnnotation = "capsule.clastix.io/enable-node-update" + enableNodeDeletionAnnotation = "capsule.clastix.io/enable-node-deletion" + enableStorageClassListingAnnotation = "capsule.clastix.io/enable-storageclass-listing" + enableStorageClassUpdateAnnotation = "capsule.clastix.io/enable-storageclass-update" + enableStorageClassDeletionAnnotation = "capsule.clastix.io/enable-storageclass-deletion" + enableIngressClassListingAnnotation = "capsule.clastix.io/enable-ingressclass-listing" + enableIngressClassUpdateAnnotation = "capsule.clastix.io/enable-ingressclass-update" + enableIngressClassDeletionAnnotation = "capsule.clastix.io/enable-ingressclass-deletion" + enablePriorityClassListingAnnotation = "capsule.clastix.io/enable-priorityclass-listing" + enablePriorityClassUpdateAnnotation = "capsule.clastix.io/enable-priorityclass-update" + enablePriorityClassDeletionAnnotation = "capsule.clastix.io/enable-priorityclass-deletion" ) func (t *Tenant) convertV1Alpha1OwnerToV1Beta1() capsulev1beta1.OwnerListSpec { var serviceKindToAnnotationMap = map[capsulev1beta1.ProxyServiceKind][]string{ - capsulev1beta1.NodesProxy: {enableNodeListingAnnotation, enableNodeUpdateAnnotation, enableNodeDeletionAnnotation}, - capsulev1beta1.StorageClassesProxy: {enableStorageClassListingAnnotation, enableStorageClassUpdateAnnotation, enableStorageClassDeletionAnnotation}, - capsulev1beta1.IngressClassesProxy: {enableIngressClassListingAnnotation, enableIngressClassUpdateAnnotation, enableIngressClassDeletionAnnotation}, + capsulev1beta1.NodesProxy: {enableNodeListingAnnotation, enableNodeUpdateAnnotation, enableNodeDeletionAnnotation}, + capsulev1beta1.StorageClassesProxy: {enableStorageClassListingAnnotation, enableStorageClassUpdateAnnotation, enableStorageClassDeletionAnnotation}, + capsulev1beta1.IngressClassesProxy: {enableIngressClassListingAnnotation, enableIngressClassUpdateAnnotation, enableIngressClassDeletionAnnotation}, + capsulev1beta1.PriorityClassesProxy: {enablePriorityClassListingAnnotation, enablePriorityClassUpdateAnnotation, enablePriorityClassDeletionAnnotation}, } var annotationToOperationMap = map[string]capsulev1beta1.ProxyOperation{ - enableNodeListingAnnotation: capsulev1beta1.ListOperation, - enableNodeUpdateAnnotation: capsulev1beta1.UpdateOperation, - enableNodeDeletionAnnotation: capsulev1beta1.DeleteOperation, - enableStorageClassListingAnnotation: capsulev1beta1.ListOperation, - enableStorageClassUpdateAnnotation: capsulev1beta1.UpdateOperation, - enableStorageClassDeletionAnnotation: capsulev1beta1.DeleteOperation, - enableIngressClassListingAnnotation: capsulev1beta1.ListOperation, - enableIngressClassUpdateAnnotation: capsulev1beta1.UpdateOperation, - enableIngressClassDeletionAnnotation: capsulev1beta1.DeleteOperation, + enableNodeListingAnnotation: capsulev1beta1.ListOperation, + enableNodeUpdateAnnotation: capsulev1beta1.UpdateOperation, + enableNodeDeletionAnnotation: capsulev1beta1.DeleteOperation, + enableStorageClassListingAnnotation: capsulev1beta1.ListOperation, + enableStorageClassUpdateAnnotation: capsulev1beta1.UpdateOperation, + enableStorageClassDeletionAnnotation: capsulev1beta1.DeleteOperation, + enableIngressClassListingAnnotation: capsulev1beta1.ListOperation, + enableIngressClassUpdateAnnotation: capsulev1beta1.UpdateOperation, + enableIngressClassDeletionAnnotation: capsulev1beta1.DeleteOperation, + enablePriorityClassListingAnnotation: capsulev1beta1.ListOperation, + enablePriorityClassUpdateAnnotation: capsulev1beta1.UpdateOperation, + enablePriorityClassDeletionAnnotation: capsulev1beta1.DeleteOperation, } var annotationToOwnerKindMap = map[string]capsulev1beta1.OwnerKind{ ownerUsersAnnotation: capsulev1beta1.UserOwner, @@ -279,6 +286,9 @@ func (t *Tenant) ConvertTo(dstRaw conversion.Hub) error { delete(dst.ObjectMeta.Annotations, enableIngressClassListingAnnotation) delete(dst.ObjectMeta.Annotations, enableIngressClassUpdateAnnotation) delete(dst.ObjectMeta.Annotations, enableIngressClassDeletionAnnotation) + delete(dst.ObjectMeta.Annotations, enablePriorityClassListingAnnotation) + delete(dst.ObjectMeta.Annotations, enablePriorityClassUpdateAnnotation) + delete(dst.ObjectMeta.Annotations, enablePriorityClassDeletionAnnotation) return nil } @@ -331,6 +341,17 @@ func (t *Tenant) convertV1Beta1OwnerToV1Alpha1(src *capsulev1beta1.Tenant) { proxyAnnotations[enableNodeDeletionAnnotation] = append(proxyAnnotations[enableNodeDeletionAnnotation], owner.Name) } } + case capsulev1beta1.PriorityClassesProxy: + for _, operation := range setting.Operations { + switch operation { + case capsulev1beta1.ListOperation: + proxyAnnotations[enablePriorityClassListingAnnotation] = append(proxyAnnotations[enablePriorityClassListingAnnotation], owner.Name) + case capsulev1beta1.UpdateOperation: + proxyAnnotations[enablePriorityClassUpdateAnnotation] = append(proxyAnnotations[enablePriorityClassUpdateAnnotation], owner.Name) + case capsulev1beta1.DeleteOperation: + proxyAnnotations[enablePriorityClassDeletionAnnotation] = append(proxyAnnotations[enablePriorityClassDeletionAnnotation], owner.Name) + } + } case capsulev1beta1.StorageClassesProxy: for _, operation := range setting.Operations { switch operation { diff --git a/api/v1alpha1/conversion_hub_test.go b/api/v1alpha1/conversion_hub_test.go index 581685f7..98b30e20 100644 --- a/api/v1alpha1/conversion_hub_test.go +++ b/api/v1alpha1/conversion_hub_test.go @@ -171,6 +171,10 @@ func generateTenantsSpecs() (Tenant, capsulev1beta1.Tenant) { Kind: "StorageClasses", Operations: []capsulev1beta1.ProxyOperation{"List"}, }, + { + Kind: "PriorityClasses", + Operations: []capsulev1beta1.ProxyOperation{"List"}, + }, }, }, { @@ -287,6 +291,7 @@ func generateTenantsSpecs() (Tenant, capsulev1beta1.Tenant) { enableIngressClassListingAnnotation: "alice,owner-foo,owner-bar", enableIngressClassUpdateAnnotation: "alice,bob", enableIngressClassDeletionAnnotation: "alice,jack", + enablePriorityClassListingAnnotation: "jack", }, }, Spec: TenantSpec{ diff --git a/api/v1beta1/owner.go b/api/v1beta1/owner.go index 7e63cafc..22894a78 100644 --- a/api/v1beta1/owner.go +++ b/api/v1beta1/owner.go @@ -31,7 +31,7 @@ func (p ProxyOperation) String() string { return string(p) } -// +kubebuilder:validation:Enum=Nodes;StorageClasses;IngressClasses +// +kubebuilder:validation:Enum=Nodes;StorageClasses;IngressClasses;PriorityClasses type ProxyServiceKind string func (p ProxyServiceKind) String() string { @@ -39,9 +39,10 @@ func (p ProxyServiceKind) String() string { } const ( - NodesProxy ProxyServiceKind = "Nodes" - StorageClassesProxy ProxyServiceKind = "StorageClasses" - IngressClassesProxy ProxyServiceKind = "IngressClasses" + NodesProxy ProxyServiceKind = "Nodes" + StorageClassesProxy ProxyServiceKind = "StorageClasses" + IngressClassesProxy ProxyServiceKind = "IngressClasses" + PriorityClassesProxy ProxyServiceKind = "PriorityClasses" ListOperation ProxyOperation = "List" UpdateOperation ProxyOperation = "Update" diff --git a/charts/capsule/crds/tenant-crd.yaml b/charts/capsule/crds/tenant-crd.yaml index 150aa32f..0817f859 100644 --- a/charts/capsule/crds/tenant-crd.yaml +++ b/charts/capsule/crds/tenant-crd.yaml @@ -1058,6 +1058,7 @@ spec: - Nodes - StorageClasses - IngressClasses + - PriorityClasses type: string operations: items: diff --git a/config/crd/bases/capsule.clastix.io_tenants.yaml b/config/crd/bases/capsule.clastix.io_tenants.yaml index 609b9bc2..393f0322 100644 --- a/config/crd/bases/capsule.clastix.io_tenants.yaml +++ b/config/crd/bases/capsule.clastix.io_tenants.yaml @@ -1058,6 +1058,7 @@ spec: - Nodes - StorageClasses - IngressClasses + - PriorityClasses type: string operations: items: diff --git a/config/install.yaml b/config/install.yaml index 7f473042..8a1cd575 100644 --- a/config/install.yaml +++ b/config/install.yaml @@ -1137,6 +1137,7 @@ spec: - Nodes - StorageClasses - IngressClasses + - PriorityClasses type: string operations: items: