From b8b67df1e715e0b1d7a6bb034e6a1f37b9b8ba3c Mon Sep 17 00:00:00 2001 From: David Ansari Date: Mon, 29 Jan 2024 10:48:36 +0100 Subject: [PATCH] Support RabbitMQ operator policies (#752) * Bump Golang Use Golang 1.21 locally on the dev machine and bump Golang to 1.21 in Dockerfile make manifests * Support RabbitMQ operator policies Closes #202 * Add workaround for Go 1.21 since codeql does not (yet) support Go 1.21, see https://github.com/github/codeql-action/issues/1842 * Fix test flake * Add missing test * Apply feedback --- .github/workflows/build-test-publish.yml | 2 +- .github/workflows/codeql-analysis.yml | 7 + .github/workflows/pr.yml | 2 +- Dockerfile | 2 +- api/v1beta1/operatorpolicy_types.go | 90 +++ api/v1beta1/operatorpolicy_types_test.go | 117 ++++ api/v1beta1/operatorpolicy_webhook.go | 57 ++ api/v1beta1/operatorpolicy_webhook_test.go | 112 ++++ api/v1beta1/policy_types.go | 2 +- api/v1beta1/zz_generated.deepcopy.go | 102 ++++ config/crd/bases/rabbitmq.com_bindings.yaml | 52 +- config/crd/bases/rabbitmq.com_exchanges.yaml | 52 +- .../crd/bases/rabbitmq.com_federations.yaml | 71 ++- .../bases/rabbitmq.com_operatorpolicies.yaml | 156 +++++ .../crd/bases/rabbitmq.com_permissions.yaml | 63 ++- config/crd/bases/rabbitmq.com_policies.yaml | 73 ++- config/crd/bases/rabbitmq.com_queues.yaml | 59 +- .../rabbitmq.com_schemareplications.yaml | 89 +-- config/crd/bases/rabbitmq.com_shovels.yaml | 72 ++- .../crd/bases/rabbitmq.com_superstreams.yaml | 61 +- .../bases/rabbitmq.com_topicpermissions.yaml | 58 +- config/crd/bases/rabbitmq.com_users.yaml | 95 ++-- config/crd/bases/rabbitmq.com_vhosts.yaml | 57 +- config/crd/kustomization.yaml | 3 + .../cainjection_in_operatorpolicies.yaml | 8 + .../patches/webhook_in_operatorpolicies.yaml | 17 + config/rbac/operatorpolicy_editor_role.yaml | 24 + config/rbac/operatorpolicy_viewer_role.yaml | 20 + config/rbac/role.yaml | 26 + config/webhook/manifests.yaml | 20 + controllers/common.go | 1 + controllers/operatorpolicy_controller.go | 51 ++ controllers/operatorpolicy_controller_test.go | 225 ++++++++ controllers/reconcile_func.go | 1 + controllers/utils.go | 2 + docs/api/rabbitmq.com.ref.asciidoc | 535 ++++++++++++++---- .../operator-policies/operator-policy.yaml | 13 + go.mod | 4 +- internal/operator_policy_test.go | 67 +++ internal/operatorpolicy.go | 34 ++ main.go | 19 + .../v1beta1/fake/fake_operatorpolicy.go | 134 +++++ .../v1beta1/fake/fake_rabbitmq.com_client.go | 4 + .../v1beta1/generated_expansion.go | 2 + .../rabbitmq.com/v1beta1/operatorpolicy.go | 188 ++++++ .../v1beta1/rabbitmq.com_client.go | 5 + .../informers/externalversions/generic.go | 2 + .../rabbitmq.com/v1beta1/interface.go | 7 + .../rabbitmq.com/v1beta1/operatorpolicy.go | 83 +++ .../v1beta1/expansion_generated.go | 8 + .../rabbitmq.com/v1beta1/operatorpolicy.go | 92 +++ system_tests/operatorpolicy_system_test.go | 120 ++++ system_tests/user_system_test.go | 4 +- 53 files changed, 2738 insertions(+), 432 deletions(-) create mode 100644 api/v1beta1/operatorpolicy_types.go create mode 100644 api/v1beta1/operatorpolicy_types_test.go create mode 100644 api/v1beta1/operatorpolicy_webhook.go create mode 100644 api/v1beta1/operatorpolicy_webhook_test.go create mode 100644 config/crd/bases/rabbitmq.com_operatorpolicies.yaml create mode 100644 config/crd/patches/cainjection_in_operatorpolicies.yaml create mode 100644 config/crd/patches/webhook_in_operatorpolicies.yaml create mode 100644 config/rbac/operatorpolicy_editor_role.yaml create mode 100644 config/rbac/operatorpolicy_viewer_role.yaml create mode 100644 controllers/operatorpolicy_controller.go create mode 100644 controllers/operatorpolicy_controller_test.go create mode 100644 docs/examples/operator-policies/operator-policy.yaml create mode 100644 internal/operator_policy_test.go create mode 100644 internal/operatorpolicy.go create mode 100644 pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/fake/fake_operatorpolicy.go create mode 100644 pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/operatorpolicy.go create mode 100644 pkg/generated/informers/externalversions/rabbitmq.com/v1beta1/operatorpolicy.go create mode 100644 pkg/generated/listers/rabbitmq.com/v1beta1/operatorpolicy.go create mode 100644 system_tests/operatorpolicy_system_test.go diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 116acfa5..c883308b 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -12,7 +12,7 @@ on: tags: [ "v*" ] env: - GO_VERSION: '1.20.x' # Require Go 1.20 minor + GO_VERSION: '1.21.x' # Require Go 1.21 minor jobs: unit_integration_tests: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 97a53498..94a9882b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -37,6 +37,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + # Manually install the right version of Go + # See https://github.com/github/codeql-action/issues/1842 and https://github.com/github/codeql/issues/13992 + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 9d15dc03..2dd1f850 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -5,7 +5,7 @@ on: branches: [ main ] env: - GO_VERSION: '1.20.x' # Require Go 1.20.x + GO_VERSION: '1.21.x' # Require Go 1.21.x jobs: diff --git a/Dockerfile b/Dockerfile index 9b81dc52..0354b6ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.20 as builder +FROM --platform=$BUILDPLATFORM golang:1.21 as builder WORKDIR /workspace # Copy the Go Modules manifests diff --git a/api/v1beta1/operatorpolicy_types.go b/api/v1beta1/operatorpolicy_types.go new file mode 100644 index 00000000..133dc5ab --- /dev/null +++ b/api/v1beta1/operatorpolicy_types.go @@ -0,0 +1,90 @@ +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// OperatorPolicySpec defines the desired state of OperatorPolicy +// https://www.rabbitmq.com/parameters.html#operator-policies +type OperatorPolicySpec struct { + // Required property; cannot be updated + // +kubebuilder:validation:Required + Name string `json:"name"` + // Default to vhost '/'; cannot be updated + // +kubebuilder:default:=/ + Vhost string `json:"vhost,omitempty"` + // Regular expression pattern used to match queues, e.g. "^my-queue$". + // Required property. + // +kubebuilder:validation:Required + Pattern string `json:"pattern"` + // What this operator policy applies to: 'queues', 'classic_queues', 'quorum_queues', 'streams'. + // Default to 'queues'. + // +kubebuilder:validation:Enum=queues;classic_queues;quorum_queues;streams + // +kubebuilder:default:=queues + ApplyTo string `json:"applyTo,omitempty"` + // Default to '0'. + // In the event that more than one operator policy can match a given queue, the operator policy with the greatest priority applies. + // +kubebuilder:default:=0 + Priority int `json:"priority,omitempty"` + // OperatorPolicy definition. Required property. + // +kubebuilder:validation:Type=object + // +kubebuilder:pruning:PreserveUnknownFields + // +kubebuilder:validation:Required + Definition *runtime.RawExtension `json:"definition"` + // Reference to the RabbitmqCluster that the operator policy will be created in. + // Required property. + // +kubebuilder:validation:Required + RabbitmqClusterReference RabbitmqClusterReference `json:"rabbitmqClusterReference"` +} + +// OperatorPolicyStatus defines the observed state of OperatorPolicy +type OperatorPolicyStatus struct { + // observedGeneration is the most recent successful generation observed for this OperatorPolicy. It corresponds to the + // OperatorPolicy's generation, which is updated on mutation by the API Server. + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + Conditions []Condition `json:"conditions,omitempty"` +} + +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:resource:categories=all;rabbitmq +// +kubebuilder:subresource:status + +// OperatorPolicy is the Schema for the operator policies API +type OperatorPolicy struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec OperatorPolicySpec `json:"spec,omitempty"` + Status OperatorPolicyStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// OperatorPolicyList contains a list of OperatorPolicy +type OperatorPolicyList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []OperatorPolicy `json:"items"` +} + +func (p *OperatorPolicy) GroupResource() schema.GroupResource { + return schema.GroupResource{ + Group: p.GroupVersionKind().Group, + Resource: p.GroupVersionKind().Kind, + } +} + +func (p *OperatorPolicy) RabbitReference() RabbitmqClusterReference { + return p.Spec.RabbitmqClusterReference +} + +func (p *OperatorPolicy) SetStatusConditions(c []Condition) { + p.Status.Conditions = c +} + +func init() { + SchemeBuilder.Register(&OperatorPolicy{}, &OperatorPolicyList{}) +} diff --git a/api/v1beta1/operatorpolicy_types_test.go b/api/v1beta1/operatorpolicy_types_test.go new file mode 100644 index 00000000..0dda3d1c --- /dev/null +++ b/api/v1beta1/operatorpolicy_types_test.go @@ -0,0 +1,117 @@ +package v1beta1 + +import ( + "context" + + "k8s.io/apimachinery/pkg/runtime" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +var _ = Describe("OperatorPolicy", func() { + var ( + namespace = "default" + ctx = context.Background() + ) + + It("creates an operator policy with minimal configurations", func() { + policy := OperatorPolicy{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-operator-policy", + Namespace: namespace, + }, + Spec: OperatorPolicySpec{ + Name: "test-operator-policy", + Pattern: "^some-prefix", + Definition: &runtime.RawExtension{ + Raw: []byte(`{"max-length": 10}`), + }, + RabbitmqClusterReference: RabbitmqClusterReference{ + Name: "some-cluster", + }, + }, + } + Expect(k8sClient.Create(ctx, &policy)).To(Succeed()) + fetched := &OperatorPolicy{} + Expect(k8sClient.Get(ctx, types.NamespacedName{ + Name: policy.Name, + Namespace: policy.Namespace, + }, fetched)).To(Succeed()) + Expect(fetched.Spec.RabbitmqClusterReference).To(Equal(RabbitmqClusterReference{ + Name: "some-cluster", + })) + Expect(fetched.Spec.Name).To(Equal("test-operator-policy")) + Expect(fetched.Spec.Vhost).To(Equal("/")) + Expect(fetched.Spec.Pattern).To(Equal("^some-prefix")) + Expect(fetched.Spec.ApplyTo).To(Equal("queues")) + Expect(fetched.Spec.Priority).To(Equal(0)) + Expect(fetched.Spec.Definition.Raw).To(Equal([]byte(`{"max-length":10}`))) + }) + + It("creates operator policy with configurations", func() { + policy := OperatorPolicy{ + ObjectMeta: metav1.ObjectMeta{ + Name: "random-policy", + Namespace: namespace, + }, + Spec: OperatorPolicySpec{ + Name: "test-policy", + Vhost: "/hello", + Pattern: "*.", + ApplyTo: "quorum_queues", + Priority: 100, + Definition: &runtime.RawExtension{ + Raw: []byte(`{"max-length":10}`), + }, + RabbitmqClusterReference: RabbitmqClusterReference{ + Name: "random-cluster", + }, + }, + } + Expect(k8sClient.Create(ctx, &policy)).To(Succeed()) + fetched := &OperatorPolicy{} + Expect(k8sClient.Get(ctx, types.NamespacedName{ + Name: policy.Name, + Namespace: policy.Namespace, + }, fetched)).To(Succeed()) + + Expect(fetched.Spec.Name).To(Equal("test-policy")) + Expect(fetched.Spec.Vhost).To(Equal("/hello")) + Expect(fetched.Spec.Pattern).To(Equal("*.")) + Expect(fetched.Spec.ApplyTo).To(Equal("quorum_queues")) + Expect(fetched.Spec.Priority).To(Equal(100)) + Expect(fetched.Spec.RabbitmqClusterReference).To(Equal( + RabbitmqClusterReference{ + Name: "random-cluster", + })) + Expect(fetched.Spec.Definition.Raw).To(Equal([]byte(`{"max-length":10}`))) + }) + + When("creating a policy with an invalid 'ApplyTo' value", func() { + It("fails with validation errors", func() { + policy := OperatorPolicy{ + ObjectMeta: metav1.ObjectMeta{ + Name: "invalid", + Namespace: namespace, + }, + Spec: OperatorPolicySpec{ + Name: "test-policy", + Pattern: "a-queue-name", + Definition: &runtime.RawExtension{ + Raw: []byte(`{"max-length":10}`), + }, + ApplyTo: "yo-yo", + RabbitmqClusterReference: RabbitmqClusterReference{ + Name: "some-cluster", + }, + }, + } + Expect(k8sClient.Create(ctx, &policy)).To(HaveOccurred()) + Expect(k8sClient.Create(ctx, &policy)).To(MatchError(`OperatorPolicy.rabbitmq.com "invalid" is invalid: spec.applyTo: Unsupported value: "yo-yo": supported values: "queues", "classic_queues", "quorum_queues", "streams"`)) + }) + }) + +}) diff --git a/api/v1beta1/operatorpolicy_webhook.go b/api/v1beta1/operatorpolicy_webhook.go new file mode 100644 index 00000000..42a1009d --- /dev/null +++ b/api/v1beta1/operatorpolicy_webhook.go @@ -0,0 +1,57 @@ +package v1beta1 + +import ( + "fmt" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (p *OperatorPolicy) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(p). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-rabbitmq-com-v1beta1-operatorpolicy,mutating=false,failurePolicy=fail,groups=rabbitmq.com,resources=operatorpolicies,versions=v1beta1,name=voperatorpolicy.kb.io,sideEffects=none,admissionReviewVersions=v1 + +var _ webhook.Validator = &OperatorPolicy{} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +// either rabbitmqClusterReference.name or rabbitmqClusterReference.connectionSecret must be provided but not both +func (p *OperatorPolicy) ValidateCreate() (admission.Warnings, error) { + return p.Spec.RabbitmqClusterReference.ValidateOnCreate(p.GroupResource(), p.Name) +} + +// ValidateUpdate returns error type 'forbidden' for updates on operator policy name, vhost and rabbitmqClusterReference +func (p *OperatorPolicy) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + oldOperatorPolicy, ok := old.(*OperatorPolicy) + if !ok { + return nil, apierrors.NewBadRequest(fmt.Sprintf("expected an operator policy but got a %T", old)) + } + + detailMsg := "updates on name, vhost and rabbitmqClusterReference are all forbidden" + if p.Spec.Name != oldOperatorPolicy.Spec.Name { + return nil, apierrors.NewForbidden(p.GroupResource(), p.Name, + field.Forbidden(field.NewPath("spec", "name"), detailMsg)) + } + + if p.Spec.Vhost != oldOperatorPolicy.Spec.Vhost { + return nil, apierrors.NewForbidden(p.GroupResource(), p.Name, + field.Forbidden(field.NewPath("spec", "vhost"), detailMsg)) + } + + if !oldOperatorPolicy.Spec.RabbitmqClusterReference.Matches(&p.Spec.RabbitmqClusterReference) { + return nil, apierrors.NewForbidden(p.GroupResource(), p.Name, + field.Forbidden(field.NewPath("spec", "rabbitmqClusterReference"), detailMsg)) + } + return nil, nil +} + +func (p *OperatorPolicy) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} diff --git a/api/v1beta1/operatorpolicy_webhook_test.go b/api/v1beta1/operatorpolicy_webhook_test.go new file mode 100644 index 00000000..04809d15 --- /dev/null +++ b/api/v1beta1/operatorpolicy_webhook_test.go @@ -0,0 +1,112 @@ +package v1beta1 + +import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +var _ = Describe("policy webhook", func() { + var policy = OperatorPolicy{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: OperatorPolicySpec{ + Name: "test", + Vhost: "/test", + Pattern: "a-pattern", + ApplyTo: "queues", + Priority: 0, + RabbitmqClusterReference: RabbitmqClusterReference{ + Name: "a-cluster", + }, + }, + } + + Context("ValidateCreate", func() { + It("does not allow both spec.rabbitmqClusterReference.name and spec.rabbitmqClusterReference.connectionSecret be configured", func() { + notAllowed := policy.DeepCopy() + notAllowed.Spec.RabbitmqClusterReference.ConnectionSecret = &corev1.LocalObjectReference{Name: "some-secret"} + Expect(apierrors.IsForbidden(ignoreNilWarning(notAllowed.ValidateCreate()))).To(BeTrue()) + }) + + It("spec.rabbitmqClusterReference.name and spec.rabbitmqClusterReference.connectionSecret cannot both be empty", func() { + notAllowed := policy.DeepCopy() + notAllowed.Spec.RabbitmqClusterReference.Name = "" + notAllowed.Spec.RabbitmqClusterReference.ConnectionSecret = nil + Expect(apierrors.IsForbidden(ignoreNilWarning(notAllowed.ValidateCreate()))).To(BeTrue()) + }) + }) + + Context("ValidateUpdate", func() { + It("does not allow updates on operator policy name", func() { + newPolicy := policy.DeepCopy() + newPolicy.Spec.Name = "new-name" + Expect(apierrors.IsForbidden(ignoreNilWarning(newPolicy.ValidateUpdate(&policy)))).To(BeTrue()) + }) + + It("does not allow updates on vhost", func() { + newPolicy := policy.DeepCopy() + newPolicy.Spec.Vhost = "new-vhost" + Expect(apierrors.IsForbidden(ignoreNilWarning(newPolicy.ValidateUpdate(&policy)))).To(BeTrue()) + }) + + It("does not allow updates on RabbitmqClusterReference", func() { + newPolicy := policy.DeepCopy() + newPolicy.Spec.RabbitmqClusterReference = RabbitmqClusterReference{ + Name: "new-cluster", + } + Expect(apierrors.IsForbidden(ignoreNilWarning(newPolicy.ValidateUpdate(&policy)))).To(BeTrue()) + }) + + It("does not allow updates on rabbitmqClusterReference.connectionSecret", func() { + connectionScr := OperatorPolicy{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: OperatorPolicySpec{ + Name: "test", + Vhost: "/test", + Pattern: "a-pattern", + ApplyTo: "all", + Priority: 0, + RabbitmqClusterReference: RabbitmqClusterReference{ + ConnectionSecret: &corev1.LocalObjectReference{ + Name: "a-secret", + }, + }, + }, + } + new := connectionScr.DeepCopy() + new.Spec.RabbitmqClusterReference.ConnectionSecret.Name = "new-secret" + Expect(apierrors.IsForbidden(ignoreNilWarning(new.ValidateUpdate(&connectionScr)))).To(BeTrue()) + }) + + It("allows updates on operator policy.spec.pattern", func() { + newPolicy := policy.DeepCopy() + newPolicy.Spec.Pattern = "new-pattern" + Expect(ignoreNilWarning(newPolicy.ValidateUpdate(&policy))).To(Succeed()) + }) + + It("allows updates on operator policy.spec.applyTo", func() { + newPolicy := policy.DeepCopy() + newPolicy.Spec.ApplyTo = "queues" + Expect(ignoreNilWarning(newPolicy.ValidateUpdate(&policy))).To(Succeed()) + }) + + It("allows updates on operator policy.spec.priority", func() { + newPolicy := policy.DeepCopy() + newPolicy.Spec.Priority = 1000 + Expect(ignoreNilWarning(newPolicy.ValidateUpdate(&policy))).To(Succeed()) + }) + + It("allows updates on operator policy.spec.definition", func() { + newPolicy := policy.DeepCopy() + newPolicy.Spec.Definition = &runtime.RawExtension{Raw: []byte(`{"key":"new-definition-value"}`)} + Expect(ignoreNilWarning(newPolicy.ValidateUpdate(&policy))).To(Succeed()) + }) + }) +}) diff --git a/api/v1beta1/policy_types.go b/api/v1beta1/policy_types.go index d1189ad3..f3cd0728 100644 --- a/api/v1beta1/policy_types.go +++ b/api/v1beta1/policy_types.go @@ -33,7 +33,7 @@ type PolicySpec struct { // +kubebuilder:pruning:PreserveUnknownFields // +kubebuilder:validation:Required Definition *runtime.RawExtension `json:"definition"` - // Reference to the RabbitmqCluster that the exchange will be created in. + // Reference to the RabbitmqCluster that the policy will be created in. // Required property. // +kubebuilder:validation:Required RabbitmqClusterReference RabbitmqClusterReference `json:"rabbitmqClusterReference"` diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 23bb4d30..8d364060 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -340,6 +340,108 @@ func (in *FederationStatus) DeepCopy() *FederationStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorPolicy) DeepCopyInto(out *OperatorPolicy) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorPolicy. +func (in *OperatorPolicy) DeepCopy() *OperatorPolicy { + if in == nil { + return nil + } + out := new(OperatorPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OperatorPolicy) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorPolicyList) DeepCopyInto(out *OperatorPolicyList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OperatorPolicy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorPolicyList. +func (in *OperatorPolicyList) DeepCopy() *OperatorPolicyList { + if in == nil { + return nil + } + out := new(OperatorPolicyList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OperatorPolicyList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorPolicySpec) DeepCopyInto(out *OperatorPolicySpec) { + *out = *in + if in.Definition != nil { + in, out := &in.Definition, &out.Definition + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + in.RabbitmqClusterReference.DeepCopyInto(&out.RabbitmqClusterReference) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorPolicySpec. +func (in *OperatorPolicySpec) DeepCopy() *OperatorPolicySpec { + if in == nil { + return nil + } + out := new(OperatorPolicySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorPolicyStatus) DeepCopyInto(out *OperatorPolicyStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorPolicyStatus. +func (in *OperatorPolicyStatus) DeepCopy() *OperatorPolicyStatus { + if in == nil { + return nil + } + out := new(OperatorPolicyStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Permission) DeepCopyInto(out *Permission) { *out = *in diff --git a/config/crd/bases/rabbitmq.com_bindings.yaml b/config/crd/bases/rabbitmq.com_bindings.yaml index 9c470ea4..34a3b155 100644 --- a/config/crd/bases/rabbitmq.com_bindings.yaml +++ b/config/crd/bases/rabbitmq.com_bindings.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: bindings.rabbitmq.com spec: group: rabbitmq.com @@ -23,14 +23,19 @@ spec: description: Binding is the Schema for the bindings API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -51,27 +56,32 @@ spec: - queue type: string rabbitmqClusterReference: - description: Reference to the RabbitmqCluster that the binding will - be created in. Required property. + description: |- + Reference to the RabbitmqCluster that the binding will be created in. + Required property. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object @@ -118,9 +128,9 @@ spec: type: object type: array observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this Binding. It corresponds to the Binding's generation, - which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this Binding. It corresponds to the + Binding's generation, which is updated on mutation by the API Server. format: int64 type: integer type: object diff --git a/config/crd/bases/rabbitmq.com_exchanges.yaml b/config/crd/bases/rabbitmq.com_exchanges.yaml index f369a90d..26e6042f 100644 --- a/config/crd/bases/rabbitmq.com_exchanges.yaml +++ b/config/crd/bases/rabbitmq.com_exchanges.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: exchanges.rabbitmq.com spec: group: rabbitmq.com @@ -23,14 +23,19 @@ spec: description: Exchange is the Schema for the exchanges API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -50,27 +55,32 @@ spec: description: Required property; cannot be updated type: string rabbitmqClusterReference: - description: Reference to the RabbitmqCluster that the exchange will - be created in. Required property. + description: |- + Reference to the RabbitmqCluster that the exchange will be created in. + Required property. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object @@ -116,9 +126,9 @@ spec: type: object type: array observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this Exchange. It corresponds to the Exchange's generation, - which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this Exchange. It corresponds to the + Exchange's generation, which is updated on mutation by the API Server. format: int64 type: integer type: object diff --git a/config/crd/bases/rabbitmq.com_federations.yaml b/config/crd/bases/rabbitmq.com_federations.yaml index 966df6bc..3b01d398 100644 --- a/config/crd/bases/rabbitmq.com_federations.yaml +++ b/config/crd/bases/rabbitmq.com_federations.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: federations.rabbitmq.com spec: group: rabbitmq.com @@ -23,20 +23,26 @@ spec: description: Federation is the Schema for the federations API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object spec: - description: 'FederationSpec defines the desired state of Federation For - how to configure federation upstreams, see: https://www.rabbitmq.com/federation-reference.html.' + description: |- + FederationSpec defines the desired state of Federation + For how to configure federation upstreams, see: https://www.rabbitmq.com/federation-reference.html. properties: ackMode: enum: @@ -60,27 +66,32 @@ spec: queue: type: string rabbitmqClusterReference: - description: Reference to the RabbitmqCluster that this federation - upstream will be created in. Required property. + description: |- + Reference to the RabbitmqCluster that this federation upstream will be created in. + Required property. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object @@ -89,13 +100,17 @@ spec: trustUserId: type: boolean uriSecret: - description: Secret contains the AMQP URI(s) for the upstream. The - Secret must contain the key `uri` or operator will error. `uri` - should be one or multiple uris separated by ','. Required property. + description: |- + Secret contains the AMQP URI(s) for the upstream. + The Secret must contain the key `uri` or operator will error. + `uri` should be one or multiple uris separated by ','. + Required property. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic @@ -138,9 +153,9 @@ spec: type: object type: array observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this Federation. It corresponds to the Federation's - generation, which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this Federation. It corresponds to the + Federation's generation, which is updated on mutation by the API Server. format: int64 type: integer type: object diff --git a/config/crd/bases/rabbitmq.com_operatorpolicies.yaml b/config/crd/bases/rabbitmq.com_operatorpolicies.yaml new file mode 100644 index 00000000..29637cf0 --- /dev/null +++ b/config/crd/bases/rabbitmq.com_operatorpolicies.yaml @@ -0,0 +1,156 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: operatorpolicies.rabbitmq.com +spec: + group: rabbitmq.com + names: + categories: + - all + - rabbitmq + kind: OperatorPolicy + listKind: OperatorPolicyList + plural: operatorpolicies + singular: operatorpolicy + scope: Namespaced + versions: + - name: v1beta1 + schema: + openAPIV3Schema: + description: OperatorPolicy is the Schema for the operator policies API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: |- + OperatorPolicySpec defines the desired state of OperatorPolicy + https://www.rabbitmq.com/parameters.html#operator-policies + properties: + applyTo: + default: queues + description: |- + What this operator policy applies to: 'queues', 'classic_queues', 'quorum_queues', 'streams'. + Default to 'queues'. + enum: + - queues + - classic_queues + - quorum_queues + - streams + type: string + definition: + description: OperatorPolicy definition. Required property. + type: object + x-kubernetes-preserve-unknown-fields: true + name: + description: Required property; cannot be updated + type: string + pattern: + description: |- + Regular expression pattern used to match queues, e.g. "^my-queue$". + Required property. + type: string + priority: + default: 0 + description: |- + Default to '0'. + In the event that more than one operator policy can match a given queue, the operator policy with the greatest priority applies. + type: integer + rabbitmqClusterReference: + description: |- + Reference to the RabbitmqCluster that the operator policy will be created in. + Required property. + properties: + connectionSecret: + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + type: object + x-kubernetes-map-type: atomic + name: + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. + type: string + namespace: + description: |- + The namespace of the RabbitMQ cluster to reference. + Defaults to the namespace of the requested resource if omitted. + type: string + type: object + vhost: + default: / + description: Default to vhost '/'; cannot be updated + type: string + required: + - definition + - name + - pattern + - rabbitmqClusterReference + type: object + status: + description: OperatorPolicyStatus defines the observed state of OperatorPolicy + properties: + conditions: + items: + properties: + lastTransitionTime: + description: The last time this Condition status changed. + format: date-time + type: string + message: + description: Full text reason for current status of the condition. + type: string + reason: + description: One word, camel-case reason for current status + of the condition. + type: string + status: + description: True, False, or Unknown + type: string + type: + description: Type indicates the scope of the custom resource + status addressed by the condition. + type: string + required: + - status + - type + type: object + type: array + observedGeneration: + description: |- + observedGeneration is the most recent successful generation observed for this OperatorPolicy. It corresponds to the + OperatorPolicy's generation, which is updated on mutation by the API Server. + format: int64 + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/crd/bases/rabbitmq.com_permissions.yaml b/config/crd/bases/rabbitmq.com_permissions.yaml index 5b96fd29..4ea034dc 100644 --- a/config/crd/bases/rabbitmq.com_permissions.yaml +++ b/config/crd/bases/rabbitmq.com_permissions.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: permissions.rabbitmq.com spec: group: rabbitmq.com @@ -23,14 +23,19 @@ spec: description: Permission is the Schema for the permissions API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -38,8 +43,9 @@ spec: description: PermissionSpec defines the desired state of Permission properties: permissions: - description: 'Permissions to grant to the user in the specific vhost; - required property. See RabbitMQ doc for more information: https://www.rabbitmq.com/access-control.html#user-management' + description: |- + Permissions to grant to the user in the specific vhost; required property. + See RabbitMQ doc for more information: https://www.rabbitmq.com/access-control.html#user-management properties: configure: type: string @@ -49,27 +55,32 @@ spec: type: string type: object rabbitmqClusterReference: - description: Reference to the RabbitmqCluster that both the provided - user and vhost are. Required property. + description: |- + Reference to the RabbitmqCluster that both the provided user and vhost are. + Required property. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object @@ -83,8 +94,10 @@ spec: be updated properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic @@ -127,9 +140,9 @@ spec: type: object type: array observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this Permission. It corresponds to the Permission's - generation, which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this Permission. It corresponds to the + Permission's generation, which is updated on mutation by the API Server. format: int64 type: integer type: object diff --git a/config/crd/bases/rabbitmq.com_policies.yaml b/config/crd/bases/rabbitmq.com_policies.yaml index c96958fe..5556c363 100644 --- a/config/crd/bases/rabbitmq.com_policies.yaml +++ b/config/crd/bases/rabbitmq.com_policies.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: policies.rabbitmq.com spec: group: rabbitmq.com @@ -23,25 +23,32 @@ spec: description: Policy is the Schema for the policies API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object spec: - description: PolicySpec defines the desired state of Policy https://www.rabbitmq.com/parameters.html#policies + description: |- + PolicySpec defines the desired state of Policy + https://www.rabbitmq.com/parameters.html#policies properties: applyTo: default: all - description: 'What this policy applies to: ''queues'', ''classic_queues'', - ''quorum_queues'', ''streams'', ''exchanges'', or ''all''. Default - to ''all''.' + description: |- + What this policy applies to: 'queues', 'classic_queues', 'quorum_queues', 'streams', 'exchanges', or 'all'. + Default to 'all'. enum: - queues - classic_queues @@ -58,37 +65,43 @@ spec: description: Required property; cannot be updated type: string pattern: - description: Regular expression pattern used to match queues and exchanges, - e.g. "^amq.". Required property. + description: |- + Regular expression pattern used to match queues and exchanges, e.g. "^amq.". + Required property. type: string priority: default: 0 - description: Default to '0'. In the event that more than one policy - can match a given exchange or queue, the policy with the greatest - priority applies. + description: |- + Default to '0'. + In the event that more than one policy can match a given exchange or queue, the policy with the greatest priority applies. type: integer rabbitmqClusterReference: - description: Reference to the RabbitmqCluster that the exchange will - be created in. Required property. + description: |- + Reference to the RabbitmqCluster that the policy will be created in. + Required property. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object @@ -132,9 +145,9 @@ spec: type: object type: array observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this Policy. It corresponds to the Policy's generation, - which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this Policy. It corresponds to the + Policy's generation, which is updated on mutation by the API Server. format: int64 type: integer type: object diff --git a/config/crd/bases/rabbitmq.com_queues.yaml b/config/crd/bases/rabbitmq.com_queues.yaml index d3c2ac75..6e66724c 100644 --- a/config/crd/bases/rabbitmq.com_queues.yaml +++ b/config/crd/bases/rabbitmq.com_queues.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: queues.rabbitmq.com spec: group: rabbitmq.com @@ -23,14 +23,19 @@ spec: description: Queue is the Schema for the queues API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -38,10 +43,9 @@ spec: description: QueueSpec defines the desired state of Queue properties: arguments: - description: 'Queue arguments in the format of KEY: VALUE. e.g. x-delivery-limit: - 10000. Configuring queues through arguments is not recommended because - they cannot be updated once set; we recommend configuring queues - through policies instead.' + description: |- + Queue arguments in the format of KEY: VALUE. e.g. x-delivery-limit: 10000. + Configuring queues through arguments is not recommended because they cannot be updated once set; we recommend configuring queues through policies instead. type: object x-kubernetes-preserve-unknown-fields: true autoDelete: @@ -55,27 +59,32 @@ spec: description: Name of the queue; required property. type: string rabbitmqClusterReference: - description: Reference to the RabbitmqCluster that the queue will - be created in. Required property. + description: |- + Reference to the RabbitmqCluster that the queue will be created in. + Required property. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object @@ -119,9 +128,9 @@ spec: type: object type: array observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this Queue. It corresponds to the Queue's generation, - which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this Queue. It corresponds to the + Queue's generation, which is updated on mutation by the API Server. format: int64 type: integer type: object diff --git a/config/crd/bases/rabbitmq.com_schemareplications.yaml b/config/crd/bases/rabbitmq.com_schemareplications.yaml index 4a27c361..dd9253f2 100644 --- a/config/crd/bases/rabbitmq.com_schemareplications.yaml +++ b/config/crd/bases/rabbitmq.com_schemareplications.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: schemareplications.rabbitmq.com spec: group: rabbitmq.com @@ -17,19 +17,25 @@ spec: - name: v1beta1 schema: openAPIV3Schema: - description: 'SchemaReplication is the Schema for the schemareplications API - This feature requires Tanzu RabbitMQ with schema replication plugin. For - more information, see: https://tanzu.vmware.com/rabbitmq and https://www.rabbitmq.com/definitions-standby.html.' + description: |- + SchemaReplication is the Schema for the schemareplications API + This feature requires Tanzu RabbitMQ with schema replication plugin. + For more information, see: https://tanzu.vmware.com/rabbitmq and https://www.rabbitmq.com/definitions-standby.html. properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -37,33 +43,38 @@ spec: description: SchemaReplicationSpec defines the desired state of SchemaReplication properties: endpoints: - description: endpoints should be one or multiple endpoints separated - by ','. Must provide either spec.endpoints or endpoints in spec.upstreamSecret. - When endpoints are provided in both spec.endpoints and spec.upstreamSecret, - spec.endpoints takes precedence. + description: |- + endpoints should be one or multiple endpoints separated by ','. + Must provide either spec.endpoints or endpoints in spec.upstreamSecret. + When endpoints are provided in both spec.endpoints and spec.upstreamSecret, spec.endpoints takes + precedence. type: string rabbitmqClusterReference: description: Reference to the RabbitmqCluster that schema replication would be set for. Must be an existing cluster. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object @@ -74,25 +85,25 @@ spec: vault: properties: secretPath: - description: Path in Vault to access a KV (Key-Value) secret - with the fields username and password to be used for replication. - For example "secret/data/rabbitmq/config". Optional; if - not provided, username and password will come from upstreamSecret - instead. Have to set either secretBackend.vault.secretPath - or upstreamSecret, but not both. + description: |- + Path in Vault to access a KV (Key-Value) secret with the fields username and password to be used for replication. + For example "secret/data/rabbitmq/config". + Optional; if not provided, username and password will come from upstreamSecret instead. + Have to set either secretBackend.vault.secretPath or upstreamSecret, but not both. type: string type: object type: object upstreamSecret: - description: Defines a Secret which contains credentials to be used - for schema replication. The Secret must contain the keys `username` - and `password` in its Data field, or operator will error. Have to - set either secretBackend.vault.secretPath or spec.upstreamSecret, - but not both. + description: |- + Defines a Secret which contains credentials to be used for schema replication. + The Secret must contain the keys `username` and `password` in its Data field, or operator will error. + Have to set either secretBackend.vault.secretPath or spec.upstreamSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic @@ -129,9 +140,9 @@ spec: type: object type: array observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this Queue. It corresponds to the Queue's generation, - which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this Queue. It corresponds to the + Queue's generation, which is updated on mutation by the API Server. format: int64 type: integer type: object diff --git a/config/crd/bases/rabbitmq.com_shovels.yaml b/config/crd/bases/rabbitmq.com_shovels.yaml index dd9caebd..82e53100 100644 --- a/config/crd/bases/rabbitmq.com_shovels.yaml +++ b/config/crd/bases/rabbitmq.com_shovels.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: shovels.rabbitmq.com spec: group: rabbitmq.com @@ -23,20 +23,26 @@ spec: description: Shovel is the Schema for the shovels API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object spec: - description: 'ShovelSpec defines the desired state of Shovel For how to - configure Shovel, see: https://www.rabbitmq.com/shovel.html.' + description: |- + ShovelSpec defines the desired state of Shovel + For how to configure Shovel, see: https://www.rabbitmq.com/shovel.html. properties: ackMode: enum: @@ -91,27 +97,32 @@ spec: prefetchCount: type: integer rabbitmqClusterReference: - description: Reference to the RabbitmqCluster that this Shovel will - be created in. Required property. + description: |- + Reference to the RabbitmqCluster that this Shovel will be created in. + Required property. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object @@ -143,14 +154,17 @@ spec: description: amqp091 configuration type: string uriSecret: - description: Secret contains the AMQP URI(s) to configure Shovel destination - and source. The Secret must contain the key `destUri` and `srcUri` - or operator will error. Both fields should be one or multiple uris - separated by ','. Required property. + description: |- + Secret contains the AMQP URI(s) to configure Shovel destination and source. + The Secret must contain the key `destUri` and `srcUri` or operator will error. + Both fields should be one or multiple uris separated by ','. + Required property. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic @@ -193,9 +207,9 @@ spec: type: object type: array observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this Shovel. It corresponds to the Shovel's generation, - which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this Shovel. It corresponds to the + Shovel's generation, which is updated on mutation by the API Server. format: int64 type: integer type: object diff --git a/config/crd/bases/rabbitmq.com_superstreams.yaml b/config/crd/bases/rabbitmq.com_superstreams.yaml index 02a28223..d84d1a3f 100644 --- a/config/crd/bases/rabbitmq.com_superstreams.yaml +++ b/config/crd/bases/rabbitmq.com_superstreams.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: superstreams.rabbitmq.com spec: group: rabbitmq.com @@ -23,14 +23,19 @@ spec: description: SuperStream is the Schema for the queues API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -42,38 +47,44 @@ spec: type: string partitions: default: 3 - description: Number of partitions to create within this super stream. + description: |- + Number of partitions to create within this super stream. Defaults to '3'. type: integer rabbitmqClusterReference: - description: Reference to the RabbitmqCluster that the SuperStream - will be created in. Required property. + description: |- + Reference to the RabbitmqCluster that the SuperStream will be created in. + Required property. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object routingKeys: - description: Routing keys to use for each of the partitions in the - SuperStream If unset, the routing keys for the partitions will be - set to the index of the partitions + description: |- + Routing keys to use for each of the partitions in the SuperStream + If unset, the routing keys for the partitions will be set to the index of the partitions items: type: string type: array @@ -115,9 +126,9 @@ spec: type: object type: array observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this SuperStream. It corresponds to the SuperStream's - generation, which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this SuperStream. It corresponds to the + SuperStream's generation, which is updated on mutation by the API Server. format: int64 type: integer partitions: diff --git a/config/crd/bases/rabbitmq.com_topicpermissions.yaml b/config/crd/bases/rabbitmq.com_topicpermissions.yaml index 7d7c1886..dee27223 100644 --- a/config/crd/bases/rabbitmq.com_topicpermissions.yaml +++ b/config/crd/bases/rabbitmq.com_topicpermissions.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: topicpermissions.rabbitmq.com spec: group: rabbitmq.com @@ -20,14 +20,19 @@ spec: description: TopicPermission is the Schema for the topicpermissions API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -48,27 +53,32 @@ spec: type: string type: object rabbitmqClusterReference: - description: Reference to the RabbitmqCluster that both the provided - user and vhost are. Required property. + description: |- + Reference to the RabbitmqCluster that both the provided user and vhost are. + Required property. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object @@ -82,8 +92,10 @@ spec: be updated. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic @@ -126,9 +138,9 @@ spec: type: object type: array observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this TopicPermission. It corresponds to the TopicPermission's - generation, which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this TopicPermission. It corresponds to the + TopicPermission's generation, which is updated on mutation by the API Server. format: int64 type: integer type: object diff --git a/config/crd/bases/rabbitmq.com_users.yaml b/config/crd/bases/rabbitmq.com_users.yaml index 6fd0c1b1..acc0b956 100644 --- a/config/crd/bases/rabbitmq.com_users.yaml +++ b/config/crd/bases/rabbitmq.com_users.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: users.rabbitmq.com spec: group: rabbitmq.com @@ -23,14 +23,19 @@ spec: description: User is the Schema for the users API. properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -38,55 +43,63 @@ spec: description: Spec configures the desired state of the User object. properties: importCredentialsSecret: - description: Defines a Secret used to pre-define the username and - password set for this User. User objects created with this field - set will not have randomly-generated credentials, and will instead - import the username/password values from this Secret. The Secret - must contain the keys `username` and `password` in its Data field, - or the import will fail. Note that this import only occurs at creation - time, and is ignored once a password has been set on a User. + description: |- + Defines a Secret used to pre-define the username and password set for this User. User objects created + with this field set will not have randomly-generated credentials, and will instead import + the username/password values from this Secret. + The Secret must contain the keys `username` and `password` in its Data field, or the import will fail. + Note that this import only occurs at creation time, and is ignored once a password has been set + on a User. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic rabbitmqClusterReference: - description: Reference to the RabbitmqCluster that the user will be - created for. This cluster must exist for the User object to be created. + description: |- + Reference to the RabbitmqCluster that the user will be created for. This cluster must + exist for the User object to be created. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object tags: - description: List of permissions tags to associate with the user. - This determines the level of access to the RabbitMQ management UI - granted to the user. Omitting this field will lead to a user than - can still connect to the cluster through messaging protocols, but - cannot perform any management actions. For more information, see - https://www.rabbitmq.com/management.html#permissions. + description: |- + List of permissions tags to associate with the user. This determines the level of + access to the RabbitMQ management UI granted to the user. Omitting this field will + lead to a user than can still connect to the cluster through messaging protocols, + but cannot perform any management actions. + For more information, see https://www.rabbitmq.com/management.html#permissions. items: - description: UserTag defines the level of access to the management - UI allocated to the user. For more information, see https://www.rabbitmq.com/management.html#permissions. + description: |- + UserTag defines the level of access to the management UI allocated to the user. + For more information, see https://www.rabbitmq.com/management.html#permissions. enum: - management - policymaker @@ -131,15 +144,17 @@ spec: user credentials. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this User. It corresponds to the User's generation, - which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this User. It corresponds to the + User's generation, which is updated on mutation by the API Server. format: int64 type: integer username: diff --git a/config/crd/bases/rabbitmq.com_vhosts.yaml b/config/crd/bases/rabbitmq.com_vhosts.yaml index 3b509669..1efbe1b7 100644 --- a/config/crd/bases/rabbitmq.com_vhosts.yaml +++ b/config/crd/bases/rabbitmq.com_vhosts.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.13.0 + controller-gen.kubebuilder.io/version: v0.14.0 name: vhosts.rabbitmq.com spec: group: rabbitmq.com @@ -23,14 +23,19 @@ spec: description: Vhost is the Schema for the vhosts API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -38,8 +43,9 @@ spec: description: VhostSpec defines the desired state of Vhost properties: defaultQueueType: - description: Default queue type for this vhost; can be set to quorum, - classic or stream. Supported in RabbitMQ 3.11.12 or above. + description: |- + Default queue type for this vhost; can be set to quorum, classic or stream. + Supported in RabbitMQ 3.11.12 or above. enum: - quorum - classic @@ -49,27 +55,32 @@ spec: description: Name of the vhost; see https://www.rabbitmq.com/vhosts.html. type: string rabbitmqClusterReference: - description: Reference to the RabbitmqCluster that the vhost will - be created in. Required property. + description: |- + Reference to the RabbitmqCluster that the vhost will be created in. + Required property. properties: connectionSecret: - description: Secret contains the http management uri for the RabbitMQ - cluster. The Secret must contain the key `uri`, `username` and - `password` or operator will error. Have to set either name or - connectionSecret, but not both. + description: |- + Secret contains the http management uri for the RabbitMQ cluster. + The Secret must contain the key `uri`, `username` and `password` or operator will error. + Have to set either name or connectionSecret, but not both. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic name: - description: The name of the RabbitMQ cluster to reference. Have - to set either name or connectionSecret, but not both. + description: |- + The name of the RabbitMQ cluster to reference. + Have to set either name or connectionSecret, but not both. type: string namespace: - description: The namespace of the RabbitMQ cluster to reference. + description: |- + The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. type: string type: object @@ -113,9 +124,9 @@ spec: type: object type: array observedGeneration: - description: observedGeneration is the most recent successful generation - observed for this Vhost. It corresponds to the Vhost's generation, - which is updated on mutation by the API Server. + description: |- + observedGeneration is the most recent successful generation observed for this Vhost. It corresponds to the + Vhost's generation, which is updated on mutation by the API Server. format: int64 type: integer type: object diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 7729cec6..97fb28a0 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -8,6 +8,7 @@ resources: - bases/rabbitmq.com_users.yaml - bases/rabbitmq.com_vhosts.yaml - bases/rabbitmq.com_policies.yaml +- bases/rabbitmq.com_operatorpolicies.yaml - bases/rabbitmq.com_permissions.yaml - bases/rabbitmq.com_schemareplications.yaml - bases/rabbitmq.com_federations.yaml @@ -22,6 +23,7 @@ resources: #- patches/webhook_in_exchanges.yaml #- patches/webhook_in_vhosts.yaml #- patches/webhook_in_policies.yaml +#- patches/webhook_in_operatorpolicies.yaml #- patches/webhook_in_users.yaml #- patches/webhook_in_permissions.yaml #- patches/webhook_in_schemareplications.yaml @@ -36,6 +38,7 @@ resources: #- patches/cainjection_in_exchanges.yaml #- patches/cainjection_in_vhosts.yaml #- patches/cainjection_in_policies.yaml +#- patches/cainjection_in_operatorpolicies.yaml #- patches/cainjection_in_users.yaml #- patches/cainjection_in_permissions.yaml #- patches/cainjection_in_schemareplications.yaml diff --git a/config/crd/patches/cainjection_in_operatorpolicies.yaml b/config/crd/patches/cainjection_in_operatorpolicies.yaml new file mode 100644 index 00000000..c9739c46 --- /dev/null +++ b/config/crd/patches/cainjection_in_operatorpolicies.yaml @@ -0,0 +1,8 @@ +# The following patch adds a directive for certmanager to inject CA into the CRD +# CRD conversion requires k8s 1.13 or later. +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + name: operatorpolicies.rabbitmq.com diff --git a/config/crd/patches/webhook_in_operatorpolicies.yaml b/config/crd/patches/webhook_in_operatorpolicies.yaml new file mode 100644 index 00000000..675c4bdf --- /dev/null +++ b/config/crd/patches/webhook_in_operatorpolicies.yaml @@ -0,0 +1,17 @@ +# The following patch enables conversion webhook for CRD +# CRD conversion requires k8s 1.13 or later. +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: operatorpolicies.rabbitmq.com +spec: + conversion: + strategy: Webhook + webhook: + conversionReviewVersions: ["v1", "v1beta1"] + clientConfig: + caBundle: Cg== + service: + namespace: system + name: webhook-service + path: /convert diff --git a/config/rbac/operatorpolicy_editor_role.yaml b/config/rbac/operatorpolicy_editor_role.yaml new file mode 100644 index 00000000..f6c59d5f --- /dev/null +++ b/config/rbac/operatorpolicy_editor_role.yaml @@ -0,0 +1,24 @@ +# permissions for end users to edit operator policies. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: operatorpolicy-editor-role +rules: +- apiGroups: + - rabbitmq.com + resources: + - operatorpolicies + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - rabbitmq.com + resources: + - operatorpolicies/status + verbs: + - get diff --git a/config/rbac/operatorpolicy_viewer_role.yaml b/config/rbac/operatorpolicy_viewer_role.yaml new file mode 100644 index 00000000..92356229 --- /dev/null +++ b/config/rbac/operatorpolicy_viewer_role.yaml @@ -0,0 +1,20 @@ +# permissions for end users to view operator policies. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: operatorpolicy-viewer-role +rules: +- apiGroups: + - rabbitmq.com + resources: + - operatorpolicies + verbs: + - get + - list + - watch +- apiGroups: + - rabbitmq.com + resources: + - operatorpolicies/status + verbs: + - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 6afac7d6..bc0b1875 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -107,6 +107,32 @@ rules: - get - patch - update +- apiGroups: + - rabbitmq.com + resources: + - operatorpolicies + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - rabbitmq.com + resources: + - operatorpolicies/finalizers + verbs: + - update +- apiGroups: + - rabbitmq.com + resources: + - operatorpolicies/status + verbs: + - get + - patch + - update - apiGroups: - rabbitmq.com resources: diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index 8c4c287e..43b42780 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -64,6 +64,26 @@ webhooks: resources: - federations sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-rabbitmq-com-v1beta1-operatorpolicy + failurePolicy: Fail + name: voperatorpolicy.kb.io + rules: + - apiGroups: + - rabbitmq.com + apiVersions: + - v1beta1 + operations: + - CREATE + - UPDATE + resources: + - operatorpolicies + sideEffects: None - admissionReviewVersions: - v1 clientConfig: diff --git a/controllers/common.go b/controllers/common.go index 9a3645a0..106c9897 100644 --- a/controllers/common.go +++ b/controllers/common.go @@ -18,6 +18,7 @@ const ( BindingControllerName = "binding-controller" UserControllerName = "user-controller" PolicyControllerName = "policy-controller" + OperatorPolicyControllerName = "operator-policy-controller" PermissionControllerName = "permission-controller" SchemaReplicationControllerName = "schema-replication-controller" FederationControllerName = "federation-controller" diff --git a/controllers/operatorpolicy_controller.go b/controllers/operatorpolicy_controller.go new file mode 100644 index 00000000..d9b4ae44 --- /dev/null +++ b/controllers/operatorpolicy_controller.go @@ -0,0 +1,51 @@ +/* +RabbitMQ Messaging Topology Kubernetes Operator +Copyright 2021 VMware, Inc. + +This product is licensed to you under the Mozilla Public License 2.0 license (the "License"). You may not use this product except in compliance with the Mozilla 2.0 License. + +This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. +*/ + +package controllers + +import ( + "context" + "errors" + "fmt" + + topology "github.com/rabbitmq/messaging-topology-operator/api/v1beta1" + "github.com/rabbitmq/messaging-topology-operator/internal" + "github.com/rabbitmq/messaging-topology-operator/rabbitmqclient" + ctrl "sigs.k8s.io/controller-runtime" +) + +// +kubebuilder:rbac:groups=rabbitmq.com,resources=operatorpolicies,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=rabbitmq.com,resources=operatorpolicies/finalizers,verbs=update +// +kubebuilder:rbac:groups=rabbitmq.com,resources=operatorpolicies/status,verbs=get;update;patch + +type OperatorPolicyReconciler struct{} + +// DeclareFunc creates or updates a given operator policy using rabbithole client.PutOperatorPolicy +func (r *OperatorPolicyReconciler) DeclareFunc(_ context.Context, client rabbitmqclient.Client, obj topology.TopologyResource) error { + policy := obj.(*topology.OperatorPolicy) + generateOperatorPolicy, err := internal.GenerateOperatorPolicy(policy) + if err != nil { + return fmt.Errorf("failed to generate OperatorPolicy: %w", err) + } + return validateResponse(client.PutOperatorPolicy(policy.Spec.Vhost, policy.Spec.Name, *generateOperatorPolicy)) +} + +// DeleteFunc deletes operator policy from rabbitmq server +// if server responds with '404' Not Found, it logs and does not requeue on error +func (r *OperatorPolicyReconciler) DeleteFunc(ctx context.Context, client rabbitmqclient.Client, obj topology.TopologyResource) error { + logger := ctrl.LoggerFrom(ctx) + policy := obj.(*topology.OperatorPolicy) + err := validateResponseForDeletion(client.DeleteOperatorPolicy(policy.Spec.Vhost, policy.Spec.Name)) + if errors.Is(err, NotFound) { + logger.Info("cannot find operator policy in rabbitmq server; already deleted", "operatorpolicy", policy.Spec.Name) + } else if err != nil { + return err + } + return nil +} diff --git a/controllers/operatorpolicy_controller_test.go b/controllers/operatorpolicy_controller_test.go new file mode 100644 index 00000000..444745ff --- /dev/null +++ b/controllers/operatorpolicy_controller_test.go @@ -0,0 +1,225 @@ +package controllers_test + +import ( + "bytes" + "context" + "errors" + "io" + "net/http" + "time" + + "github.com/rabbitmq/messaging-topology-operator/controllers" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" + runtimeClient "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" + + "k8s.io/apimachinery/pkg/runtime" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gstruct" + topology "github.com/rabbitmq/messaging-topology-operator/api/v1beta1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +var _ = Describe("operatorpolicy-controller", func() { + var ( + policy topology.OperatorPolicy + policyName string + policyMgr ctrl.Manager + managerCtx context.Context + managerCancel context.CancelFunc + k8sClient runtimeClient.Client + ) + + BeforeEach(func() { + var err error + policyMgr, err = ctrl.NewManager(testEnv.Config, ctrl.Options{ + Metrics: server.Options{ + BindAddress: "0", // To avoid MacOS firewall pop-up every time you run this suite + }, + Cache: cache.Options{ + DefaultNamespaces: map[string]cache.Config{policyNamespace: {}}, + }, + Logger: GinkgoLogr, + }) + Expect(err).ToNot(HaveOccurred()) + + managerCtx, managerCancel = context.WithCancel(context.Background()) + go func(ctx context.Context) { + defer GinkgoRecover() + Expect(policyMgr.Start(ctx)).To(Succeed()) + }(managerCtx) + + k8sClient = policyMgr.GetClient() + + Expect((&controllers.TopologyReconciler{ + Client: policyMgr.GetClient(), + Type: &topology.OperatorPolicy{}, + Scheme: policyMgr.GetScheme(), + Recorder: fakeRecorder, + RabbitmqClientFactory: fakeRabbitMQClientFactory, + ReconcileFunc: &controllers.OperatorPolicyReconciler{}, + }).SetupWithManager(policyMgr)).To(Succeed()) + }) + + AfterEach(func() { + managerCancel() + // Sad workaround to avoid controllers racing for the reconciliation of other's + // test cases. Without this wait, the last run test consistently fails because + // the previous cancelled manager is just in time to reconcile the Queue of the + // new/last test, and use the wrong/unexpected arguments in the queue declare call + // + // Eventual consistency is nice when you have good means of awaiting. That's not the + // case with testenv and kubernetes controllers. + <-time.After(time.Second) + }) + + JustBeforeEach(func() { + policy = topology.OperatorPolicy{ + ObjectMeta: metav1.ObjectMeta{ + Name: policyName, + Namespace: policyNamespace, + }, + Spec: topology.OperatorPolicySpec{ + Definition: &runtime.RawExtension{ + Raw: []byte(`{"key":"value"}`), + }, + RabbitmqClusterReference: topology.RabbitmqClusterReference{ + Name: "example-rabbit", + }, + }, + } + }) + + Context("creation", func() { + When("the RabbitMQ Client returns a HTTP error response", func() { + BeforeEach(func() { + policyName = "test-http-error" + fakeRabbitMQClient.PutOperatorPolicyReturns(&http.Response{ + Status: "418 I'm a teapot", + StatusCode: 418, + }, errors.New("a failure")) + }) + + It("sets the status condition", func() { + Expect(k8sClient.Create(ctx, &policy)).To(Succeed()) + Eventually(func() []topology.Condition { + _ = k8sClient.Get( + ctx, + types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, + &policy, + ) + + return policy.Status.Conditions + }). + Within(statusEventsUpdateTimeout). + WithPolling(time.Second). + Should(ContainElement(MatchFields(IgnoreExtras, Fields{ + "Type": Equal(topology.ConditionType("Ready")), + "Reason": Equal("FailedCreateOrUpdate"), + "Status": Equal(corev1.ConditionFalse), + "Message": ContainSubstring("a failure"), + }))) + }) + }) + + When("the RabbitMQ Client returns a Go error response", func() { + BeforeEach(func() { + policyName = "test-go-error" + fakeRabbitMQClient.PutOperatorPolicyReturns(nil, errors.New("a go failure")) + }) + + It("sets the status condition to indicate a failure to reconcile", func() { + Expect(k8sClient.Create(ctx, &policy)).To(Succeed()) + Eventually(func() []topology.Condition { + _ = k8sClient.Get( + ctx, + types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, + &policy, + ) + + return policy.Status.Conditions + }). + Within(statusEventsUpdateTimeout). + WithPolling(time.Second). + Should(ContainElement(MatchFields(IgnoreExtras, Fields{ + "Type": Equal(topology.ConditionType("Ready")), + "Reason": Equal("FailedCreateOrUpdate"), + "Status": Equal(corev1.ConditionFalse), + "Message": ContainSubstring("a go failure"), + }))) + }) + }) + }) + + Context("deletion", func() { + JustBeforeEach(func() { + fakeRabbitMQClient.PutOperatorPolicyReturns(&http.Response{ + Status: "201 Created", + StatusCode: http.StatusCreated, + }, nil) + Expect(k8sClient.Create(ctx, &policy)).To(Succeed()) + Eventually(func() []topology.Condition { + _ = k8sClient.Get( + ctx, + types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, + &policy, + ) + + return policy.Status.Conditions + }). + Within(statusEventsUpdateTimeout). + WithPolling(time.Second). + Should(ContainElement(MatchFields(IgnoreExtras, Fields{ + "Type": Equal(topology.ConditionType("Ready")), + "Reason": Equal("SuccessfulCreateOrUpdate"), + "Status": Equal(corev1.ConditionTrue), + }))) + }) + + When("the RabbitMQ Client returns a HTTP error response", func() { + BeforeEach(func() { + policyName = "delete-policy-http-error" + fakeRabbitMQClient.DeleteOperatorPolicyReturns(&http.Response{ + Status: "502 Bad Gateway", + StatusCode: http.StatusBadGateway, + Body: io.NopCloser(bytes.NewBufferString("Hello World")), + }, nil) + }) + + It("publishes a 'warning' event", func() { + Expect(k8sClient.Delete(ctx, &policy)).To(Succeed()) + Consistently(func() bool { + err := k8sClient.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, &topology.OperatorPolicy{}) + return apierrors.IsNotFound(err) + }). + Within(statusEventsUpdateTimeout). + Should(BeFalse()) + Expect(observedEvents()).To(ContainElement("Warning FailedDelete failed to delete operatorpolicy")) + }) + }) + + When("the RabbitMQ Client returns a Go error response", func() { + BeforeEach(func() { + policyName = "delete-go-error" + fakeRabbitMQClient.DeleteOperatorPolicyReturns(nil, errors.New("some error")) + }) + + It("publishes a 'warning' event", func() { + Expect(k8sClient.Delete(ctx, &policy)).To(Succeed()) + Consistently(func() bool { + err := k8sClient.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, &topology.OperatorPolicy{}) + return apierrors.IsNotFound(err) + }). + Within(statusEventsUpdateTimeout). + Should(BeFalse()) + Expect(observedEvents()).To(ContainElement("Warning FailedDelete failed to delete operatorpolicy")) + }) + }) + }) +}) diff --git a/controllers/reconcile_func.go b/controllers/reconcile_func.go index 62a3dbb7..a3900a0f 100644 --- a/controllers/reconcile_func.go +++ b/controllers/reconcile_func.go @@ -11,6 +11,7 @@ var _ ReconcileFunc = &ExchangeReconciler{} var _ ReconcileFunc = &FederationReconciler{} var _ ReconcileFunc = &PermissionReconciler{} var _ ReconcileFunc = &PolicyReconciler{} +var _ ReconcileFunc = &OperatorPolicyReconciler{} var _ ReconcileFunc = &QueueReconciler{} var _ ReconcileFunc = &SchemaReplicationReconciler{} var _ ReconcileFunc = &ShovelReconciler{} diff --git a/controllers/utils.go b/controllers/utils.go index c90c28f0..2aee8ffd 100644 --- a/controllers/utils.go +++ b/controllers/utils.go @@ -86,6 +86,8 @@ func deletionFinalizer(kind string) string { var plural string if kind == "Policy" { plural = "policies" + } else if kind == "OperatorPolicy" { + plural = "operatorpolicies" } else { plural = strings.ToLower(kind) + "s" } diff --git a/docs/api/rabbitmq.com.ref.asciidoc b/docs/api/rabbitmq.com.ref.asciidoc index 27ae4f5b..c9a9bc38 100644 --- a/docs/api/rabbitmq.com.ref.asciidoc +++ b/docs/api/rabbitmq.com.ref.asciidoc @@ -36,8 +36,15 @@ SuperStream is the Schema for the queues API | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1alpha1` | *`kind`* __string__ | `SuperStream` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1alpha1-superstreamspec[$$SuperStreamSpec$$]__ | @@ -57,8 +64,15 @@ SuperStreamList contains a list of SuperStreams | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1alpha1` | *`kind`* __string__ | `SuperStreamList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1alpha1-superstream[$$SuperStream$$] array__ | @@ -80,9 +94,12 @@ SuperStreamSpec defines the desired state of SuperStream | Field | Description | *`name`* __string__ | Name of the queue; required property. | *`vhost`* __string__ | Default to vhost '/'; cannot be updated -| *`partitions`* __integer__ | Number of partitions to create within this super stream. Defaults to '3'. -| *`routingKeys`* __string array__ | Routing keys to use for each of the partitions in the SuperStream If unset, the routing keys for the partitions will be set to the index of the partitions -| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the SuperStream will be created in. Required property. +| *`partitions`* __integer__ | Number of partitions to create within this super stream. +Defaults to '3'. +| *`routingKeys`* __string array__ | Routing keys to use for each of the partitions in the SuperStream +If unset, the routing keys for the partitions will be set to the index of the partitions +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the SuperStream will be created in. +Required property. |=== @@ -99,7 +116,8 @@ SuperStreamStatus defines the observed state of SuperStream [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this SuperStream. It corresponds to the SuperStream's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this SuperStream. It corresponds to the +SuperStream's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | | *`partitions`* __string array__ | Partitions are a list of the stream queue names which form the partitions of this SuperStream. |=== @@ -118,6 +136,8 @@ Package v1beta1 contains API Schema definitions for the rabbitmq.com v1beta1 API - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-exchangelist[$$ExchangeList$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-federation[$$Federation$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-federationlist[$$FederationList$$] +- xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicy[$$OperatorPolicy$$] +- xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicylist[$$OperatorPolicyList$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-permission[$$Permission$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-permissionlist[$$PermissionList$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-policy[$$Policy$$] @@ -153,8 +173,15 @@ Binding is the Schema for the bindings API | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `Binding` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-bindingspec[$$BindingSpec$$]__ | @@ -174,8 +201,15 @@ BindingList contains a list of Binding | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `BindingList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-binding[$$Binding$$] array__ | @@ -201,7 +235,8 @@ BindingSpec defines the desired state of Binding | *`destinationType`* __string__ | Cannot be updated | *`routingKey`* __string__ | Cannot be updated | *`arguments`* __xref:{anchor_prefix}-k8s-io-apimachinery-pkg-runtime-rawextension[$$RawExtension$$]__ | Cannot be updated -| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the binding will be created in. Required property. +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the binding will be created in. +Required property. |=== @@ -218,7 +253,8 @@ BindingStatus defines the observed state of Binding [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Binding. It corresponds to the Binding's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Binding. It corresponds to the +Binding's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | |=== @@ -233,6 +269,7 @@ BindingStatus defines the observed state of Binding - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-bindingstatus[$$BindingStatus$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-exchangestatus[$$ExchangeStatus$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-federationstatus[$$FederationStatus$$] +- xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicystatus[$$OperatorPolicyStatus$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-permissionstatus[$$PermissionStatus$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-policystatus[$$PolicyStatus$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-queuestatus[$$QueueStatus$$] @@ -282,8 +319,15 @@ Exchange is the Schema for the exchanges API | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `Exchange` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-exchangespec[$$ExchangeSpec$$]__ | @@ -303,8 +347,15 @@ ExchangeList contains a list of Exchange | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `ExchangeList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-exchange[$$Exchange$$] array__ | @@ -330,7 +381,8 @@ ExchangeSpec defines the desired state of Exchange | *`durable`* __boolean__ | Cannot be updated | *`autoDelete`* __boolean__ | Cannot be updated | *`arguments`* __xref:{anchor_prefix}-k8s-io-apimachinery-pkg-runtime-rawextension[$$RawExtension$$]__ | -| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the exchange will be created in. Required property. +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the exchange will be created in. +Required property. |=== @@ -347,7 +399,8 @@ ExchangeStatus defines the observed state of Exchange [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Exchange. It corresponds to the Exchange's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Exchange. It corresponds to the +Exchange's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | |=== @@ -367,8 +420,15 @@ Federation is the Schema for the federations API | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `Federation` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-federationspec[$$FederationSpec$$]__ | @@ -388,8 +448,15 @@ FederationList contains a list of Federation | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `FederationList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-federation[$$Federation$$] array__ | @@ -399,7 +466,8 @@ FederationList contains a list of Federation [id="{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-federationspec"] ==== FederationSpec -FederationSpec defines the desired state of Federation For how to configure federation upstreams, see: https://www.rabbitmq.com/federation-reference.html. +FederationSpec defines the desired state of Federation +For how to configure federation upstreams, see: https://www.rabbitmq.com/federation-reference.html. .Appears In: **** @@ -411,8 +479,12 @@ FederationSpec defines the desired state of Federation For how to configure fede | Field | Description | *`name`* __string__ | Required property; cannot be updated | *`vhost`* __string__ | Default to vhost '/'; cannot be updated -| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that this federation upstream will be created in. Required property. -| *`uriSecret`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Secret contains the AMQP URI(s) for the upstream. The Secret must contain the key `uri` or operator will error. `uri` should be one or multiple uris separated by ','. Required property. +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that this federation upstream will be created in. +Required property. +| *`uriSecret`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Secret contains the AMQP URI(s) for the upstream. +The Secret must contain the key `uri` or operator will error. +`uri` should be one or multiple uris separated by ','. +Required property. | *`prefetch-count`* __integer__ | | *`ackMode`* __string__ | | *`expires`* __integer__ | @@ -438,7 +510,113 @@ FederationStatus defines the observed state of Federation [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Federation. It corresponds to the Federation's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Federation. It corresponds to the +Federation's generation, which is updated on mutation by the API Server. +| *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | +|=== + + +[id="{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicy"] +==== OperatorPolicy + +OperatorPolicy is the Schema for the operator policies API + +.Appears In: +**** +- xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicylist[$$OperatorPolicyList$$] +**** + +[cols="25a,75a", options="header"] +|=== +| Field | Description +| *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` +| *`kind`* __string__ | `OperatorPolicy` +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. + +| *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicyspec[$$OperatorPolicySpec$$]__ | +| *`status`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicystatus[$$OperatorPolicyStatus$$]__ | +|=== + + +[id="{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicylist"] +==== OperatorPolicyList + +OperatorPolicyList contains a list of OperatorPolicy + + + +[cols="25a,75a", options="header"] +|=== +| Field | Description +| *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` +| *`kind`* __string__ | `OperatorPolicyList` +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. + +| *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicy[$$OperatorPolicy$$] array__ | +|=== + + +[id="{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicyspec"] +==== OperatorPolicySpec + +OperatorPolicySpec defines the desired state of OperatorPolicy +https://www.rabbitmq.com/parameters.html#operator-policies + +.Appears In: +**** +- xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicy[$$OperatorPolicy$$] +**** + +[cols="25a,75a", options="header"] +|=== +| Field | Description +| *`name`* __string__ | Required property; cannot be updated +| *`vhost`* __string__ | Default to vhost '/'; cannot be updated +| *`pattern`* __string__ | Regular expression pattern used to match queues, e.g. "^my-queue$". +Required property. +| *`applyTo`* __string__ | What this operator policy applies to: 'queues', 'classic_queues', 'quorum_queues', 'streams'. +Default to 'queues'. +| *`priority`* __integer__ | Default to '0'. +In the event that more than one operator policy can match a given queue, the operator policy with the greatest priority applies. +| *`definition`* __xref:{anchor_prefix}-k8s-io-apimachinery-pkg-runtime-rawextension[$$RawExtension$$]__ | OperatorPolicy definition. Required property. +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the operator policy will be created in. +Required property. +|=== + + +[id="{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicystatus"] +==== OperatorPolicyStatus + +OperatorPolicyStatus defines the observed state of OperatorPolicy + +.Appears In: +**** +- xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicy[$$OperatorPolicy$$] +**** + +[cols="25a,75a", options="header"] +|=== +| Field | Description +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this OperatorPolicy. It corresponds to the +OperatorPolicy's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | |=== @@ -458,8 +636,15 @@ Permission is the Schema for the permissions API | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `Permission` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-permissionspec[$$PermissionSpec$$]__ | @@ -479,8 +664,15 @@ PermissionList contains a list of Permission | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `PermissionList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-permission[$$Permission$$] array__ | @@ -503,8 +695,10 @@ PermissionSpec defines the desired state of Permission | *`user`* __string__ | Name of an existing user; must provide user or userReference, else create/update will fail; cannot be updated | *`userReference`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Reference to an existing user.rabbitmq.com object; must provide user or userReference, else create/update will fail; cannot be updated | *`vhost`* __string__ | Name of an existing vhost; required property; cannot be updated -| *`permissions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-vhostpermissions[$$VhostPermissions$$]__ | Permissions to grant to the user in the specific vhost; required property. See RabbitMQ doc for more information: https://www.rabbitmq.com/access-control.html#user-management -| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that both the provided user and vhost are. Required property. +| *`permissions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-vhostpermissions[$$VhostPermissions$$]__ | Permissions to grant to the user in the specific vhost; required property. +See RabbitMQ doc for more information: https://www.rabbitmq.com/access-control.html#user-management +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that both the provided user and vhost are. +Required property. |=== @@ -521,7 +715,8 @@ PermissionStatus defines the observed state of Permission [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Permission. It corresponds to the Permission's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Permission. It corresponds to the +Permission's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | |=== @@ -541,8 +736,15 @@ Policy is the Schema for the policies API | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `Policy` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-policyspec[$$PolicySpec$$]__ | @@ -562,8 +764,15 @@ PolicyList contains a list of Policy | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `PolicyList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-policy[$$Policy$$] array__ | @@ -573,7 +782,8 @@ PolicyList contains a list of Policy [id="{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-policyspec"] ==== PolicySpec -PolicySpec defines the desired state of Policy https://www.rabbitmq.com/parameters.html#policies +PolicySpec defines the desired state of Policy +https://www.rabbitmq.com/parameters.html#policies .Appears In: **** @@ -585,11 +795,15 @@ PolicySpec defines the desired state of Policy https://www.rabbitmq.com/paramete | Field | Description | *`name`* __string__ | Required property; cannot be updated | *`vhost`* __string__ | Default to vhost '/'; cannot be updated -| *`pattern`* __string__ | Regular expression pattern used to match queues and exchanges, e.g. "^amq.". Required property. -| *`applyTo`* __string__ | What this policy applies to: 'queues', 'classic_queues', 'quorum_queues', 'streams', 'exchanges', or 'all'. Default to 'all'. -| *`priority`* __integer__ | Default to '0'. In the event that more than one policy can match a given exchange or queue, the policy with the greatest priority applies. +| *`pattern`* __string__ | Regular expression pattern used to match queues and exchanges, e.g. "^amq.". +Required property. +| *`applyTo`* __string__ | What this policy applies to: 'queues', 'classic_queues', 'quorum_queues', 'streams', 'exchanges', or 'all'. +Default to 'all'. +| *`priority`* __integer__ | Default to '0'. +In the event that more than one policy can match a given exchange or queue, the policy with the greatest priority applies. | *`definition`* __xref:{anchor_prefix}-k8s-io-apimachinery-pkg-runtime-rawextension[$$RawExtension$$]__ | Policy definition. Required property. -| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the exchange will be created in. Required property. +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the policy will be created in. +Required property. |=== @@ -606,7 +820,8 @@ PolicyStatus defines the observed state of Policy [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Policy. It corresponds to the Policy's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Policy. It corresponds to the +Policy's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | |=== @@ -626,8 +841,15 @@ Queue is the Schema for the queues API | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `Queue` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-queuespec[$$QueueSpec$$]__ | @@ -647,8 +869,15 @@ QueueList contains a list of Queue | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `QueueList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-queue[$$Queue$$] array__ | @@ -673,8 +902,10 @@ QueueSpec defines the desired state of Queue | *`type`* __string__ | | *`durable`* __boolean__ | When set to false queues does not survive server restart. | *`autoDelete`* __boolean__ | when set to true, queues that have had at least one consumer before are deleted after the last consumer unsubscribes. -| *`arguments`* __xref:{anchor_prefix}-k8s-io-apimachinery-pkg-runtime-rawextension[$$RawExtension$$]__ | Queue arguments in the format of KEY: VALUE. e.g. x-delivery-limit: 10000. Configuring queues through arguments is not recommended because they cannot be updated once set; we recommend configuring queues through policies instead. -| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the queue will be created in. Required property. +| *`arguments`* __xref:{anchor_prefix}-k8s-io-apimachinery-pkg-runtime-rawextension[$$RawExtension$$]__ | Queue arguments in the format of KEY: VALUE. e.g. x-delivery-limit: 10000. +Configuring queues through arguments is not recommended because they cannot be updated once set; we recommend configuring queues through policies instead. +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the queue will be created in. +Required property. |=== @@ -691,7 +922,8 @@ QueueStatus defines the observed state of Queue [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Queue. It corresponds to the Queue's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Queue. It corresponds to the +Queue's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | |=== @@ -706,6 +938,7 @@ QueueStatus defines the observed state of Queue - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-bindingspec[$$BindingSpec$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-exchangespec[$$ExchangeSpec$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-federationspec[$$FederationSpec$$] +- xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-operatorpolicyspec[$$OperatorPolicySpec$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-permissionspec[$$PermissionSpec$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-policyspec[$$PolicySpec$$] - xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-queuespec[$$QueueSpec$$] @@ -720,16 +953,22 @@ QueueStatus defines the observed state of Queue [cols="25a,75a", options="header"] |=== | Field | Description -| *`name`* __string__ | The name of the RabbitMQ cluster to reference. Have to set either name or connectionSecret, but not both. -| *`namespace`* __string__ | The namespace of the RabbitMQ cluster to reference. Defaults to the namespace of the requested resource if omitted. -| *`connectionSecret`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Secret contains the http management uri for the RabbitMQ cluster. The Secret must contain the key `uri`, `username` and `password` or operator will error. Have to set either name or connectionSecret, but not both. +| *`name`* __string__ | The name of the RabbitMQ cluster to reference. +Have to set either name or connectionSecret, but not both. +| *`namespace`* __string__ | The namespace of the RabbitMQ cluster to reference. +Defaults to the namespace of the requested resource if omitted. +| *`connectionSecret`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Secret contains the http management uri for the RabbitMQ cluster. +The Secret must contain the key `uri`, `username` and `password` or operator will error. +Have to set either name or connectionSecret, but not both. |=== [id="{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-schemareplication"] ==== SchemaReplication -SchemaReplication is the Schema for the schemareplications API This feature requires Tanzu RabbitMQ with schema replication plugin. For more information, see: https://tanzu.vmware.com/rabbitmq and https://www.rabbitmq.com/definitions-standby.html. +SchemaReplication is the Schema for the schemareplications API +This feature requires Tanzu RabbitMQ with schema replication plugin. +For more information, see: https://tanzu.vmware.com/rabbitmq and https://www.rabbitmq.com/definitions-standby.html. .Appears In: **** @@ -741,8 +980,15 @@ SchemaReplication is the Schema for the schemareplications API This feature requ | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `SchemaReplication` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-schemareplicationspec[$$SchemaReplicationSpec$$]__ | @@ -762,8 +1008,15 @@ SchemaReplicationList contains a list of SchemaReplication | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `SchemaReplicationList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-schemareplication[$$SchemaReplication$$] array__ | @@ -784,8 +1037,13 @@ SchemaReplicationSpec defines the desired state of SchemaReplication |=== | Field | Description | *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that schema replication would be set for. Must be an existing cluster. -| *`upstreamSecret`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Defines a Secret which contains credentials to be used for schema replication. The Secret must contain the keys `username` and `password` in its Data field, or operator will error. Have to set either secretBackend.vault.secretPath or spec.upstreamSecret, but not both. -| *`endpoints`* __string__ | endpoints should be one or multiple endpoints separated by ','. Must provide either spec.endpoints or endpoints in spec.upstreamSecret. When endpoints are provided in both spec.endpoints and spec.upstreamSecret, spec.endpoints takes precedence. +| *`upstreamSecret`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Defines a Secret which contains credentials to be used for schema replication. +The Secret must contain the keys `username` and `password` in its Data field, or operator will error. +Have to set either secretBackend.vault.secretPath or spec.upstreamSecret, but not both. +| *`endpoints`* __string__ | endpoints should be one or multiple endpoints separated by ','. +Must provide either spec.endpoints or endpoints in spec.upstreamSecret. +When endpoints are provided in both spec.endpoints and spec.upstreamSecret, spec.endpoints takes +precedence. | *`secretBackend`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-secretbackend[$$SecretBackend$$]__ | Set to fetch user credentials from K8s external secret stores to be used for schema replication. |=== @@ -803,7 +1061,8 @@ SchemaReplicationStatus defines the observed state of SchemaReplication [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Queue. It corresponds to the Queue's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Queue. It corresponds to the +Queue's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | |=== @@ -811,7 +1070,8 @@ SchemaReplicationStatus defines the observed state of SchemaReplication [id="{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-secretbackend"] ==== SecretBackend -SecretBackend configures a single secret backend. Today, only Vault exists as supported secret backend. +SecretBackend configures a single secret backend. +Today, only Vault exists as supported secret backend. .Appears In: **** @@ -840,8 +1100,15 @@ Shovel is the Schema for the shovels API | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `Shovel` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-shovelspec[$$ShovelSpec$$]__ | @@ -861,8 +1128,15 @@ ShovelList contains a list of Shovel | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `ShovelList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-shovel[$$Shovel$$] array__ | @@ -872,7 +1146,8 @@ ShovelList contains a list of Shovel [id="{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-shovelspec"] ==== ShovelSpec -ShovelSpec defines the desired state of Shovel For how to configure Shovel, see: https://www.rabbitmq.com/shovel.html. +ShovelSpec defines the desired state of Shovel +For how to configure Shovel, see: https://www.rabbitmq.com/shovel.html. .Appears In: **** @@ -884,8 +1159,12 @@ ShovelSpec defines the desired state of Shovel For how to configure Shovel, see: | Field | Description | *`name`* __string__ | Required property; cannot be updated | *`vhost`* __string__ | Default to vhost '/'; cannot be updated -| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that this Shovel will be created in. Required property. -| *`uriSecret`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Secret contains the AMQP URI(s) to configure Shovel destination and source. The Secret must contain the key `destUri` and `srcUri` or operator will error. Both fields should be one or multiple uris separated by ','. Required property. +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that this Shovel will be created in. +Required property. +| *`uriSecret`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Secret contains the AMQP URI(s) to configure Shovel destination and source. +The Secret must contain the key `destUri` and `srcUri` or operator will error. +Both fields should be one or multiple uris separated by ','. +Required property. | *`ackMode`* __string__ | | *`prefetchCount`* __integer__ | | *`reconnectDelay`* __integer__ | @@ -926,7 +1205,8 @@ ShovelStatus defines the observed state of Shovel [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Shovel. It corresponds to the Shovel's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Shovel. It corresponds to the +Shovel's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | |=== @@ -946,8 +1226,15 @@ TopicPermission is the Schema for the topicpermissions API | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `TopicPermission` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-topicpermissionspec[$$TopicPermissionSpec$$]__ | @@ -986,8 +1273,15 @@ TopicPermissionList contains a list of TopicPermission | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `TopicPermissionList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-topicpermission[$$TopicPermission$$] array__ | @@ -1011,7 +1305,8 @@ TopicPermissionSpec defines the desired state of TopicPermission | *`userReference`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Reference to an existing user.rabbitmq.com object; must provide user or userReference, else create/update will fail; cannot be updated. | *`vhost`* __string__ | Name of an existing vhost; required property; cannot be updated. | *`permissions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-topicpermissionconfig[$$TopicPermissionConfig$$]__ | Permissions to grant to the user to a topic exchange; required property. -| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that both the provided user and vhost are. Required property. +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that both the provided user and vhost are. +Required property. |=== @@ -1028,7 +1323,8 @@ TopicPermissionStatus defines the observed state of TopicPermission [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this TopicPermission. It corresponds to the TopicPermission's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this TopicPermission. It corresponds to the +TopicPermission's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | |=== @@ -1050,8 +1346,15 @@ User is the Schema for the users API. | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `User` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-userspec[$$UserSpec$$]__ | Spec configures the desired state of the User object. @@ -1071,8 +1374,15 @@ UserList contains a list of Users. | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `UserList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-user[$$User$$] array__ | @@ -1092,9 +1402,19 @@ UserSpec defines the desired state of User. [cols="25a,75a", options="header"] |=== | Field | Description -| *`tags`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-usertag[$$UserTag$$] array__ | List of permissions tags to associate with the user. This determines the level of access to the RabbitMQ management UI granted to the user. Omitting this field will lead to a user than can still connect to the cluster through messaging protocols, but cannot perform any management actions. For more information, see https://www.rabbitmq.com/management.html#permissions. -| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the user will be created for. This cluster must exist for the User object to be created. -| *`importCredentialsSecret`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Defines a Secret used to pre-define the username and password set for this User. User objects created with this field set will not have randomly-generated credentials, and will instead import the username/password values from this Secret. The Secret must contain the keys `username` and `password` in its Data field, or the import will fail. Note that this import only occurs at creation time, and is ignored once a password has been set on a User. +| *`tags`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-usertag[$$UserTag$$] array__ | List of permissions tags to associate with the user. This determines the level of +access to the RabbitMQ management UI granted to the user. Omitting this field will +lead to a user than can still connect to the cluster through messaging protocols, +but cannot perform any management actions. +For more information, see https://www.rabbitmq.com/management.html#permissions. +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the user will be created for. This cluster must +exist for the User object to be created. +| *`importCredentialsSecret`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Defines a Secret used to pre-define the username and password set for this User. User objects created +with this field set will not have randomly-generated credentials, and will instead import +the username/password values from this Secret. +The Secret must contain the keys `username` and `password` in its Data field, or the import will fail. +Note that this import only occurs at creation time, and is ignored once a password has been set +on a User. |=== @@ -1111,7 +1431,8 @@ UserStatus defines the observed state of User. [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this User. It corresponds to the User's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this User. It corresponds to the +User's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | | *`credentials`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core[$$LocalObjectReference$$]__ | Provides a reference to a Secret object containing the user credentials. | *`username`* __string__ | Provide rabbitmq Username @@ -1121,7 +1442,8 @@ UserStatus defines the observed state of User. [id="{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-usertag"] ==== UserTag (string) -UserTag defines the level of access to the management UI allocated to the user. For more information, see https://www.rabbitmq.com/management.html#permissions. +UserTag defines the level of access to the management UI allocated to the user. +For more information, see https://www.rabbitmq.com/management.html#permissions. .Appears In: **** @@ -1143,7 +1465,10 @@ UserTag defines the level of access to the management UI allocated to the user. [cols="25a,75a", options="header"] |=== | Field | Description -| *`secretPath`* __string__ | Path in Vault to access a KV (Key-Value) secret with the fields username and password to be used for replication. For example "secret/data/rabbitmq/config". Optional; if not provided, username and password will come from upstreamSecret instead. Have to set either secretBackend.vault.secretPath or upstreamSecret, but not both. +| *`secretPath`* __string__ | Path in Vault to access a KV (Key-Value) secret with the fields username and password to be used for replication. +For example "secret/data/rabbitmq/config". +Optional; if not provided, username and password will come from upstreamSecret instead. +Have to set either secretBackend.vault.secretPath or upstreamSecret, but not both. |=== @@ -1162,8 +1487,15 @@ Vhost is the Schema for the vhosts API | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `Vhost` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`spec`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-vhostspec[$$VhostSpec$$]__ | @@ -1183,8 +1515,15 @@ VhostList contains a list of Vhost | Field | Description | *`apiVersion`* __string__ | `rabbitmq.com/v1beta1` | *`kind`* __string__ | `VhostList` -| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds -| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources +| *`kind`* __string__ | Kind is a string value representing the REST resource this object represents. +Servers may infer this from the endpoint the client submits requests to. +Cannot be updated. +In CamelCase. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds +| *`apiVersion`* __string__ | APIVersion defines the versioned schema of this representation of an object. +Servers should convert recognized schemas to the latest internal value, and +may reject unrecognized values. +More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. | *`items`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-vhost[$$Vhost$$] array__ | @@ -1194,7 +1533,8 @@ VhostList contains a list of Vhost [id="{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-vhostpermissions"] ==== VhostPermissions -Set of RabbitMQ permissions: configure, read and write. By not setting a property (configure/write/read), it result in an empty string which does not not match any permission. +Set of RabbitMQ permissions: configure, read and write. +By not setting a property (configure/write/read), it result in an empty string which does not not match any permission. .Appears In: **** @@ -1226,8 +1566,10 @@ VhostSpec defines the desired state of Vhost | *`name`* __string__ | Name of the vhost; see https://www.rabbitmq.com/vhosts.html. | *`tracing`* __boolean__ | | *`tags`* __string array__ | -| *`defaultQueueType`* __string__ | Default queue type for this vhost; can be set to quorum, classic or stream. Supported in RabbitMQ 3.11.12 or above. -| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the vhost will be created in. Required property. +| *`defaultQueueType`* __string__ | Default queue type for this vhost; can be set to quorum, classic or stream. +Supported in RabbitMQ 3.11.12 or above. +| *`rabbitmqClusterReference`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-rabbitmqclusterreference[$$RabbitmqClusterReference$$]__ | Reference to the RabbitmqCluster that the vhost will be created in. +Required property. |=== @@ -1244,7 +1586,8 @@ VhostStatus defines the observed state of Vhost [cols="25a,75a", options="header"] |=== | Field | Description -| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Vhost. It corresponds to the Vhost's generation, which is updated on mutation by the API Server. +| *`observedGeneration`* __integer__ | observedGeneration is the most recent successful generation observed for this Vhost. It corresponds to the +Vhost's generation, which is updated on mutation by the API Server. | *`conditions`* __xref:{anchor_prefix}-github-com-rabbitmq-messaging-topology-operator-api-v1beta1-condition[$$Condition$$] array__ | |=== diff --git a/docs/examples/operator-policies/operator-policy.yaml b/docs/examples/operator-policies/operator-policy.yaml new file mode 100644 index 00000000..2b16ec0f --- /dev/null +++ b/docs/examples/operator-policies/operator-policy.yaml @@ -0,0 +1,13 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: OperatorPolicy +metadata: + name: operator-policy-example +spec: + name: my-operator-policy # name of the operator policy + vhost: "/" # default to '/' if not provided + pattern: "^abc" # regex used to match queues + applyTo: "queues" # apply to all types of 'queues' (default), 'classic_queue', quorum_queues', or 'streams' + definition: # policy definition + expires: 1800000 + rabbitmqClusterReference: + name: test # rabbitmqCluster must exist in the same namespace as this resource diff --git a/go.mod b/go.mod index 7eb0ae43..d9f75426 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/rabbitmq/messaging-topology-operator -go 1.20 +go 1.21 + +toolchain go1.21.6 require ( github.com/cloudflare/cfssl v1.6.4 diff --git a/internal/operator_policy_test.go b/internal/operator_policy_test.go new file mode 100644 index 00000000..d2740f64 --- /dev/null +++ b/internal/operator_policy_test.go @@ -0,0 +1,67 @@ +package internal_test + +import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + topology "github.com/rabbitmq/messaging-topology-operator/api/v1beta1" + . "github.com/rabbitmq/messaging-topology-operator/internal" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +var _ = Describe("GenerateOperatorPolicy", func() { + var p *topology.OperatorPolicy + + BeforeEach(func() { + p = &topology.OperatorPolicy{ + ObjectMeta: metav1.ObjectMeta{ + Name: "new-operatorPolicy", + }, + Spec: topology.OperatorPolicySpec{ + Name: "new-p", + Vhost: "/new-vhost", + ApplyTo: "queues", + Pattern: "queue-name", + Priority: 5, + Definition: &runtime.RawExtension{Raw: []byte(`{"key":"value"}`)}, + }, + } + }) + + It("sets operatorPolicy name according to operatorPolicySpec", func() { + generated, err := GenerateOperatorPolicy(p) + Expect(err).NotTo(HaveOccurred()) + Expect(generated.Name).To(Equal("new-p")) + }) + + It("sets operatorPolicy vhost according to operatorPolicySpec", func() { + generated, err := GenerateOperatorPolicy(p) + Expect(err).NotTo(HaveOccurred()) + Expect(generated.Vhost).To(Equal("/new-vhost")) + }) + + It("sets 'ApplyTo' according to operatorPolicySpec", func() { + generated, err := GenerateOperatorPolicy(p) + Expect(err).NotTo(HaveOccurred()) + Expect(generated.ApplyTo).To(Equal("queues")) + }) + + It("sets 'priority' according to operatorPolicySpec", func() { + generated, err := GenerateOperatorPolicy(p) + Expect(err).NotTo(HaveOccurred()) + Expect(generated.Priority).To(Equal(5)) + }) + + It("sets 'pattern' according to operatorPolicySpec", func() { + generated, err := GenerateOperatorPolicy(p) + Expect(err).NotTo(HaveOccurred()) + Expect(generated.Pattern).To(Equal("queue-name")) + }) + + It("sets definition according to operatorPolicySpec", func() { + generated, err := GenerateOperatorPolicy(p) + Expect(err).NotTo(HaveOccurred()) + Expect(generated.Definition).Should(HaveLen(1)) + Expect(generated.Definition).Should(HaveKeyWithValue("key", "value")) + }) +}) diff --git a/internal/operatorpolicy.go b/internal/operatorpolicy.go new file mode 100644 index 00000000..a926f945 --- /dev/null +++ b/internal/operatorpolicy.go @@ -0,0 +1,34 @@ +/* +RabbitMQ Messaging Topology Kubernetes Operator +Copyright 2021 VMware, Inc. + +This product is licensed to you under the Mozilla Public License 2.0 license (the "License"). You may not use this product except in compliance with the Mozilla 2.0 License. + +This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. +*/ + +package internal + +import ( + "encoding/json" + "fmt" + + rabbithole "github.com/michaelklishin/rabbit-hole/v2" + topology "github.com/rabbitmq/messaging-topology-operator/api/v1beta1" +) + +func GenerateOperatorPolicy(p *topology.OperatorPolicy) (*rabbithole.OperatorPolicy, error) { + definition := make(map[string]interface{}) + if err := json.Unmarshal(p.Spec.Definition.Raw, &definition); err != nil { + return nil, fmt.Errorf("failed to unmarshall policy definition: %v", err) + } + + return &rabbithole.OperatorPolicy{ + Vhost: p.Spec.Vhost, + Pattern: p.Spec.Pattern, + ApplyTo: p.Spec.ApplyTo, + Name: p.Spec.Name, + Priority: p.Spec.Priority, + Definition: definition, + }, nil +} diff --git a/main.go b/main.go index 79dde46d..c1daab14 100644 --- a/main.go +++ b/main.go @@ -268,6 +268,21 @@ func main() { os.Exit(1) } + if err = (&controllers.TopologyReconciler{ + Client: mgr.GetClient(), + Type: &topology.OperatorPolicy{}, + Log: ctrl.Log.WithName(controllers.OperatorPolicyControllerName), + Scheme: mgr.GetScheme(), + Recorder: mgr.GetEventRecorderFor(controllers.OperatorPolicyControllerName), + RabbitmqClientFactory: rabbitmqclient.RabbitholeClientFactory, + KubernetesClusterDomain: clusterDomain, + ReconcileFunc: &controllers.OperatorPolicyReconciler{}, + ConnectUsingPlainHTTP: usePlainHTTP, + }).SetupWithManager(mgr); err != nil { + log.Error(err, "unable to create controller", "controller", controllers.OperatorPolicyControllerName) + os.Exit(1) + } + if err = (&controllers.TopologyReconciler{ Client: mgr.GetClient(), Type: &topology.Permission{}, @@ -375,6 +390,10 @@ func main() { log.Error(err, "unable to create webhook", "webhook", "Policy") os.Exit(1) } + if err = (&topology.OperatorPolicy{}).SetupWebhookWithManager(mgr); err != nil { + log.Error(err, "unable to create webhook", "webhook", "OperatorPolicy") + os.Exit(1) + } if err = (&topology.User{}).SetupWebhookWithManager(mgr); err != nil { log.Error(err, "unable to create webhook", "webhook", "User") os.Exit(1) diff --git a/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/fake/fake_operatorpolicy.go b/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/fake/fake_operatorpolicy.go new file mode 100644 index 00000000..8a5508f6 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/fake/fake_operatorpolicy.go @@ -0,0 +1,134 @@ +/* +RabbitMQ Messaging Topology Kubernetes Operator +Copyright 2021 VMware, Inc. + +This product is licensed to you under the Mozilla Public License 2.0 license (the "License"). You may not use this product except in compliance with the Mozilla 2.0 License. + +This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta1 "github.com/rabbitmq/messaging-topology-operator/api/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeOperatorPolicies implements OperatorPolicyInterface +type FakeOperatorPolicies struct { + Fake *FakeRabbitmqV1beta1 + ns string +} + +var operatorpoliciesResource = v1beta1.SchemeGroupVersion.WithResource("operatorpolicies") + +var operatorpoliciesKind = v1beta1.SchemeGroupVersion.WithKind("OperatorPolicy") + +// Get takes name of the operatorPolicy, and returns the corresponding operatorPolicy object, and an error if there is any. +func (c *FakeOperatorPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.OperatorPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(operatorpoliciesResource, c.ns, name), &v1beta1.OperatorPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.OperatorPolicy), err +} + +// List takes label and field selectors, and returns the list of OperatorPolicies that match those selectors. +func (c *FakeOperatorPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.OperatorPolicyList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(operatorpoliciesResource, operatorpoliciesKind, c.ns, opts), &v1beta1.OperatorPolicyList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.OperatorPolicyList{ListMeta: obj.(*v1beta1.OperatorPolicyList).ListMeta} + for _, item := range obj.(*v1beta1.OperatorPolicyList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested operatorPolicies. +func (c *FakeOperatorPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(operatorpoliciesResource, c.ns, opts)) + +} + +// Create takes the representation of a operatorPolicy and creates it. Returns the server's representation of the operatorPolicy, and an error, if there is any. +func (c *FakeOperatorPolicies) Create(ctx context.Context, operatorPolicy *v1beta1.OperatorPolicy, opts v1.CreateOptions) (result *v1beta1.OperatorPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(operatorpoliciesResource, c.ns, operatorPolicy), &v1beta1.OperatorPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.OperatorPolicy), err +} + +// Update takes the representation of a operatorPolicy and updates it. Returns the server's representation of the operatorPolicy, and an error, if there is any. +func (c *FakeOperatorPolicies) Update(ctx context.Context, operatorPolicy *v1beta1.OperatorPolicy, opts v1.UpdateOptions) (result *v1beta1.OperatorPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(operatorpoliciesResource, c.ns, operatorPolicy), &v1beta1.OperatorPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.OperatorPolicy), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeOperatorPolicies) UpdateStatus(ctx context.Context, operatorPolicy *v1beta1.OperatorPolicy, opts v1.UpdateOptions) (*v1beta1.OperatorPolicy, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(operatorpoliciesResource, "status", c.ns, operatorPolicy), &v1beta1.OperatorPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.OperatorPolicy), err +} + +// Delete takes name of the operatorPolicy and deletes it. Returns an error if one occurs. +func (c *FakeOperatorPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(operatorpoliciesResource, c.ns, name, opts), &v1beta1.OperatorPolicy{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeOperatorPolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(operatorpoliciesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.OperatorPolicyList{}) + return err +} + +// Patch applies the patch and returns the patched operatorPolicy. +func (c *FakeOperatorPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.OperatorPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(operatorpoliciesResource, c.ns, name, pt, data, subresources...), &v1beta1.OperatorPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.OperatorPolicy), err +} diff --git a/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/fake/fake_rabbitmq.com_client.go b/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/fake/fake_rabbitmq.com_client.go index c934eb4d..c49f56b6 100644 --- a/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/fake/fake_rabbitmq.com_client.go +++ b/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/fake/fake_rabbitmq.com_client.go @@ -41,6 +41,10 @@ func (c *FakeRabbitmqV1beta1) Policies(namespace string) v1beta1.PolicyInterface return &FakePolicies{c, namespace} } +func (c *FakeRabbitmqV1beta1) OperatorPolicies(namespace string) v1beta1.OperatorPolicyInterface { + return &FakeOperatorPolicies{c, namespace} +} + func (c *FakeRabbitmqV1beta1) Queues(namespace string) v1beta1.QueueInterface { return &FakeQueues{c, namespace} } diff --git a/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/generated_expansion.go index ffcd0167..2471ed92 100644 --- a/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/generated_expansion.go @@ -21,6 +21,8 @@ type PermissionExpansion interface{} type PolicyExpansion interface{} +type OperatorPolicyExpansion interface{} + type QueueExpansion interface{} type SchemaReplicationExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/operatorpolicy.go b/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/operatorpolicy.go new file mode 100644 index 00000000..89c5a91e --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/operatorpolicy.go @@ -0,0 +1,188 @@ +/* +RabbitMQ Messaging Topology Kubernetes Operator +Copyright 2021 VMware, Inc. + +This product is licensed to you under the Mozilla Public License 2.0 license (the "License"). You may not use this product except in compliance with the Mozilla 2.0 License. + +This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + v1beta1 "github.com/rabbitmq/messaging-topology-operator/api/v1beta1" + scheme "github.com/rabbitmq/messaging-topology-operator/pkg/generated/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// OperatorPoliciesGetter has a method to return a OperatorPolicyInterface. +// A group's client should implement this interface. +type OperatorPoliciesGetter interface { + OperatorPolicies(namespace string) OperatorPolicyInterface +} + +// OperatorPolicyInterface has methods to work with OperatorPolicy resources. +type OperatorPolicyInterface interface { + Create(ctx context.Context, operatorPolicy *v1beta1.OperatorPolicy, opts v1.CreateOptions) (*v1beta1.OperatorPolicy, error) + Update(ctx context.Context, operatorPolicy *v1beta1.OperatorPolicy, opts v1.UpdateOptions) (*v1beta1.OperatorPolicy, error) + UpdateStatus(ctx context.Context, operatorPolicy *v1beta1.OperatorPolicy, opts v1.UpdateOptions) (*v1beta1.OperatorPolicy, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.OperatorPolicy, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.OperatorPolicyList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.OperatorPolicy, err error) + OperatorPolicyExpansion +} + +// operatorPolicies implements OperatorPolicyInterface +type operatorPolicies struct { + client rest.Interface + ns string +} + +// newOperatorPolicies returns a OperatorPolicies +func newOperatorPolicies(c *RabbitmqV1beta1Client, namespace string) *operatorPolicies { + return &operatorPolicies{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the operatorPolicy, and returns the corresponding operatorPolicy object, and an error if there is any. +func (c *operatorPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.OperatorPolicy, err error) { + result = &v1beta1.OperatorPolicy{} + err = c.client.Get(). + Namespace(c.ns). + Resource("operatorpolicies"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of OperatorPolicies that match those selectors. +func (c *operatorPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.OperatorPolicyList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.OperatorPolicyList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("operatorpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested operatorPolicies. +func (c *operatorPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("operatorpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a operatorPolicy and creates it. Returns the server's representation of the operatorPolicy, and an error, if there is any. +func (c *operatorPolicies) Create(ctx context.Context, operatorPolicy *v1beta1.OperatorPolicy, opts v1.CreateOptions) (result *v1beta1.OperatorPolicy, err error) { + result = &v1beta1.OperatorPolicy{} + err = c.client.Post(). + Namespace(c.ns). + Resource("operatorpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(operatorPolicy). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a operatorPolicy and updates it. Returns the server's representation of the operatorPolicy, and an error, if there is any. +func (c *operatorPolicies) Update(ctx context.Context, operatorPolicy *v1beta1.OperatorPolicy, opts v1.UpdateOptions) (result *v1beta1.OperatorPolicy, err error) { + result = &v1beta1.OperatorPolicy{} + err = c.client.Put(). + Namespace(c.ns). + Resource("operatorpolicies"). + Name(operatorPolicy.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(operatorPolicy). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *operatorPolicies) UpdateStatus(ctx context.Context, operatorPolicy *v1beta1.OperatorPolicy, opts v1.UpdateOptions) (result *v1beta1.OperatorPolicy, err error) { + result = &v1beta1.OperatorPolicy{} + err = c.client.Put(). + Namespace(c.ns). + Resource("operatorpolicies"). + Name(operatorPolicy.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(operatorPolicy). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the operatorPolicy and deletes it. Returns an error if one occurs. +func (c *operatorPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("operatorpolicies"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *operatorPolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("operatorpolicies"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched operatorPolicy. +func (c *operatorPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.OperatorPolicy, err error) { + result = &v1beta1.OperatorPolicy{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("operatorpolicies"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/rabbitmq.com_client.go b/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/rabbitmq.com_client.go index 8479f97b..cfb1bd34 100644 --- a/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/rabbitmq.com_client.go +++ b/pkg/generated/clientset/versioned/typed/rabbitmq.com/v1beta1/rabbitmq.com_client.go @@ -26,6 +26,7 @@ type RabbitmqV1beta1Interface interface { FederationsGetter PermissionsGetter PoliciesGetter + OperatorPoliciesGetter QueuesGetter SchemaReplicationsGetter ShovelsGetter @@ -58,6 +59,10 @@ func (c *RabbitmqV1beta1Client) Policies(namespace string) PolicyInterface { return newPolicies(c, namespace) } +func (c *RabbitmqV1beta1Client) OperatorPolicies(namespace string) OperatorPolicyInterface { + return newOperatorPolicies(c, namespace) +} + func (c *RabbitmqV1beta1Client) Queues(namespace string) QueueInterface { return newQueues(c, namespace) } diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index d8add53c..06d50649 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -57,6 +57,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Rabbitmq().V1beta1().Exchanges().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("federations"): return &genericInformer{resource: resource.GroupResource(), informer: f.Rabbitmq().V1beta1().Federations().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("operatorpolicies"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Rabbitmq().V1beta1().OperatorPolicies().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("permissions"): return &genericInformer{resource: resource.GroupResource(), informer: f.Rabbitmq().V1beta1().Permissions().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("policies"): diff --git a/pkg/generated/informers/externalversions/rabbitmq.com/v1beta1/interface.go b/pkg/generated/informers/externalversions/rabbitmq.com/v1beta1/interface.go index db7dbfdf..e37eb1e7 100644 --- a/pkg/generated/informers/externalversions/rabbitmq.com/v1beta1/interface.go +++ b/pkg/generated/informers/externalversions/rabbitmq.com/v1beta1/interface.go @@ -23,6 +23,8 @@ type Interface interface { Exchanges() ExchangeInformer // Federations returns a FederationInformer. Federations() FederationInformer + // OperatorPolicies returns a OperatorPolicyInformer. + OperatorPolicies() OperatorPolicyInformer // Permissions returns a PermissionInformer. Permissions() PermissionInformer // Policies returns a PolicyInformer. @@ -65,6 +67,11 @@ func (v *version) Federations() FederationInformer { return &federationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// OperatorPolicies returns a OperatorPolicyInformer. +func (v *version) OperatorPolicies() OperatorPolicyInformer { + return &operatorPolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // Permissions returns a PermissionInformer. func (v *version) Permissions() PermissionInformer { return &permissionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/generated/informers/externalversions/rabbitmq.com/v1beta1/operatorpolicy.go b/pkg/generated/informers/externalversions/rabbitmq.com/v1beta1/operatorpolicy.go new file mode 100644 index 00000000..f74b3f83 --- /dev/null +++ b/pkg/generated/informers/externalversions/rabbitmq.com/v1beta1/operatorpolicy.go @@ -0,0 +1,83 @@ +/* +RabbitMQ Messaging Topology Kubernetes Operator +Copyright 2021 VMware, Inc. + +This product is licensed to you under the Mozilla Public License 2.0 license (the "License"). You may not use this product except in compliance with the Mozilla 2.0 License. + +This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + time "time" + + rabbitmqcomv1beta1 "github.com/rabbitmq/messaging-topology-operator/api/v1beta1" + versioned "github.com/rabbitmq/messaging-topology-operator/pkg/generated/clientset/versioned" + internalinterfaces "github.com/rabbitmq/messaging-topology-operator/pkg/generated/informers/externalversions/internalinterfaces" + v1beta1 "github.com/rabbitmq/messaging-topology-operator/pkg/generated/listers/rabbitmq.com/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// OperatorPolicyInformer provides access to a shared informer and lister for +// OperatorPolicies. +type OperatorPolicyInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.OperatorPolicyLister +} + +type operatorPolicyInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewOperatorPolicyInformer constructs a new informer for OperatorPolicy type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewOperatorPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredOperatorPolicyInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredOperatorPolicyInformer constructs a new informer for OperatorPolicy type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredOperatorPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.RabbitmqV1beta1().OperatorPolicies(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.RabbitmqV1beta1().OperatorPolicies(namespace).Watch(context.TODO(), options) + }, + }, + &rabbitmqcomv1beta1.OperatorPolicy{}, + resyncPeriod, + indexers, + ) +} + +func (f *operatorPolicyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredOperatorPolicyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *operatorPolicyInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&rabbitmqcomv1beta1.OperatorPolicy{}, f.defaultInformer) +} + +func (f *operatorPolicyInformer) Lister() v1beta1.OperatorPolicyLister { + return v1beta1.NewOperatorPolicyLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/listers/rabbitmq.com/v1beta1/expansion_generated.go b/pkg/generated/listers/rabbitmq.com/v1beta1/expansion_generated.go index fb354b3d..85fdec6f 100644 --- a/pkg/generated/listers/rabbitmq.com/v1beta1/expansion_generated.go +++ b/pkg/generated/listers/rabbitmq.com/v1beta1/expansion_generated.go @@ -35,6 +35,14 @@ type FederationListerExpansion interface{} // FederationNamespaceLister. type FederationNamespaceListerExpansion interface{} +// OperatorPolicyListerExpansion allows custom methods to be added to +// OperatorPolicyLister. +type OperatorPolicyListerExpansion interface{} + +// OperatorPolicyNamespaceListerExpansion allows custom methods to be added to +// OperatorPolicyNamespaceLister. +type OperatorPolicyNamespaceListerExpansion interface{} + // PermissionListerExpansion allows custom methods to be added to // PermissionLister. type PermissionListerExpansion interface{} diff --git a/pkg/generated/listers/rabbitmq.com/v1beta1/operatorpolicy.go b/pkg/generated/listers/rabbitmq.com/v1beta1/operatorpolicy.go new file mode 100644 index 00000000..4942355d --- /dev/null +++ b/pkg/generated/listers/rabbitmq.com/v1beta1/operatorpolicy.go @@ -0,0 +1,92 @@ +/* +RabbitMQ Messaging Topology Kubernetes Operator +Copyright 2021 VMware, Inc. + +This product is licensed to you under the Mozilla Public License 2.0 license (the "License"). You may not use this product except in compliance with the Mozilla 2.0 License. + +This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/rabbitmq/messaging-topology-operator/api/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// OperatorPolicyLister helps list OperatorPolicies. +// All objects returned here must be treated as read-only. +type OperatorPolicyLister interface { + // List lists all OperatorPolicies in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.OperatorPolicy, err error) + // OperatorPolicies returns an object that can list and get OperatorPolicies. + OperatorPolicies(namespace string) OperatorPolicyNamespaceLister + OperatorPolicyListerExpansion +} + +// operatorPolicyLister implements the OperatorPolicyLister interface. +type operatorPolicyLister struct { + indexer cache.Indexer +} + +// NewOperatorPolicyLister returns a new OperatorPolicyLister. +func NewOperatorPolicyLister(indexer cache.Indexer) OperatorPolicyLister { + return &operatorPolicyLister{indexer: indexer} +} + +// List lists all OperatorPolicies in the indexer. +func (s *operatorPolicyLister) List(selector labels.Selector) (ret []*v1beta1.OperatorPolicy, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.OperatorPolicy)) + }) + return ret, err +} + +// OperatorPolicies returns an object that can list and get OperatorPolicies. +func (s *operatorPolicyLister) OperatorPolicies(namespace string) OperatorPolicyNamespaceLister { + return operatorPolicyNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// OperatorPolicyNamespaceLister helps list and get OperatorPolicies. +// All objects returned here must be treated as read-only. +type OperatorPolicyNamespaceLister interface { + // List lists all OperatorPolicies in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.OperatorPolicy, err error) + // Get retrieves the OperatorPolicy from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta1.OperatorPolicy, error) + OperatorPolicyNamespaceListerExpansion +} + +// operatorPolicyNamespaceLister implements the OperatorPolicyNamespaceLister +// interface. +type operatorPolicyNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all OperatorPolicies in the indexer for a given namespace. +func (s operatorPolicyNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.OperatorPolicy, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.OperatorPolicy)) + }) + return ret, err +} + +// Get retrieves the OperatorPolicy from the indexer for a given namespace and name. +func (s operatorPolicyNamespaceLister) Get(name string) (*v1beta1.OperatorPolicy, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("operatorpolicy"), name) + } + return obj.(*v1beta1.OperatorPolicy), nil +} diff --git a/system_tests/operatorpolicy_system_test.go b/system_tests/operatorpolicy_system_test.go new file mode 100644 index 00000000..a47e8a1d --- /dev/null +++ b/system_tests/operatorpolicy_system_test.go @@ -0,0 +1,120 @@ +package system_tests + +import ( + "context" + + rabbithole "github.com/michaelklishin/rabbit-hole/v2" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gstruct" + + topology "github.com/rabbitmq/messaging-topology-operator/api/v1beta1" +) + +var _ = Describe("OperatorPolicy", func() { + var ( + namespace = MustHaveEnv("NAMESPACE") + ctx = context.Background() + policy *topology.OperatorPolicy + ) + + BeforeEach(func() { + policy = &topology.OperatorPolicy{ + ObjectMeta: metav1.ObjectMeta{ + Name: "operator-policy-test", + Namespace: namespace, + }, + Spec: topology.OperatorPolicySpec{ + RabbitmqClusterReference: topology.RabbitmqClusterReference{ + Name: rmq.Name, + }, + Name: "operator-policy-test", + Pattern: "test-queue", + ApplyTo: "queues", + Definition: &runtime.RawExtension{ + Raw: []byte(`{"ha-mode":"all"}`), + }, + }, + } + }) + + It("creates, updates and deletes an operator policy successfully", func() { + By("creating operator policy") + Expect(k8sClient.Create(ctx, policy, &client.CreateOptions{})).To(Succeed()) + var fetchedPolicy *rabbithole.OperatorPolicy + Eventually(func() error { + var err error + fetchedPolicy, err = rabbitClient.GetOperatorPolicy(policy.Spec.Vhost, policy.Name) + return err + }, 10, 2).Should(BeNil()) + + Expect(*fetchedPolicy).To(MatchFields(IgnoreExtras, Fields{ + "Name": Equal(policy.Spec.Name), + "Vhost": Equal(policy.Spec.Vhost), + "Pattern": Equal("test-queue"), + "ApplyTo": Equal("queues"), + "Priority": Equal(0), + })) + + Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("ha-mode", "all")) + + By("updating status condition 'Ready'") + updatedPolicy := topology.OperatorPolicy{} + + Eventually(func() []topology.Condition { + Expect(k8sClient.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, &updatedPolicy)).To(Succeed()) + return updatedPolicy.Status.Conditions + }, waitUpdatedStatusCondition, 2).Should(HaveLen(1), "OperatorPolicy status condition should be present") + + readyCondition := updatedPolicy.Status.Conditions[0] + Expect(string(readyCondition.Type)).To(Equal("Ready")) + Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue)) + Expect(readyCondition.Reason).To(Equal("SuccessfulCreateOrUpdate")) + Expect(readyCondition.LastTransitionTime).NotTo(Equal(metav1.Time{})) + + By("setting correct finalizer") + Expect(updatedPolicy.ObjectMeta.Finalizers).To(ConsistOf("deletion.finalizers.operatorpolicies.rabbitmq.com")) + + By("setting status.observedGeneration") + Expect(updatedPolicy.Status.ObservedGeneration).To(Equal(updatedPolicy.GetGeneration())) + + By("not allowing updates on certain fields") + updateTest := topology.OperatorPolicy{} + Expect(k8sClient.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, &updateTest)).To(Succeed()) + updateTest.Spec.Vhost = "/a-new-vhost" + Expect(k8sClient.Update(ctx, &updateTest).Error()).To(ContainSubstring("spec.vhost: Forbidden: updates on name, vhost and rabbitmqClusterReference are all forbidden")) + + By("updating operator policy definitions successfully") + Expect(k8sClient.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, policy)).To(Succeed()) + policy.Spec.Definition = &runtime.RawExtension{ + Raw: []byte(`{"ha-mode":"exactly", +"ha-params": 2 +}`)} + Expect(k8sClient.Update(ctx, policy, &client.UpdateOptions{})).To(Succeed()) + + Eventually(func() rabbithole.PolicyDefinition { + var err error + fetchedPolicy, err = rabbitClient.GetOperatorPolicy(policy.Spec.Vhost, policy.Name) + Expect(err).NotTo(HaveOccurred()) + return fetchedPolicy.Definition + }, 10, 2).Should(HaveLen(2)) + + Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("ha-mode", "exactly")) + Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("ha-params", float64(2))) + + By("deleting policy") + Expect(k8sClient.Delete(ctx, policy)).To(Succeed()) + var err error + Eventually(func() error { + _, err = rabbitClient.GetOperatorPolicy(policy.Spec.Vhost, policy.Name) + return err + }, 10).Should(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("Object Not Found")) + }) +}) diff --git a/system_tests/user_system_test.go b/system_tests/user_system_test.go index eac82ad2..b4ae859b 100644 --- a/system_tests/user_system_test.go +++ b/system_tests/user_system_test.go @@ -211,7 +211,7 @@ var _ = Describe("Users", func() { Expect(k8sClient.Create(ctx, &credentialSecret, &client.CreateOptions{})).To(Succeed()) user = &topology.User{ ObjectMeta: metav1.ObjectMeta{ - Name: "user-2", + Name: "user-3", Namespace: namespace, }, Spec: topology.UserSpec{ @@ -235,7 +235,7 @@ var _ = Describe("Users", func() { By("Creating a new Secret with the provided credentials secret") generatedSecretKey := types.NamespacedName{ - Name: "user-2-user-credentials", + Name: "user-3-user-credentials", Namespace: namespace, } var generatedSecret = &corev1.Secret{}