Skip to content

Commit

Permalink
Merge pull request #83 from rabbitmq/rmqReference
Browse files Browse the repository at this point in the history
RabbitmqClusterReference reference a cluster in the same namespace as the created CR
  • Loading branch information
ChunyiLyu authored Mar 24, 2021
2 parents 9b10d40 + 2d58cc6 commit 4ebe74b
Show file tree
Hide file tree
Showing 81 changed files with 458 additions and 533 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ manifests: install-tools
# Generate API reference documentation
api-reference:
crd-ref-docs \
--source-path ./api/v1alpha1 \
--source-path ./api/v1alpha2 \
--config ./docs/api/autogen/config.yaml \
--templates-dir ./docs/api/autogen/templates \
--output-path ./docs/api/rabbitmq.com.ref.asciidoc \
Expand Down
12 changes: 6 additions & 6 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ repo: github.com/rabbitmq/messaging-topology-operator
resources:
- group: rabbitmq.com
kind: Queue
version: v1alpha1
version: v1alpha2
- group: rabbitmq.com
kind: Exchange
version: v1alpha1
version: v1alpha2
- group: rabbitmq.com
kind: Binding
version: v1alpha1
version: v1alpha2
- group: rabbitmq.com
kind: User
version: v1alpha1
version: v1alpha2
- group: rabbitmq.com
kind: Vhost
version: v1alpha1
version: v1alpha2
- group: rabbitmq.com
kind: Policy
version: v1alpha1
version: v1alpha2
version: "2"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This product is licensed to you under the Mozilla Public License 2.0 license (th
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 v1alpha1
package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
"context"
Expand All @@ -19,8 +19,7 @@ var _ = Describe("Binding spec", func() {
expectedSpec := BindingSpec{
Vhost: "/",
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "some-cluster",
Namespace: namespace,
Name: "some-cluster",
},
}

Expand All @@ -31,8 +30,7 @@ var _ = Describe("Binding spec", func() {
},
Spec: BindingSpec{
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "some-cluster",
Namespace: namespace,
Name: "some-cluster",
},
},
}
Expand Down Expand Up @@ -61,8 +59,7 @@ var _ = Describe("Binding spec", func() {
Raw: []byte(`{"argument":"argument-value"}`),
},
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "random-cluster",
Namespace: namespace,
Name: "random-cluster",
},
},
}
Expand All @@ -80,8 +77,7 @@ var _ = Describe("Binding spec", func() {
Expect(fetchedBinding.Spec.RoutingKey).To(Equal("akey"))
Expect(fetchedBinding.Spec.RabbitmqClusterReference).To(Equal(
RabbitmqClusterReference{
Name: "random-cluster",
Namespace: namespace,
Name: "random-cluster",
}))
Expect(fetchedBinding.Spec.Arguments.Raw).To(Equal([]byte(`{"argument":"argument-value"}`)))
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
"fmt"
Expand All @@ -16,7 +16,7 @@ func (b *Binding) SetupWebhookWithManager(mgr ctrl.Manager) error {
Complete()
}

// +kubebuilder:webhook:verbs=create;update,path=/validate-rabbitmq-com-v1alpha1-binding,mutating=false,failurePolicy=fail,groups=rabbitmq.com,resources=bindings,versions=v1alpha1,name=vbinding.kb.io,sideEffects=none,admissionReviewVersions=v1
// +kubebuilder:webhook:verbs=create;update,path=/validate-rabbitmq-com-v1alpha2-binding,mutating=false,failurePolicy=fail,groups=rabbitmq.com,resources=bindings,versions=v1alpha2,name=vbinding.kb.io,sideEffects=none,admissionReviewVersions=v1

var _ webhook.Validator = &Binding{}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
. "github.com/onsi/ginkgo"
Expand All @@ -20,8 +20,7 @@ var _ = Describe("Binding webhook", func() {
Destination: "test",
DestinationType: "queue",
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "some-cluster",
Namespace: "default",
Name: "some-cluster",
},
},
}
Expand All @@ -35,8 +34,7 @@ var _ = Describe("Binding webhook", func() {
It("does not allow updates on RabbitmqClusterReference", func() {
newBinding := oldBinding.DeepCopy()
newBinding.Spec.RabbitmqClusterReference = RabbitmqClusterReference{
Name: "new-cluster",
Namespace: "default",
Name: "new-cluster",
}
Expect(apierrors.IsForbidden(newBinding.ValidateUpdate(&oldBinding))).To(BeTrue())
})
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/conditions.go → api/v1alpha2/conditions.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
corev1 "k8s.io/api/core/v1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
. "github.com/onsi/ginkgo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This product is licensed to you under the Mozilla Public License 2.0 license (th
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 v1alpha1
package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
"context"
Expand All @@ -23,8 +23,7 @@ var _ = Describe("Exchange spec", func() {
AutoDelete: false,
Type: "direct",
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "some-cluster",
Namespace: namespace,
Name: "some-cluster",
},
}

Expand All @@ -36,8 +35,7 @@ var _ = Describe("Exchange spec", func() {
Spec: ExchangeSpec{
Name: "test-exchange",
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "some-cluster",
Namespace: namespace,
Name: "some-cluster",
},
},
}
Expand Down Expand Up @@ -66,8 +64,7 @@ var _ = Describe("Exchange spec", func() {
Raw: []byte(`{"alternative-exchange":"alternative-name"}`),
},
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "random-cluster",
Namespace: namespace,
Name: "random-cluster",
},
},
}
Expand All @@ -85,8 +82,7 @@ var _ = Describe("Exchange spec", func() {
Expect(fetchedExchange.Spec.AutoDelete).To(BeTrue())
Expect(fetchedExchange.Spec.RabbitmqClusterReference).To(Equal(
RabbitmqClusterReference{
Name: "random-cluster",
Namespace: namespace,
Name: "random-cluster",
}))
Expect(fetchedExchange.Spec.Arguments.Raw).To(Equal([]byte(`{"alternative-exchange":"alternative-name"}`)))
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
"fmt"
Expand All @@ -15,7 +15,7 @@ func (r *Exchange) SetupWebhookWithManager(mgr ctrl.Manager) error {
Complete()
}

// +kubebuilder:webhook:verbs=create;update,path=/validate-rabbitmq-com-v1alpha1-exchange,mutating=false,failurePolicy=fail,groups=rabbitmq.com,resources=exchanges,versions=v1alpha1,name=vexchange.kb.io,sideEffects=none,admissionReviewVersions=v1
// +kubebuilder:webhook:verbs=create;update,path=/validate-rabbitmq-com-v1alpha2-exchange,mutating=false,failurePolicy=fail,groups=rabbitmq.com,resources=exchanges,versions=v1alpha2,name=vexchange.kb.io,sideEffects=none,admissionReviewVersions=v1

var _ webhook.Validator = &Exchange{}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
. "github.com/onsi/ginkgo"
Expand All @@ -21,8 +21,7 @@ var _ = Describe("exchange webhook", func() {
Durable: false,
AutoDelete: true,
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "some-cluster",
Namespace: "default",
Name: "some-cluster",
},
},
}
Expand All @@ -42,8 +41,7 @@ var _ = Describe("exchange webhook", func() {
It("does not allow updates on RabbitmqClusterReference", func() {
newExchange := exchange.DeepCopy()
newExchange.Spec.RabbitmqClusterReference = RabbitmqClusterReference{
Name: "new-cluster",
Namespace: "default",
Name: "new-cluster",
}
Expect(apierrors.IsForbidden(newExchange.ValidateUpdate(&exchange))).To(BeTrue())
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ This product is licensed to you under the Mozilla Public License 2.0 license (th
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 v1alpha1 contains API Schema definitions for the rabbitmq.com v1alpha1 API group
// Package v1alpha2 contains API Schema definitions for the rabbitmq.com v1alpha2 API group
// +kubebuilder:object:generate=true
// +groupName=rabbitmq.com
package v1alpha1
package v1alpha2

import (
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -19,7 +19,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "rabbitmq.com", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "rabbitmq.com", Version: "v1alpha2"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
"context"
Expand Down Expand Up @@ -29,8 +29,7 @@ var _ = Describe("Policy", func() {
Raw: []byte(`{"key":"value"}`),
},
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "some-cluster",
Namespace: namespace,
Name: "some-cluster",
},
},
}
Expand All @@ -41,8 +40,7 @@ var _ = Describe("Policy", func() {
Namespace: policy.Namespace,
}, fetched)).To(Succeed())
Expect(fetched.Spec.RabbitmqClusterReference).To(Equal(RabbitmqClusterReference{
Name: "some-cluster",
Namespace: namespace,
Name: "some-cluster",
}))
Expect(fetched.Spec.Name).To(Equal("test-policy"))
Expect(fetched.Spec.Vhost).To(Equal("/"))
Expand All @@ -68,8 +66,7 @@ var _ = Describe("Policy", func() {
Raw: []byte(`{"key":"value"}`),
},
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "random-cluster",
Namespace: namespace,
Name: "random-cluster",
},
},
}
Expand All @@ -87,8 +84,7 @@ var _ = Describe("Policy", func() {
Expect(fetched.Spec.Priority).To(Equal(100))
Expect(fetched.Spec.RabbitmqClusterReference).To(Equal(
RabbitmqClusterReference{
Name: "random-cluster",
Namespace: namespace,
Name: "random-cluster",
}))
Expect(fetched.Spec.Definition.Raw).To(Equal([]byte(`{"key":"value"}`)))
})
Expand All @@ -108,8 +104,7 @@ var _ = Describe("Policy", func() {
},
ApplyTo: "yo-yo",
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "some-cluster",
Namespace: namespace,
Name: "some-cluster",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
"fmt"
Expand All @@ -15,7 +15,7 @@ func (p *Policy) SetupWebhookWithManager(mgr ctrl.Manager) error {
Complete()
}

// +kubebuilder:webhook:verbs=create;update,path=/validate-rabbitmq-com-v1alpha1-policy,mutating=false,failurePolicy=fail,groups=rabbitmq.com,resources=policies,versions=v1alpha1,name=vpolicy.kb.io,sideEffects=none,admissionReviewVersions=v1
// +kubebuilder:webhook:verbs=create;update,path=/validate-rabbitmq-com-v1alpha2-policy,mutating=false,failurePolicy=fail,groups=rabbitmq.com,resources=policies,versions=v1alpha2,name=vpolicy.kb.io,sideEffects=none,admissionReviewVersions=v1

var _ webhook.Validator = &Policy{}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1alpha2

import (
. "github.com/onsi/ginkgo"
Expand All @@ -20,8 +20,7 @@ var _ = Describe("policy webhook", func() {
ApplyTo: "all",
Priority: 0,
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "a-cluster",
Namespace: "default",
Name: "a-cluster",
},
},
}
Expand All @@ -41,8 +40,7 @@ var _ = Describe("policy webhook", func() {
It("does not allow updates on RabbitmqClusterReference", func() {
newPolicy := policy.DeepCopy()
newPolicy.Spec.RabbitmqClusterReference = RabbitmqClusterReference{
Name: "new-cluster",
Namespace: "default",
Name: "new-cluster",
}
Expect(apierrors.IsForbidden(newPolicy.ValidateUpdate(&policy))).To(BeTrue())
})
Expand Down
4 changes: 1 addition & 3 deletions api/v1alpha1/queue_types.go → api/v1alpha2/queue_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This product is licensed to you under the Mozilla Public License 2.0 license (th
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 v1alpha1
package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -45,8 +45,6 @@ type QueueSpec struct {
type RabbitmqClusterReference struct {
// +kubebuilder:validation:Required
Name string `json:"name"`
// +kubebuilder:validation:Required
Namespace string `json:"namespace"`
}

// QueueStatus defines the observed state of Queue
Expand Down
Loading

0 comments on commit 4ebe74b

Please sign in to comment.