Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions docs/spec/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ its subscribers._

| Field | Type | Description | Constraints |
| ------------- | ---------------------------------- | -------------------------------------------------------------------------- | -------------------------------------- |
| provisioner\* | ProvisionerReference | The name of the provisioner to create the resources that back the Channel. | Immutable. |
| provisioner\* | ObjectReference | The name of the provisioner to create the resources that back the Channel. | Immutable. |
| arguments | runtime.RawExtension (JSON object) | Arguments to be passed to the provisioner. | |
| subscribers | ChannelSubscriberSpec[] | Information about subscriptions used to implement message forwarding. | Filled out by Subscription Controller. |

Expand Down Expand Up @@ -125,9 +125,9 @@ or a Channel system that receives and delivers events._

#### Spec

| Field | Type | Description | Constraints |
| ---------- | ---------------------------------- | ------------------------------------------------------------------------------------------------- | ---------------- |
| parameters | runtime.RawExtension (JSON object) | Description of the arguments able to be passed by the provisioned resource (not enforced in 0.1). | JSON Schema |
| Field | Type | Description | Constraints |
| ---------- | ---------------------------------- | ------------------------------------------------------------------------------------------------- | ----------- |
| parameters | runtime.RawExtension (JSON object) | Description of the arguments able to be passed by the provisioned resource (not enforced in 0.1). | JSON Schema |

\*: Required

Expand All @@ -150,14 +150,6 @@ or a Channel system that receives and delivers events._

## Shared Object Schema

### ProvisionerReference

| Field | Type | Description | Constraints |
| ----- | --------------- | ----------- | ----------- |
| ref\* | ObjectReference | | |

\*: Required

### EndpointSpec

| Field | Type | Description | Constraints |
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/eventing/v1alpha1/channel_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/knative/pkg/apis"
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
"github.com/knative/pkg/webhook"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down Expand Up @@ -64,8 +65,7 @@ type ChannelSpec struct {
Generation int64 `json:"generation,omitempty"`

// Provisioner defines the name of the Provisioner backing this channel.
// TODO: +optional If missing, a default Provisioner may be selected for the Channel.
Provisioner *ProvisionerReference `json:"provisioner,omitempty"`
Provisioner *corev1.ObjectReference `json:"provisioner,omitempty"`

// Arguments defines the arguments to pass to the Provisioner which provisions
// this Channel.
Expand Down
72 changes: 24 additions & 48 deletions pkg/apis/eventing/v1alpha1/channel_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ func TestChannelValidation(t *testing.T) {
name: "valid",
cr: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "foo",
},
Provisioner: &corev1.ObjectReference{
Name: "foo",
},
},
},
Expand All @@ -51,10 +49,8 @@ func TestChannelValidation(t *testing.T) {
name: "subscribers array",
cr: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "foo",
},
Provisioner: &corev1.ObjectReference{
Name: "foo",
},
Channelable: &eventingduck.Channelable{
Subscribers: []eventingduck.ChannelSubscriberSpec{{
Expand All @@ -68,10 +64,8 @@ func TestChannelValidation(t *testing.T) {
name: "empty subscriber at index 1",
cr: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "foo",
},
Provisioner: &corev1.ObjectReference{
Name: "foo",
},
Channelable: &eventingduck.Channelable{
Subscribers: []eventingduck.ChannelSubscriberSpec{{
Expand All @@ -89,10 +83,8 @@ func TestChannelValidation(t *testing.T) {
name: "2 empty subscribers",
cr: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "foo",
},
Provisioner: &corev1.ObjectReference{
Name: "foo",
},
Channelable: &eventingduck.Channelable{
Subscribers: []eventingduck.ChannelSubscriberSpec{{}, {}},
Expand Down Expand Up @@ -124,10 +116,8 @@ func TestChannelImmutableFields(t *testing.T) {
name: "good (new)",
new: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "foo",
},
Provisioner: &corev1.ObjectReference{
Name: "foo",
},
},
},
Expand All @@ -137,19 +127,15 @@ func TestChannelImmutableFields(t *testing.T) {
name: "good (no change)",
new: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "foo",
},
Provisioner: &corev1.ObjectReference{
Name: "foo",
},
},
},
old: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "foo",
},
Provisioner: &corev1.ObjectReference{
Name: "foo",
},
},
},
Expand All @@ -158,10 +144,8 @@ func TestChannelImmutableFields(t *testing.T) {
name: "good (arguments change)",
new: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "foo",
},
Provisioner: &corev1.ObjectReference{
Name: "foo",
},
Arguments: &runtime.RawExtension{
Raw: []byte("\"foo\":\"bar\""),
Expand All @@ -170,10 +154,8 @@ func TestChannelImmutableFields(t *testing.T) {
},
old: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "foo",
},
Provisioner: &corev1.ObjectReference{
Name: "foo",
},
Arguments: &runtime.RawExtension{
Raw: []byte(`{"foo":"baz"}`),
Expand All @@ -185,10 +167,8 @@ func TestChannelImmutableFields(t *testing.T) {
name: "bad (not channel)",
new: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "foo",
},
Provisioner: &corev1.ObjectReference{
Name: "foo",
},
},
},
Expand All @@ -200,19 +180,15 @@ func TestChannelImmutableFields(t *testing.T) {
name: "bad (provisioner changes)",
new: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "foo",
},
Provisioner: &corev1.ObjectReference{
Name: "foo",
},
},
},
old: &Channel{
Spec: ChannelSpec{
Provisioner: &ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "bar",
},
Provisioner: &corev1.ObjectReference{
Name: "bar",
},
},
},
Expand Down
29 changes: 0 additions & 29 deletions pkg/apis/eventing/v1alpha1/provisioner_reference.go

This file was deleted.

29 changes: 2 additions & 27 deletions pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/controller/eventing/inmemory/channel/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (r *reconciler) createVirtualService(ctx context.Context, c *eventingv1alph
func newK8sService(c *eventingv1alpha1.Channel) *corev1.Service {
labels := map[string]string{
"channel": c.Name,
"provisioner": c.Spec.Provisioner.Ref.Name,
"provisioner": c.Spec.Provisioner.Name,
}
return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -272,9 +272,9 @@ func newK8sService(c *eventingv1alpha1.Channel) *corev1.Service {
func newVirtualService(channel *eventingv1alpha1.Channel) *istiov1alpha3.VirtualService {
labels := map[string]string{
"channel": channel.Name,
"provisioner": channel.Spec.Provisioner.Ref.Name,
"provisioner": channel.Spec.Provisioner.Name,
}
destinationHost := controller.ServiceHostName(controller.ClusterBusDispatcherServiceName(channel.Spec.Provisioner.Ref.Name), system.Namespace)
destinationHost := controller.ServiceHostName(controller.ClusterBusDispatcherServiceName(channel.Spec.Provisioner.Name), system.Namespace)
return &istiov1alpha3.VirtualService{
ObjectMeta: metav1.ObjectMeta{
Name: controller.ChannelVirtualServiceName(channel.Name),
Expand Down
36 changes: 11 additions & 25 deletions pkg/controller/eventing/inmemory/channel/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,8 @@ var (
Kind: "Channel",
},
Spec: eventingv1alpha1.ChannelSpec{
Provisioner: &eventingv1alpha1.ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: ccpName,
},
Provisioner: &corev1.ObjectReference{
Name: ccpName,
},
Channelable: &eventingduck.Channelable{
Subscribers: []eventingduck.ChannelSubscriberSpec{
Expand All @@ -141,10 +139,8 @@ var (
Kind: "Channel",
},
Spec: eventingv1alpha1.ChannelSpec{
Provisioner: &eventingv1alpha1.ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: "some-other-provisioner",
},
Provisioner: &corev1.ObjectReference{
Name: "some-other-provisioner",
},
Channelable: &eventingduck.Channelable{
Subscribers: []eventingduck.ChannelSubscriberSpec{
Expand All @@ -164,10 +160,8 @@ var (
Kind: "Channel",
},
Spec: eventingv1alpha1.ChannelSpec{
Provisioner: &eventingv1alpha1.ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: ccpName,
},
Provisioner: &corev1.ObjectReference{
Name: ccpName,
},
Channelable: &eventingduck.Channelable{
Subscribers: []eventingduck.ChannelSubscriberSpec{
Expand Down Expand Up @@ -225,7 +219,7 @@ func TestReconcile(t *testing.T) {
{
Name: "Channel not reconciled - nil ref",
InitialState: []runtime.Object{
makeChannelNilRef(),
makeChannelNilProvisioner(),
},
},
{
Expand Down Expand Up @@ -472,10 +466,8 @@ func makeChannel() *eventingv1alpha1.Channel {
UID: cUID,
},
Spec: eventingv1alpha1.ChannelSpec{
Provisioner: &eventingv1alpha1.ProvisionerReference{
Ref: &corev1.ObjectReference{
Name: ccpName,
},
Provisioner: &corev1.ObjectReference{
Name: ccpName,
},
},
}
Expand All @@ -502,21 +494,15 @@ func makeChannelNilProvisioner() *eventingv1alpha1.Channel {
return c
}

func makeChannelNilRef() *eventingv1alpha1.Channel {
c := makeChannel()
c.Spec.Provisioner.Ref = nil
return c
}

func makeChannelWithWrongProvisionerNamespace() *eventingv1alpha1.Channel {
c := makeChannel()
c.Spec.Provisioner.Ref.Namespace = "wrong-namespace"
c.Spec.Provisioner.Namespace = "wrong-namespace"
return c
}

func makeChannelWithWrongProvisionerName() *eventingv1alpha1.Channel {
c := makeChannel()
c.Spec.Provisioner.Ref.Name = "wrong-name"
c.Spec.Provisioner.Name = "wrong-name"
return c
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ func (r *reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err

// IsControlled determines if the in-memory Channel Controller should control (and therefore
// reconcile) a given object, based on that object's ClusterChannelProvisioner reference.
func IsControlled(ref *eventingv1alpha1.ProvisionerReference) bool {
if ref != nil && ref.Ref != nil {
return shouldReconcile(ref.Ref.Namespace, ref.Ref.Name)
func IsControlled(ref *corev1.ObjectReference) bool {
if ref != nil {
return shouldReconcile(ref.Namespace, ref.Name)
}
return false
}
Expand Down
Loading