Skip to content

Commit

Permalink
Remove KafkaChannel upgrade hack (knative#5276)
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Guardiani <[email protected]>
  • Loading branch information
slinkydeveloper committed Apr 19, 2021
1 parent 97c0d30 commit 96a4cc3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 39 deletions.
8 changes: 1 addition & 7 deletions pkg/apis/messaging/v1/subscription_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,4 @@ func (s *Subscription) SetDefaults(ctx context.Context) {
s.Spec.SetDefaults(ctx)
}

func (ss *SubscriptionSpec) SetDefaults(ctx context.Context) {
// HACK if a channel ref is a kafka channel ref, we need to hack it around to use only v1beta1
// TODO(slinkydeveloper) REMOVE AFTER 0.22 release
if ss.Channel.Kind == "KafkaChannel" && ss.Channel.APIVersion == "messaging.knative.dev/v1alpha1" {
ss.Channel.APIVersion = "messaging.knative.dev/v1beta1"
}
}
func (ss *SubscriptionSpec) SetDefaults(ctx context.Context) {}
10 changes: 1 addition & 9 deletions pkg/apis/messaging/v1/subscription_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,8 @@ func (s *Subscription) CheckImmutableFields(ctx context.Context, original *Subsc
return nil
}

// TODO(slinkydeveloper)
// HACK around the immutability check to make sure the update script can upgrade the api version
// REMOVE AFTER 0.22 release
ignoredFields := []string{"Subscriber", "Reply"}
if original.Spec.Channel.Kind == "KafkaChannel" && original.Spec.Channel.APIVersion == "messaging.knative.dev/v1alpha1" && s.Spec.Channel.APIVersion == "messaging.knative.dev/v1beta1" {
ignoredFields = append(ignoredFields, "Channel.APIVersion")
}

// Only Subscriber and Reply are mutable.
ignoreArguments := cmpopts.IgnoreFields(SubscriptionSpec{}, ignoredFields...)
ignoreArguments := cmpopts.IgnoreFields(SubscriptionSpec{}, "Subscriber", "Reply")
if diff, err := kmp.ShortDiff(original.Spec, s.Spec, ignoreArguments); err != nil {
return &apis.FieldError{
Message: "Failed to diff Subscription",
Expand Down
23 changes: 0 additions & 23 deletions pkg/apis/messaging/v1/subscription_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,29 +329,6 @@ func TestSubscriptionImmutable(t *testing.T) {
},
},
want: nil,
}, {
name: "valid, kafkachannel hack",
c: &Subscription{
Spec: SubscriptionSpec{
Channel: corev1.ObjectReference{
Name: channelName,
Kind: "KafkaChannel",
APIVersion: "messaging.knative.dev/v1beta1",
},
Subscriber: getValidDestination(),
},
},
og: &Subscription{
Spec: SubscriptionSpec{
Channel: corev1.ObjectReference{
Name: channelName,
Kind: "KafkaChannel",
APIVersion: "messaging.knative.dev/v1alpha1",
},
Subscriber: getValidDestination(),
},
},
want: nil,
}, {
name: "Channel changed",
c: &Subscription{
Expand Down

0 comments on commit 96a4cc3

Please sign in to comment.