From 55c6e2fc035cd26ff88d2386747e61cb38b1b644 Mon Sep 17 00:00:00 2001 From: Lionel Villard Date: Mon, 9 Sep 2019 09:33:35 -0400 Subject: [PATCH] Add ErrorChannel to Channelable --- Gopkg.lock | 1 + pkg/apis/duck/v1alpha1/channelable_types.go | 16 ++++++++++++++++ pkg/apis/duck/v1alpha1/channelable_types_test.go | 11 +++++++++++ pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go | 6 ++++++ 4 files changed, 34 insertions(+) diff --git a/Gopkg.lock b/Gopkg.lock index ac3a5f3650d..31fe85a0270 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1390,6 +1390,7 @@ "knative.dev/pkg/apis/duck", "knative.dev/pkg/apis/duck/v1alpha1", "knative.dev/pkg/apis/duck/v1beta1", + "knative.dev/pkg/apis/v1alpha1", "knative.dev/pkg/client/clientset/versioned/fake", "knative.dev/pkg/codegen/cmd/injection-gen", "knative.dev/pkg/configmap", diff --git a/pkg/apis/duck/v1alpha1/channelable_types.go b/pkg/apis/duck/v1alpha1/channelable_types.go index db2dc86bf9e..04dd1048c3e 100644 --- a/pkg/apis/duck/v1alpha1/channelable_types.go +++ b/pkg/apis/duck/v1alpha1/channelable_types.go @@ -24,6 +24,7 @@ import ( "knative.dev/pkg/apis/duck" "knative.dev/pkg/apis/duck/v1alpha1" duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" ) // +genclient @@ -45,6 +46,12 @@ type Channelable struct { // ChannelableSpec contains Spec of the Channelable object type ChannelableSpec struct { SubscribableTypeSpec `json:",inline"` + + // ErrorChannel is the channel receiving messages that couldn't be sent to + // subscribers. One message is sent to this channel per failing subscriber. + // + // +optional + ErrorChannel *apisv1alpha1.Destination `json:"errorChannel,omitempty"` } // ChannelableStatus contains the Status of a Channelable object. @@ -81,6 +88,15 @@ func (c *Channelable) Populate() { ReplyURI: "sink2", }}, } + c.Spec.ErrorChannel = &apisv1alpha1.Destination{ + ObjectReference: &corev1.ObjectReference{ + Name: "aname", + }, + URI: &apis.URL{ + Scheme: "http", + Host: "test-error-domain", + }, + } c.Status = ChannelableStatus{ AddressStatus: v1alpha1.AddressStatus{ Address: &v1alpha1.Addressable{ diff --git a/pkg/apis/duck/v1alpha1/channelable_types_test.go b/pkg/apis/duck/v1alpha1/channelable_types_test.go index 06a0b3af7c5..07a8f305bb6 100644 --- a/pkg/apis/duck/v1alpha1/channelable_types_test.go +++ b/pkg/apis/duck/v1alpha1/channelable_types_test.go @@ -23,6 +23,7 @@ import ( "knative.dev/pkg/apis" "knative.dev/pkg/apis/duck/v1alpha1" duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" "github.com/google/go-cmp/cmp" ) @@ -57,7 +58,17 @@ func TestChannelablePopulate(t *testing.T) { }}, }, }, + ErrorChannel: &apisv1alpha1.Destination{ + ObjectReference: &corev1.ObjectReference{ + Name: "aname", + }, + URI: &apis.URL{ + Scheme: "http", + Host: "test-error-domain", + }, + }, }, + Status: ChannelableStatus{ AddressStatus: v1alpha1.AddressStatus{ Address: &v1alpha1.Addressable{ diff --git a/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go index 5087d30a837..262961c9b5b 100644 --- a/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go @@ -23,6 +23,7 @@ package v1alpha1 import ( v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" + apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -151,6 +152,11 @@ func (in *ChannelableList) DeepCopyObject() runtime.Object { func (in *ChannelableSpec) DeepCopyInto(out *ChannelableSpec) { *out = *in in.SubscribableTypeSpec.DeepCopyInto(&out.SubscribableTypeSpec) + if in.ErrorChannel != nil { + in, out := &in.ErrorChannel, &out.ErrorChannel + *out = new(apisv1alpha1.Destination) + (*in).DeepCopyInto(*out) + } return }