From 02ac82fa8f74cb11f87294c398251eb00c989204 Mon Sep 17 00:00:00 2001 From: Nikolaos Stamatopoulos Date: Fri, 8 Sep 2023 12:36:04 +0300 Subject: [PATCH 1/2] feat: Allow policy to apply to specific queue types (classic/quorum) As of RabbitMQ v3.12.0, policies can be defined to only apply to specific queue types. This commit allows setting those types on the applyTo field of a Policy. --- api/v1beta1/policy_types.go | 4 ++-- api/v1beta1/policy_types_test.go | 2 +- config/crd/bases/rabbitmq.com_policies.yaml | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api/v1beta1/policy_types.go b/api/v1beta1/policy_types.go index 43f53ee3..a1209fe8 100644 --- a/api/v1beta1/policy_types.go +++ b/api/v1beta1/policy_types.go @@ -19,9 +19,9 @@ type PolicySpec struct { // Required property. // +kubebuilder:validation:Required Pattern string `json:"pattern"` - // What this policy applies to: 'queues', 'exchanges', or 'all'. + // What this policy applies to: 'queues', 'classic_queues', 'quorum_queues', 'exchanges', or 'all'. // Default to 'all'. - // +kubebuilder:validation:Enum=queues;exchanges;all + // +kubebuilder:validation:Enum=queues;classic_queues;quorum_queues;exchanges;all // +kubebuilder:default:=all ApplyTo string `json:"applyTo,omitempty"` // Default to '0'. diff --git a/api/v1beta1/policy_types_test.go b/api/v1beta1/policy_types_test.go index bb06de3f..4bdd3918 100644 --- a/api/v1beta1/policy_types_test.go +++ b/api/v1beta1/policy_types_test.go @@ -109,7 +109,7 @@ var _ = Describe("Policy", func() { }, } Expect(k8sClient.Create(ctx, &policy)).To(HaveOccurred()) - Expect(k8sClient.Create(ctx, &policy)).To(MatchError(`Policy.rabbitmq.com "invalid" is invalid: spec.applyTo: Unsupported value: "yo-yo": supported values: "queues", "exchanges", "all"`)) + Expect(k8sClient.Create(ctx, &policy)).To(MatchError(`Policy.rabbitmq.com "invalid" is invalid: spec.applyTo: Unsupported value: "yo-yo": supported values: "queues", "classic_queues", "quorum_queues", "exchanges", "all"`)) }) }) diff --git a/config/crd/bases/rabbitmq.com_policies.yaml b/config/crd/bases/rabbitmq.com_policies.yaml index aa39d783..c815eaa7 100644 --- a/config/crd/bases/rabbitmq.com_policies.yaml +++ b/config/crd/bases/rabbitmq.com_policies.yaml @@ -39,10 +39,12 @@ spec: properties: applyTo: default: all - description: 'What this policy applies to: ''queues'', ''exchanges'', - or ''all''. Default to ''all''.' + description: 'What this policy applies to: ''queues'', ''classic_queues'', + ''quorum_queues'', ''exchanges'', or ''all''. Default to ''all''.' enum: - queues + - classic_queues + - quorum_queues - exchanges - all type: string From f1e978048222e3c97a23d0ab7d285842d4fca633 Mon Sep 17 00:00:00 2001 From: Nikolaos Stamatopoulos Date: Mon, 11 Sep 2023 12:32:58 +0300 Subject: [PATCH 2/2] feat: Allow policy to apply to streams --- api/v1beta1/policy_types.go | 4 ++-- api/v1beta1/policy_types_test.go | 2 +- config/crd/bases/rabbitmq.com_policies.yaml | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/v1beta1/policy_types.go b/api/v1beta1/policy_types.go index a1209fe8..d1189ad3 100644 --- a/api/v1beta1/policy_types.go +++ b/api/v1beta1/policy_types.go @@ -19,9 +19,9 @@ type PolicySpec struct { // Required property. // +kubebuilder:validation:Required Pattern string `json:"pattern"` - // What this policy applies to: 'queues', 'classic_queues', 'quorum_queues', 'exchanges', or 'all'. + // What this policy applies to: 'queues', 'classic_queues', 'quorum_queues', 'streams', 'exchanges', or 'all'. // Default to 'all'. - // +kubebuilder:validation:Enum=queues;classic_queues;quorum_queues;exchanges;all + // +kubebuilder:validation:Enum=queues;classic_queues;quorum_queues;streams;exchanges;all // +kubebuilder:default:=all ApplyTo string `json:"applyTo,omitempty"` // Default to '0'. diff --git a/api/v1beta1/policy_types_test.go b/api/v1beta1/policy_types_test.go index 4bdd3918..370355e7 100644 --- a/api/v1beta1/policy_types_test.go +++ b/api/v1beta1/policy_types_test.go @@ -109,7 +109,7 @@ var _ = Describe("Policy", func() { }, } Expect(k8sClient.Create(ctx, &policy)).To(HaveOccurred()) - Expect(k8sClient.Create(ctx, &policy)).To(MatchError(`Policy.rabbitmq.com "invalid" is invalid: spec.applyTo: Unsupported value: "yo-yo": supported values: "queues", "classic_queues", "quorum_queues", "exchanges", "all"`)) + Expect(k8sClient.Create(ctx, &policy)).To(MatchError(`Policy.rabbitmq.com "invalid" is invalid: spec.applyTo: Unsupported value: "yo-yo": supported values: "queues", "classic_queues", "quorum_queues", "streams", "exchanges", "all"`)) }) }) diff --git a/config/crd/bases/rabbitmq.com_policies.yaml b/config/crd/bases/rabbitmq.com_policies.yaml index c815eaa7..1816fe41 100644 --- a/config/crd/bases/rabbitmq.com_policies.yaml +++ b/config/crd/bases/rabbitmq.com_policies.yaml @@ -40,11 +40,13 @@ spec: applyTo: default: all description: 'What this policy applies to: ''queues'', ''classic_queues'', - ''quorum_queues'', ''exchanges'', or ''all''. Default to ''all''.' + ''quorum_queues'', ''streams'', ''exchanges'', or ''all''. Default + to ''all''.' enum: - queues - classic_queues - quorum_queues + - streams - exchanges - all type: string