Skip to content

Commit

Permalink
Set APIVersion and Kind of EventPolicy manually in OwnerReference of …
Browse files Browse the repository at this point in the history
…backing channels policy (#8031)

* Set APIVersion and Kind of EventPolicy manually in OwnerReference of backing channels policy

* Switch to GetGroupVersionKind()
  • Loading branch information
creydr authored Jul 3, 2024
1 parent 96c30bd commit 4f2b53f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
22 changes: 17 additions & 5 deletions pkg/reconciler/channel/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"fmt"
"testing"

eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1"

v1 "knative.dev/eventing/pkg/apis/messaging/v1"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -361,7 +363,9 @@ func TestReconcile(t *testing.T) {
Kind: "InMemoryChannel",
Name: channelName,
}, {
Name: readyEventPolicyName,
APIVersion: eventingv1alpha1.SchemeGroupVersion.String(),
Kind: "EventPolicy",
Name: readyEventPolicyName,
},
}...),
WithEventPolicyLabels(map[string]string{
Expand Down Expand Up @@ -411,7 +415,9 @@ func TestReconcile(t *testing.T) {
Kind: "InMemoryChannel",
Name: channelName,
}, {
Name: unreadyEventPolicyName,
APIVersion: eventingv1alpha1.SchemeGroupVersion.String(),
Kind: "EventPolicy",
Name: unreadyEventPolicyName,
},
}...),
WithEventPolicyLabels(map[string]string{
Expand Down Expand Up @@ -464,7 +470,9 @@ func TestReconcile(t *testing.T) {
Kind: "InMemoryChannel",
Name: channelName,
}, {
Name: readyEventPolicyName,
APIVersion: eventingv1alpha1.SchemeGroupVersion.String(),
Kind: "EventPolicy",
Name: readyEventPolicyName,
},
}...),
WithEventPolicyLabels(map[string]string{
Expand All @@ -482,7 +490,9 @@ func TestReconcile(t *testing.T) {
Kind: "InMemoryChannel",
Name: channelName,
}, {
Name: unreadyEventPolicyName,
APIVersion: eventingv1alpha1.SchemeGroupVersion.String(),
Kind: "EventPolicy",
Name: unreadyEventPolicyName,
},
}...),
WithEventPolicyLabels(map[string]string{
Expand Down Expand Up @@ -547,7 +557,9 @@ func TestReconcile(t *testing.T) {
Kind: "InMemoryChannel",
Name: channelName,
}, {
Name: readyEventPolicyName,
APIVersion: eventingv1alpha1.SchemeGroupVersion.String(),
Kind: "EventPolicy",
Name: readyEventPolicyName,
},
}...),
WithEventPolicyLabels(map[string]string{
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/channel/resources/eventpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func MakeEventPolicyForBackingChannel(backingChannel *eventingduckv1.Channelable
Name: backingChannel.Name,
UID: backingChannel.UID,
}, {
APIVersion: parentPolicy.APIVersion,
Kind: parentPolicy.Kind,
APIVersion: parentPolicy.GetGroupVersionKind().GroupVersion().String(),
Kind: parentPolicy.GetGroupVersionKind().Kind,
Name: parentPolicy.Name,
UID: parentPolicy.UID,
},
Expand Down

0 comments on commit 4f2b53f

Please sign in to comment.