Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP DO NOT MERGE #3860

Closed
wants to merge 8 commits into from
Closed
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
28 changes: 14 additions & 14 deletions pkg/apis/duck/v1alpha1/channelable_combined_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ type ChannelableCombinedSpec struct {
SubscribableTypeSpec `json:",inline"`

// SubscribableSpec is for the v1beta1 spec compatibility.
eventingduckv1beta1.SubscribableSpec `json:",inline"`
SubscribableSpecv1beta1 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"`
eventingduckv1.SubscribableSpec `json:",inline"`

// DeliverySpecv1 contains options controlling the event delivery
// for the v1 spec compatibility.
Expand All @@ -80,9 +80,9 @@ type ChannelableCombinedStatus struct {
// SubscribableTypeStatus is the v1alpha1 part of the Subscribers status
SubscribableTypeStatus `json:",inline"`
// SubscribableStatus is the v1beta1 part of the Subscribers status.
eventingduckv1beta1.SubscribableStatus `json:",inline"`
SubscribableStatusv1beta1 eventingduckv1beta1.SubscribableStatus `json:",inline"`
// SubscribableStatusv1 is the v1 part of the Subscribers status.
SubscribableStatusv1 eventingduckv1.SubscribableStatus `json:",inline"`
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"`
Expand Down Expand Up @@ -111,7 +111,7 @@ func (c *ChannelableCombined) Populate() {
ReplyURI: apis.HTTP("sink2"),
}},
}
c.Spec.SubscribableSpec = eventingduckv1beta1.SubscribableSpec{
c.Spec.SubscribableSpecv1beta1 = eventingduckv1beta1.SubscribableSpec{
// Populate ALL fields
Subscribers: []eventingduckv1beta1.SubscriberSpec{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
Expand All @@ -125,7 +125,7 @@ func (c *ChannelableCombined) Populate() {
ReplyURI: apis.HTTP("sink2"),
}},
}
c.Spec.SubscribableSpecv1 = eventingduckv1.SubscribableSpec{
c.Spec.SubscribableSpec = eventingduckv1.SubscribableSpec{
// Populate ALL fields
Subscribers: []eventingduckv1.SubscriberSpec{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
Expand Down Expand Up @@ -164,7 +164,7 @@ func (c *ChannelableCombined) Populate() {
BackoffPolicy: &linearv1,
BackoffDelay: &delay,
}
subscribers := []eventingduckv1beta1.SubscriberStatus{{
subscribersv1beta1 := []eventingduckv1beta1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand All @@ -175,7 +175,7 @@ func (c *ChannelableCombined) Populate() {
Ready: corev1.ConditionFalse,
Message: "Some message",
}}
subscribersv1 := []eventingduckv1.SubscriberStatus{{
subscribers := []eventingduckv1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand All @@ -199,16 +199,16 @@ func (c *ChannelableCombined) Populate() {
Hostname: "test-domain",
},
},
SubscribableStatus: eventingduckv1beta1.SubscribableStatus{
Subscribers: subscribers,
SubscribableStatusv1beta1: eventingduckv1beta1.SubscribableStatus{
Subscribers: subscribersv1beta1,
},
SubscribableStatusv1: eventingduckv1.SubscribableStatus{
Subscribers: subscribersv1,
SubscribableStatus: eventingduckv1.SubscribableStatus{
Subscribers: subscribers,
},
SubscribableTypeStatus: SubscribableTypeStatus{
SubscribableStatus: &SubscribableStatus{
Subscribers: subscribers,
Subscribersv1: subscribersv1,
Subscribers: subscribers,
Subscribersv1beta1: subscribersv1beta1,
},
},
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/apis/duck/v1alpha1/channelable_combined_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestChannelableCombinedPopulate(t *testing.T) {
delay := "5s"
want := &ChannelableCombined{
Spec: ChannelableCombinedSpec{
SubscribableSpec: eventingduckv1beta1.SubscribableSpec{
SubscribableSpecv1beta1: eventingduckv1beta1.SubscribableSpec{
// Populate ALL fields
Subscribers: []eventingduckv1beta1.SubscriberSpec{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
Expand All @@ -63,7 +63,7 @@ func TestChannelableCombinedPopulate(t *testing.T) {
ReplyURI: apis.HTTP("sink2"),
}},
},
SubscribableSpecv1: eventingduckv1.SubscribableSpec{
SubscribableSpec: eventingduckv1.SubscribableSpec{
// Populate ALL fields
Subscribers: []eventingduckv1.SubscriberSpec{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestChannelableCombinedPopulate(t *testing.T) {
Hostname: "test-domain",
},
},
SubscribableStatus: eventingduckv1beta1.SubscribableStatus{
SubscribableStatusv1beta1: eventingduckv1beta1.SubscribableStatus{
Subscribers: []eventingduckv1beta1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Expand All @@ -148,7 +148,7 @@ func TestChannelableCombinedPopulate(t *testing.T) {
Message: "Some message",
}},
},
SubscribableStatusv1: eventingduckv1.SubscribableStatus{
SubscribableStatus: eventingduckv1.SubscribableStatus{
Subscribers: []eventingduckv1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Expand All @@ -163,7 +163,7 @@ func TestChannelableCombinedPopulate(t *testing.T) {
},
SubscribableTypeStatus: SubscribableTypeStatus{
SubscribableStatus: &SubscribableStatus{
Subscribers: []eventingduckv1beta1.SubscriberStatus{{
Subscribersv1beta1: []eventingduckv1beta1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand All @@ -174,7 +174,7 @@ func TestChannelableCombinedPopulate(t *testing.T) {
Ready: corev1.ConditionFalse,
Message: "Some message",
}},
Subscribersv1: []eventingduckv1.SubscriberStatus{{
Subscribers: []eventingduckv1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand Down
14 changes: 13 additions & 1 deletion pkg/apis/duck/v1alpha1/channelable_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -123,7 +124,18 @@ func (c *Channelable) Populate() {
},
SubscribableTypeStatus: SubscribableTypeStatus{
SubscribableStatus: &SubscribableStatus{
Subscribers: []eventingduckv1beta1.SubscriberStatus{{
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",
}},
Subscribersv1beta1: []eventingduckv1beta1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand Down
14 changes: 13 additions & 1 deletion pkg/apis/duck/v1alpha1/channelable_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -93,7 +94,18 @@ func TestChannelablePopulate(t *testing.T) {
},
SubscribableTypeStatus: SubscribableTypeStatus{
SubscribableStatus: &SubscribableStatus{
Subscribers: []eventingduckv1beta1.SubscriberStatus{{
Subscribersv1beta1: []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: []eventingduckv1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand Down
20 changes: 10 additions & 10 deletions pkg/apis/duck/v1alpha1/subscribable_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ type SubscribableStatus struct {
// This is the list of subscription's statuses for this channel.
// +patchMergeKey=uid
// +patchStrategy=merge
Subscribers []duckv1beta1.SubscriberStatus `json:"subscribers,omitempty" patchStrategy:"merge" patchMergeKey:"uid"`
Subscribersv1beta1 []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"`
Subscribers []duckv1.SubscriberStatus `json:"subscribersv1,omitempty" patchStrategy:"merge" patchMergeKey:"uid"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -139,17 +139,17 @@ 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 duckv1beta1.SubscriberStatus) {
subscribers := append(s.GetSubscribableTypeStatus().Subscribers, subscriberStatus)
s.SubscribableStatus.Subscribers = subscribers
func (s *SubscribableTypeStatus) AddSubscriberv1beta1ToSubscribableStatus(subscriberStatus duckv1beta1.SubscriberStatus) {
subscribers := append(s.GetSubscribableTypeStatus().Subscribersv1beta1, subscriberStatus)
s.SubscribableStatus.Subscribersv1beta1 = 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
func (s *SubscribableTypeStatus) AddSubscriberToSubscribableStatus(subscriberStatus duckv1.SubscriberStatus) {
subscribersv1 := append(s.GetSubscribableTypeStatus().Subscribers, subscriberStatus)
s.SubscribableStatus.Subscribers = subscribersv1
}

// GetFullType implements duck.Implementable
Expand All @@ -175,7 +175,7 @@ func (c *SubscribableType) Populate() {
}
c.Status.SetSubscribableTypeStatus(SubscribableStatus{
// Populate ALL fields
Subscribers: []duckv1beta1.SubscriberStatus{{
Subscribersv1beta1: []duckv1beta1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand All @@ -186,7 +186,7 @@ func (c *SubscribableType) Populate() {
Ready: corev1.ConditionFalse,
Message: "Some message",
}},
Subscribersv1: []duckv1.SubscriberStatus{{
Subscribers: []duckv1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand Down
20 changes: 10 additions & 10 deletions pkg/apis/duck/v1alpha1/subscribable_types_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ func (source *SubscribableTypeStatus) ConvertTo(ctx context.Context, obj apis.Co
switch sink := obj.(type) {
case *eventingduckv1beta1.SubscribableStatus:
if source.SubscribableStatus != nil &&
len(source.SubscribableStatus.Subscribers) > 0 {
sink.Subscribers = make([]eventingduckv1beta1.SubscriberStatus, len(source.SubscribableStatus.Subscribers))
for i, ss := range source.SubscribableStatus.Subscribers {
len(source.SubscribableStatus.Subscribersv1beta1) > 0 {
sink.Subscribers = make([]eventingduckv1beta1.SubscriberStatus, len(source.SubscribableStatus.Subscribersv1beta1))
for i, ss := range source.SubscribableStatus.Subscribersv1beta1 {
sink.Subscribers[i] = eventingduckv1beta1.SubscriberStatus{
UID: ss.UID,
ObservedGeneration: ss.ObservedGeneration,
Expand All @@ -139,9 +139,9 @@ func (source *SubscribableTypeStatus) ConvertTo(ctx context.Context, obj apis.Co
}
case *eventingduckv1.SubscribableStatus:
if source.SubscribableStatus != nil &&
len(source.SubscribableStatus.Subscribersv1) > 0 {
sink.Subscribers = make([]eventingduckv1.SubscriberStatus, len(source.SubscribableStatus.Subscribersv1))
for i, ss := range source.SubscribableStatus.Subscribersv1 {
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{
UID: ss.UID,
ObservedGeneration: ss.ObservedGeneration,
Expand Down Expand Up @@ -250,10 +250,10 @@ func (sink *SubscribableTypeStatus) ConvertFrom(ctx context.Context, obj apis.Co
case *eventingduckv1beta1.SubscribableStatus:
if len(source.Subscribers) > 0 {
sink.SubscribableStatus = &SubscribableStatus{
Subscribers: make([]eventingduckv1beta1.SubscriberStatus, len(source.Subscribers)),
Subscribersv1beta1: make([]eventingduckv1beta1.SubscriberStatus, len(source.Subscribers)),
}
for i, ss := range source.Subscribers {
sink.SubscribableStatus.Subscribers[i] = eventingduckv1beta1.SubscriberStatus{
sink.SubscribableStatus.Subscribersv1beta1[i] = eventingduckv1beta1.SubscriberStatus{
UID: ss.UID,
ObservedGeneration: ss.ObservedGeneration,
Ready: ss.Ready,
Expand All @@ -264,10 +264,10 @@ func (sink *SubscribableTypeStatus) ConvertFrom(ctx context.Context, obj apis.Co
case *eventingduckv1.SubscribableStatus:
if len(source.Subscribers) > 0 {
sink.SubscribableStatus = &SubscribableStatus{
Subscribersv1: make([]eventingduckv1.SubscriberStatus, len(source.Subscribers)),
Subscribers: make([]eventingduckv1.SubscriberStatus, len(source.Subscribers)),
}
for i, ss := range source.Subscribers {
sink.SubscribableStatus.Subscribersv1[i] = eventingduckv1.SubscriberStatus{
sink.SubscribableStatus.Subscribers[i] = eventingduckv1.SubscriberStatus{
UID: ss.UID,
ObservedGeneration: ss.ObservedGeneration,
Ready: ss.Ready,
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/duck/v1alpha1/subscribable_types_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestSubscribableTypeConversionV1alphaV1beta1(t *testing.T) {
},
Status: SubscribableTypeStatus{
SubscribableStatus: &SubscribableStatus{
Subscribers: []v1beta1.SubscriberStatus{
Subscribersv1beta1: []v1beta1.SubscriberStatus{
{
UID: "status-uid-1",
ObservedGeneration: 99,
Expand Down Expand Up @@ -208,7 +208,7 @@ func TestSubscribableTypeConversionV1alphaV1(t *testing.T) {
},
Status: SubscribableTypeStatus{
SubscribableStatus: &SubscribableStatus{
Subscribersv1: []v1.SubscriberStatus{
Subscribers: []v1.SubscriberStatus{
{
UID: "status-uid-1",
ObservedGeneration: 99,
Expand Down
12 changes: 6 additions & 6 deletions pkg/apis/duck/v1alpha1/subscribable_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestSubscribablePopulate(t *testing.T) {
Status: SubscribableTypeStatus{
SubscribableStatus: &SubscribableStatus{
// Populate ALL fields
Subscribers: []eventingduckv1beta1.SubscriberStatus{{
Subscribersv1beta1: []eventingduckv1beta1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand All @@ -79,7 +79,7 @@ func TestSubscribablePopulate(t *testing.T) {
Ready: corev1.ConditionFalse,
Message: "Some message",
}},
Subscribersv1: []eventingduckv1.SubscriberStatus{{
Subscribers: []eventingduckv1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand All @@ -105,7 +105,7 @@ func TestSubscribablePopulate(t *testing.T) {
func TestSubscribableTypeStatusHelperMethods(t *testing.T) {
s := &SubscribableStatus{
// Populate ALL fields
Subscribers: []eventingduckv1beta1.SubscriberStatus{{
Subscribersv1beta1: []eventingduckv1beta1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand All @@ -116,7 +116,7 @@ func TestSubscribableTypeStatusHelperMethods(t *testing.T) {
Ready: corev1.ConditionFalse,
Message: "This is new field",
}},
Subscribersv1: []eventingduckv1.SubscriberStatus{{
Subscribers: []eventingduckv1.SubscriberStatus{{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand Down Expand Up @@ -150,15 +150,15 @@ func TestSubscribableTypeStatusHelperMethods(t *testing.T) {
}

/* Test AddSubscriberToSubscribableStatus */
subscribableTypeStatus.AddSubscriberToSubscribableStatus(eventingduckv1beta1.SubscriberStatus{
subscribableTypeStatus.AddSubscriberv1beta1ToSubscribableStatus(eventingduckv1beta1.SubscriberStatus{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Message: "This is new field",
})

/* Test AddSubscriberV1ToSubscribableStatus */
subscribableTypeStatus.AddSubscriberV1ToSubscribableStatus(eventingduckv1.SubscriberStatus{
subscribableTypeStatus.AddSubscriberToSubscribableStatus(eventingduckv1.SubscriberStatus{
UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1",
ObservedGeneration: 1,
Ready: corev1.ConditionTrue,
Expand Down
Loading