From b502732cb20c983b1cc2c5e65db2cdbe11517428 Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Tue, 11 Aug 2020 03:14:05 -0400 Subject: [PATCH] Fix ChannelableCombined and SubscribableTypes for v1 migration (#3803) * add v1 type shapes to v1alpha1 channeable/subscribable * update tests * run update-codegen --- .../v1alpha1/channelable_combined_types.go | 112 ++++++++++++------ .../channelable_combined_types_test.go | 54 +++++++++ pkg/apis/duck/v1alpha1/subscribable_types.go | 32 ++++- .../v1alpha1/subscribable_types_conversion.go | 44 +++---- .../subscribable_types_conversion_test.go | 27 ++++- .../duck/v1alpha1/subscribable_types_test.go | 31 +++++ .../duck/v1alpha1/zz_generated.deepcopy.go | 24 +++- 7 files changed, 255 insertions(+), 69 deletions(-) diff --git a/pkg/apis/duck/v1alpha1/channelable_combined_types.go b/pkg/apis/duck/v1alpha1/channelable_combined_types.go index 11bfa56f63a..7e0847e7e55 100644 --- a/pkg/apis/duck/v1alpha1/channelable_combined_types.go +++ b/pkg/apis/duck/v1alpha1/channelable_combined_types.go @@ -20,6 +20,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1" eventingduckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" "knative.dev/pkg/apis" "knative.dev/pkg/apis/duck" @@ -31,8 +32,8 @@ import ( // +genduck // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// ChannelableCombined is a skeleton type wrapping Subscribable and Addressable of both -// v1alpha1 and v1beta1 duck types. This is not to be used by resource writers and is +// ChannelableCombined is a skeleton type wrapping Subscribable and Addressable of +// v1alpha1, v1beta1 and v1 duck types. This is not to be used by resource writers and is // only used by Subscription Controller to synthesize patches and read the Status // of the Channelable Resources. // This is not a real resource. @@ -55,8 +56,17 @@ type ChannelableCombinedSpec struct { eventingduckv1beta1.SubscribableSpec `json:",inline"` // DeliverySpec contains options controlling the event delivery + // for the v1beta1 spec compatibility. // +optional Delivery *eventingduckv1beta1.DeliverySpec `json:"delivery,omitempty"` + + // SubscribableSpecv1 is for the v1 spec compatibility. + SubscribableSpecv1 eventingduckv1.SubscribableSpec `json:",inline"` + + // DeliverySpecv1 contains options controlling the event delivery + // for the v1 spec compatibility. + // +optional + Deliveryv1 *eventingduckv1.DeliverySpec `json:"deliveryv1,omitempty"` } // ChannelableStatus contains the Status of a Channelable object. @@ -71,6 +81,8 @@ type ChannelableCombinedStatus struct { SubscribableTypeStatus `json:",inline"` // SubscribableStatus is the v1beta1 part of the Subscribers status. eventingduckv1beta1.SubscribableStatus `json:",inline"` + // SubscribableStatusv1 is the v1 part of the Subscribers status. + SubscribableStatusv1 eventingduckv1.SubscribableStatus `json:",inline"` // ErrorChannel is set by the channel when it supports native error handling via a channel // +optional ErrorChannel *corev1.ObjectReference `json:"errorChannel,omitempty"` @@ -113,23 +125,67 @@ func (c *ChannelableCombined) Populate() { ReplyURI: apis.HTTP("sink2"), }}, } + c.Spec.SubscribableSpecv1 = eventingduckv1.SubscribableSpec{ + // Populate ALL fields + Subscribers: []eventingduckv1.SubscriberSpec{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + Generation: 1, + SubscriberURI: apis.HTTP("call1"), + ReplyURI: apis.HTTP("sink2"), + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + Generation: 2, + SubscriberURI: apis.HTTP("call2"), + ReplyURI: apis.HTTP("sink2"), + }}, + } retry := int32(5) linear := eventingduckv1beta1.BackoffPolicyLinear + linearv1 := eventingduckv1.BackoffPolicyLinear delay := "5s" - c.Spec.Delivery = &eventingduckv1beta1.DeliverySpec{ - DeadLetterSink: &duckv1.Destination{ - Ref: &duckv1.KReference{ - Name: "aname", - }, - URI: &apis.URL{ - Scheme: "http", - Host: "test-error-domain", - }, + deadLetterSink := duckv1.Destination{ + Ref: &duckv1.KReference{ + Name: "aname", }, - Retry: &retry, - BackoffPolicy: &linear, - BackoffDelay: &delay, + URI: &apis.URL{ + Scheme: "http", + Host: "test-error-domain", + }, + } + c.Spec.Delivery = &eventingduckv1beta1.DeliverySpec{ + DeadLetterSink: &deadLetterSink, + Retry: &retry, + BackoffPolicy: &linear, + BackoffDelay: &delay, } + c.Spec.Deliveryv1 = &eventingduckv1.DeliverySpec{ + DeadLetterSink: &deadLetterSink, + Retry: &retry, + BackoffPolicy: &linearv1, + BackoffDelay: &delay, + } + subscribers := []eventingduckv1beta1.SubscriberStatus{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 1, + Ready: corev1.ConditionTrue, + Message: "Some message", + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 2, + Ready: corev1.ConditionFalse, + Message: "Some message", + }} + subscribersv1 := []eventingduckv1.SubscriberStatus{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 1, + Ready: corev1.ConditionTrue, + Message: "Some message", + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 2, + Ready: corev1.ConditionFalse, + Message: "Some message", + }} c.Status = ChannelableCombinedStatus{ AddressStatus: v1alpha1.AddressStatus{ Address: &v1alpha1.Addressable{ @@ -144,31 +200,15 @@ func (c *ChannelableCombined) Populate() { }, }, SubscribableStatus: eventingduckv1beta1.SubscribableStatus{ - Subscribers: []eventingduckv1beta1.SubscriberStatus{{ - UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", - ObservedGeneration: 1, - Ready: corev1.ConditionTrue, - Message: "Some message", - }, { - UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", - ObservedGeneration: 2, - Ready: corev1.ConditionFalse, - Message: "Some message", - }}, + Subscribers: subscribers, + }, + SubscribableStatusv1: eventingduckv1.SubscribableStatus{ + Subscribers: subscribersv1, }, SubscribableTypeStatus: SubscribableTypeStatus{ SubscribableStatus: &SubscribableStatus{ - Subscribers: []eventingduckv1beta1.SubscriberStatus{{ - UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", - ObservedGeneration: 1, - Ready: corev1.ConditionTrue, - Message: "Some message", - }, { - UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", - ObservedGeneration: 2, - Ready: corev1.ConditionFalse, - Message: "Some message", - }}, + Subscribers: subscribers, + Subscribersv1: subscribersv1, }, }, } diff --git a/pkg/apis/duck/v1alpha1/channelable_combined_types_test.go b/pkg/apis/duck/v1alpha1/channelable_combined_types_test.go index 5b594b16986..9033044a170 100644 --- a/pkg/apis/duck/v1alpha1/channelable_combined_types_test.go +++ b/pkg/apis/duck/v1alpha1/channelable_combined_types_test.go @@ -20,6 +20,7 @@ import ( "testing" corev1 "k8s.io/api/core/v1" + eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1" eventingduckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" @@ -44,6 +45,7 @@ func TestChannelableCombinedPopulate(t *testing.T) { retry := int32(5) linear := eventingduckv1beta1.BackoffPolicyLinear + linearv1 := eventingduckv1.BackoffPolicyLinear delay := "5s" want := &ChannelableCombined{ Spec: ChannelableCombinedSpec{ @@ -61,6 +63,20 @@ func TestChannelableCombinedPopulate(t *testing.T) { ReplyURI: apis.HTTP("sink2"), }}, }, + SubscribableSpecv1: eventingduckv1.SubscribableSpec{ + // Populate ALL fields + Subscribers: []eventingduckv1.SubscriberSpec{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + Generation: 1, + SubscriberURI: apis.HTTP("call1"), + ReplyURI: apis.HTTP("sink2"), + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + Generation: 2, + SubscriberURI: apis.HTTP("call2"), + ReplyURI: apis.HTTP("sink2"), + }}, + }, SubscribableTypeSpec: SubscribableTypeSpec{ Subscribable: &Subscribable{ Subscribers: []SubscriberSpec{{ @@ -90,6 +106,20 @@ func TestChannelableCombinedPopulate(t *testing.T) { BackoffPolicy: &linear, BackoffDelay: &delay, }, + Deliveryv1: &eventingduckv1.DeliverySpec{ + DeadLetterSink: &duckv1.Destination{ + Ref: &duckv1.KReference{ + Name: "aname", + }, + URI: &apis.URL{ + Scheme: "http", + Host: "test-error-domain", + }, + }, + Retry: &retry, + BackoffPolicy: &linearv1, + BackoffDelay: &delay, + }, }, Status: ChannelableCombinedStatus{ @@ -118,6 +148,19 @@ func TestChannelableCombinedPopulate(t *testing.T) { Message: "Some message", }}, }, + SubscribableStatusv1: eventingduckv1.SubscribableStatus{ + Subscribers: []eventingduckv1.SubscriberStatus{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 1, + Ready: corev1.ConditionTrue, + Message: "Some message", + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 2, + Ready: corev1.ConditionFalse, + Message: "Some message", + }}, + }, SubscribableTypeStatus: SubscribableTypeStatus{ SubscribableStatus: &SubscribableStatus{ Subscribers: []eventingduckv1beta1.SubscriberStatus{{ @@ -131,6 +174,17 @@ func TestChannelableCombinedPopulate(t *testing.T) { Ready: corev1.ConditionFalse, Message: "Some message", }}, + Subscribersv1: []eventingduckv1.SubscriberStatus{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 1, + Ready: corev1.ConditionTrue, + Message: "Some message", + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 2, + Ready: corev1.ConditionFalse, + Message: "Some message", + }}, }, }, }, diff --git a/pkg/apis/duck/v1alpha1/subscribable_types.go b/pkg/apis/duck/v1alpha1/subscribable_types.go index afb93bf4501..43c073c55d7 100644 --- a/pkg/apis/duck/v1alpha1/subscribable_types.go +++ b/pkg/apis/duck/v1alpha1/subscribable_types.go @@ -24,8 +24,8 @@ import ( "knative.dev/pkg/apis" "knative.dev/pkg/apis/duck" + duckv1 "knative.dev/eventing/pkg/apis/duck/v1" duckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" - eventingduckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" ) // +genduck @@ -62,6 +62,8 @@ type SubscriberSpec struct { DeadLetterSinkURI *apis.URL `json:"deadLetterSink,omitempty"` // +optional Delivery *duckv1beta1.DeliverySpec `json:"delivery,omitempty"` + // +optional + Deliveryv1 *duckv1.DeliverySpec `json:"deliveryv1,omitempty"` } // SubscribableStatus is the schema for the subscribable's status portion of the status @@ -71,6 +73,11 @@ type SubscribableStatus struct { // +patchMergeKey=uid // +patchStrategy=merge Subscribers []duckv1beta1.SubscriberStatus `json:"subscribers,omitempty" patchStrategy:"merge" patchMergeKey:"uid"` + + // This is the list of subscription's statuses for this channel. + // +patchMergeKey=uid + // +patchStrategy=merge + Subscribersv1 []duckv1.SubscriberStatus `json:"subscribersv1,omitempty" patchStrategy:"merge" patchMergeKey:"uid"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -132,11 +139,19 @@ func (s *SubscribableTypeStatus) SetSubscribableTypeStatus(subscriberStatus Subs // AddSubscriberToSubscribableStatus method is a Helper method for type SubscribableTypeStatus, if Subscribable Status needs to be appended // with Subscribers, use this function, so that the value is reflected in both the duplicate fields residing // in SubscribableTypeStatus -func (s *SubscribableTypeStatus) AddSubscriberToSubscribableStatus(subscriberStatus eventingduckv1beta1.SubscriberStatus) { +func (s *SubscribableTypeStatus) AddSubscriberToSubscribableStatus(subscriberStatus duckv1beta1.SubscriberStatus) { subscribers := append(s.GetSubscribableTypeStatus().Subscribers, subscriberStatus) s.SubscribableStatus.Subscribers = subscribers } +// AddSubscriberToSubscribableStatus method is a Helper method for type SubscribableTypeStatus, if Subscribable Status needs to be appended +// with Subscribers, use this function, so that the value is reflected in both the duplicate fields residing +// in SubscribableTypeStatus +func (s *SubscribableTypeStatus) AddSubscriberV1ToSubscribableStatus(subscriberStatus duckv1.SubscriberStatus) { + subscribersv1 := append(s.GetSubscribableTypeStatus().Subscribersv1, subscriberStatus) + s.SubscribableStatus.Subscribersv1 = subscribersv1 +} + // GetFullType implements duck.Implementable func (s *Subscribable) GetFullType() duck.Populatable { return &SubscribableType{} @@ -160,7 +175,18 @@ func (c *SubscribableType) Populate() { } c.Status.SetSubscribableTypeStatus(SubscribableStatus{ // Populate ALL fields - Subscribers: []eventingduckv1beta1.SubscriberStatus{{ + Subscribers: []duckv1beta1.SubscriberStatus{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 1, + Ready: corev1.ConditionTrue, + Message: "Some message", + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 2, + Ready: corev1.ConditionFalse, + Message: "Some message", + }}, + Subscribersv1: []duckv1.SubscriberStatus{{ UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", ObservedGeneration: 1, Ready: corev1.ConditionTrue, diff --git a/pkg/apis/duck/v1alpha1/subscribable_types_conversion.go b/pkg/apis/duck/v1alpha1/subscribable_types_conversion.go index 87ee03df5f9..5c819b29007 100644 --- a/pkg/apis/duck/v1alpha1/subscribable_types_conversion.go +++ b/pkg/apis/duck/v1alpha1/subscribable_types_conversion.go @@ -103,11 +103,8 @@ func (source *SubscriberSpec) ConvertTo(ctx context.Context, obj apis.Convertibl sink.UID = source.UID sink.Generation = source.Generation sink.SubscriberURI = source.SubscriberURI - if source.Delivery != nil { - sink.Delivery = &eventingduckv1.DeliverySpec{} - if err := source.Delivery.ConvertTo(ctx, sink.Delivery); err != nil { - return err - } + if source.Deliveryv1 != nil { + sink.Delivery = source.Deliveryv1 } else { // If however, there's a Deprecated DeadLetterSinkURI, convert that up // to DeliverySpec. @@ -142,12 +139,14 @@ func (source *SubscribableTypeStatus) ConvertTo(ctx context.Context, obj apis.Co } case *eventingduckv1.SubscribableStatus: if source.SubscribableStatus != nil && - len(source.SubscribableStatus.Subscribers) > 0 { - sink.Subscribers = make([]eventingduckv1.SubscriberStatus, len(source.SubscribableStatus.Subscribers)) - for i, ss := range source.SubscribableStatus.Subscribers { - sink.Subscribers[i] = eventingduckv1.SubscriberStatus{} - if err := ss.ConvertTo(ctx, &sink.Subscribers[i]); err != nil { - return err + len(source.SubscribableStatus.Subscribersv1) > 0 { + sink.Subscribers = make([]eventingduckv1.SubscriberStatus, len(source.SubscribableStatus.Subscribersv1)) + for i, ss := range source.SubscribableStatus.Subscribersv1 { + sink.Subscribers[i] = eventingduckv1.SubscriberStatus{ + UID: ss.UID, + ObservedGeneration: ss.ObservedGeneration, + Ready: ss.Ready, + Message: ss.Message, } } } @@ -229,17 +228,16 @@ func (sink *SubscriberSpec) ConvertFrom(ctx context.Context, obj apis.Convertibl sink.Delivery = source.Delivery sink.DeadLetterSinkURI = deadLetterSinkURI case *eventingduckv1.SubscriberSpec: + var deadLetterSinkURI *apis.URL + if source.Delivery != nil && source.Delivery.DeadLetterSink != nil { + deadLetterSinkURI = source.Delivery.DeadLetterSink.URI + } sink.UID = source.UID sink.Generation = source.Generation sink.SubscriberURI = source.SubscriberURI sink.ReplyURI = source.ReplyURI - if source.Delivery != nil { - sink.Delivery = &eventingduckv1beta1.DeliverySpec{} - if err := sink.Delivery.ConvertFrom(ctx, source.Delivery); err != nil { - return err - } - sink.DeadLetterSinkURI = source.Delivery.DeadLetterSink.URI - } + sink.Deliveryv1 = source.Delivery + sink.DeadLetterSinkURI = deadLetterSinkURI default: return fmt.Errorf("unknown version, got: %T", sink) } @@ -266,12 +264,14 @@ func (sink *SubscribableTypeStatus) ConvertFrom(ctx context.Context, obj apis.Co case *eventingduckv1.SubscribableStatus: if len(source.Subscribers) > 0 { sink.SubscribableStatus = &SubscribableStatus{ - Subscribers: make([]eventingduckv1beta1.SubscriberStatus, len(source.Subscribers)), + Subscribersv1: make([]eventingduckv1.SubscriberStatus, len(source.Subscribers)), } for i, ss := range source.Subscribers { - sink.SubscribableStatus.Subscribers[i] = eventingduckv1beta1.SubscriberStatus{} - if err := sink.SubscribableStatus.Subscribers[i].ConvertFrom(ctx, &ss); err != nil { - return err + sink.SubscribableStatus.Subscribersv1[i] = eventingduckv1.SubscriberStatus{ + UID: ss.UID, + ObservedGeneration: ss.ObservedGeneration, + Ready: ss.Ready, + Message: ss.Message, } } } diff --git a/pkg/apis/duck/v1alpha1/subscribable_types_conversion_test.go b/pkg/apis/duck/v1alpha1/subscribable_types_conversion_test.go index 3c0aed99ab9..0ca39c24ac3 100644 --- a/pkg/apis/duck/v1alpha1/subscribable_types_conversion_test.go +++ b/pkg/apis/duck/v1alpha1/subscribable_types_conversion_test.go @@ -147,7 +147,7 @@ func TestSubscribableTypeConversionV1alphaV1(t *testing.T) { // Just one for now, just adding the for loop for ease of future changes. versions := []apis.Convertible{&v1.Subscribable{}} - linear := v1beta1.BackoffPolicyLinear + linear := v1.BackoffPolicyLinear tests := []struct { name string @@ -180,7 +180,7 @@ func TestSubscribableTypeConversionV1alphaV1(t *testing.T) { SubscriberURI: apis.HTTP("subscriber.example.com"), ReplyURI: apis.HTTP("reply.example.com"), DeadLetterSinkURI: apis.HTTP("subscriber.dls.example.com"), - Delivery: &v1beta1.DeliverySpec{ + Deliveryv1: &v1.DeliverySpec{ DeadLetterSink: &pkgduckv1.Destination{ Ref: &pkgduckv1.KReference{ Kind: "dlKind", @@ -201,14 +201,14 @@ func TestSubscribableTypeConversionV1alphaV1(t *testing.T) { SubscriberURI: apis.HTTP("subscriber2.example.com"), ReplyURI: apis.HTTP("reply2.example.com"), DeadLetterSinkURI: apis.HTTP("subscriber2.dls.example.com"), - Delivery: nil, + Deliveryv1: nil, }, }, }, }, Status: SubscribableTypeStatus{ SubscribableStatus: &SubscribableStatus{ - Subscribers: []v1beta1.SubscriberStatus{ + Subscribersv1: []v1.SubscriberStatus{ { UID: "status-uid-1", ObservedGeneration: 99, @@ -232,7 +232,7 @@ func TestSubscribableTypeConversionV1alphaV1(t *testing.T) { t.Errorf("ConvertFrom() = %v", err) } - fixed := fixSubscribableTypeDeprecated(test.in) + fixed := fixSubscribableTypeDeprecatedv1(test.in) if diff := cmp.Diff(fixed, got); diff != "" { t.Errorf("roundtrip (-want, +got) = %v", diff) } @@ -461,3 +461,20 @@ func fixSubscribableTypeDeprecated(in *SubscribableType) *SubscribableType { return in } + +// Since v1 to v1alpha1 is lossy. +func fixSubscribableTypeDeprecatedv1(in *SubscribableType) *SubscribableType { + if in.Spec.Subscribable != nil && len(in.Spec.Subscribable.Subscribers) > 0 { + for i := range in.Spec.Subscribable.Subscribers { + if in.Spec.Subscribable.Subscribers[i].Deliveryv1 == nil { + in.Spec.Subscribable.Subscribers[i].Deliveryv1 = &v1.DeliverySpec{ + DeadLetterSink: &pkgduckv1.Destination{ + URI: in.Spec.Subscribable.Subscribers[i].DeadLetterSinkURI, + }, + } + } + } + } + + return in +} diff --git a/pkg/apis/duck/v1alpha1/subscribable_types_test.go b/pkg/apis/duck/v1alpha1/subscribable_types_test.go index c11bf455bb6..f5538dd9a8c 100644 --- a/pkg/apis/duck/v1alpha1/subscribable_types_test.go +++ b/pkg/apis/duck/v1alpha1/subscribable_types_test.go @@ -21,6 +21,7 @@ import ( "github.com/google/go-cmp/cmp" corev1 "k8s.io/api/core/v1" + eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1" eventingduckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" "knative.dev/pkg/apis" ) @@ -78,6 +79,17 @@ func TestSubscribablePopulate(t *testing.T) { Ready: corev1.ConditionFalse, Message: "Some message", }}, + Subscribersv1: []eventingduckv1.SubscriberStatus{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 1, + Ready: corev1.ConditionTrue, + Message: "Some message", + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 2, + Ready: corev1.ConditionFalse, + Message: "Some message", + }}, }, }, } @@ -104,6 +116,17 @@ func TestSubscribableTypeStatusHelperMethods(t *testing.T) { Ready: corev1.ConditionFalse, Message: "This is new field", }}, + Subscribersv1: []eventingduckv1.SubscriberStatus{{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 1, + Ready: corev1.ConditionTrue, + Message: "This is new field", + }, { + UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 2, + Ready: corev1.ConditionFalse, + Message: "This is new field", + }}, } subscribableTypeStatus := SubscribableTypeStatus{ @@ -134,6 +157,14 @@ func TestSubscribableTypeStatusHelperMethods(t *testing.T) { Message: "This is new field", }) + /* Test AddSubscriberV1ToSubscribableStatus */ + subscribableTypeStatus.AddSubscriberV1ToSubscribableStatus(eventingduckv1.SubscriberStatus{ + UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", + ObservedGeneration: 1, + Ready: corev1.ConditionTrue, + Message: "This is new field", + }) + // Check if the subscriber was added to both the fields of SubscribableTypeStatus if len(subscribableTypeStatus.SubscribableStatus.Subscribers) != 3 { t.Error("AddSubscriberToSubscribableStatus didn't add subscriberstatus to both the fields of SubscribableTypeStatus") diff --git a/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go index 552909835e9..43c16005d70 100644 --- a/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go @@ -21,8 +21,9 @@ limitations under the License. package v1alpha1 import ( - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" + v1 "knative.dev/eventing/pkg/apis/duck/v1" v1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" apis "knative.dev/pkg/apis" ) @@ -126,6 +127,12 @@ func (in *ChannelableCombinedSpec) DeepCopyInto(out *ChannelableCombinedSpec) { *out = new(v1beta1.DeliverySpec) (*in).DeepCopyInto(*out) } + in.SubscribableSpecv1.DeepCopyInto(&out.SubscribableSpecv1) + if in.Deliveryv1 != nil { + in, out := &in.Deliveryv1, &out.Deliveryv1 + *out = new(v1.DeliverySpec) + (*in).DeepCopyInto(*out) + } return } @@ -146,9 +153,10 @@ func (in *ChannelableCombinedStatus) DeepCopyInto(out *ChannelableCombinedStatus in.AddressStatus.DeepCopyInto(&out.AddressStatus) in.SubscribableTypeStatus.DeepCopyInto(&out.SubscribableTypeStatus) in.SubscribableStatus.DeepCopyInto(&out.SubscribableStatus) + in.SubscribableStatusv1.DeepCopyInto(&out.SubscribableStatusv1) if in.ErrorChannel != nil { in, out := &in.ErrorChannel, &out.ErrorChannel - *out = new(v1.ObjectReference) + *out = new(corev1.ObjectReference) **out = **in } return @@ -227,7 +235,7 @@ func (in *ChannelableStatus) DeepCopyInto(out *ChannelableStatus) { in.SubscribableTypeStatus.DeepCopyInto(&out.SubscribableTypeStatus) if in.ErrorChannel != nil { in, out := &in.ErrorChannel, &out.ErrorChannel - *out = new(v1.ObjectReference) + *out = new(corev1.ObjectReference) **out = **in } return @@ -333,6 +341,11 @@ func (in *SubscribableStatus) DeepCopyInto(out *SubscribableStatus) { *out = make([]v1beta1.SubscriberStatus, len(*in)) copy(*out, *in) } + if in.Subscribersv1 != nil { + in, out := &in.Subscribersv1, &out.Subscribersv1 + *out = make([]v1.SubscriberStatus, len(*in)) + copy(*out, *in) + } return } @@ -472,6 +485,11 @@ func (in *SubscriberSpec) DeepCopyInto(out *SubscriberSpec) { *out = new(v1beta1.DeliverySpec) (*in).DeepCopyInto(*out) } + if in.Deliveryv1 != nil { + in, out := &in.Deliveryv1, &out.Deliveryv1 + *out = new(v1.DeliverySpec) + (*in).DeepCopyInto(*out) + } return }