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

Remove assumption on default namespace for EventType reference #7724

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion pkg/apis/eventing/v1beta1/eventtype_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@ limitations under the License.

package v1beta1

import "context"
import (
"context"

"knative.dev/pkg/apis"
)

func (et *EventType) SetDefaults(ctx context.Context) {
ctx = apis.WithinParent(ctx, et.ObjectMeta)
et.Spec.SetDefaults(ctx)
}

func (ets *EventTypeSpec) SetDefaults(ctx context.Context) {
if ets.Reference == nil && ets.Broker == "" {
ets.Broker = "default"
}
if ets.Reference != nil {
ets.Reference.SetDefaults(ctx)
}
}
11 changes: 5 additions & 6 deletions pkg/apis/eventing/v1beta2/eventtype_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ package v1beta2

import (
"context"

"knative.dev/pkg/apis"
)

func (et *EventType) SetDefaults(ctx context.Context) {
ctx = apis.WithinParent(ctx, et.ObjectMeta)
et.Spec.SetDefaults(ctx)
setReferenceNs(et)
}

func (ets *EventTypeSpec) SetDefaults(ctx context.Context) {
}

func setReferenceNs(et *EventType) {
if et.Spec.Reference != nil && et.Spec.Reference.Namespace == "" {
et.Spec.Reference.Namespace = et.GetNamespace()
if ets.Reference != nil {
ets.Reference.SetDefaults(ctx)
}
}
11 changes: 5 additions & 6 deletions pkg/apis/eventing/v1beta3/eventtype_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ package v1beta3

import (
"context"

"knative.dev/pkg/apis"
)

func (et *EventType) SetDefaults(ctx context.Context) {
ctx = apis.WithinParent(ctx, et.ObjectMeta)
et.Spec.SetDefaults(ctx)
setReferenceNs(et)
}

func (ets *EventTypeSpec) SetDefaults(ctx context.Context) {
}

func setReferenceNs(et *EventType) {
if et.Spec.Reference != nil && et.Spec.Reference.Namespace == "" {
et.Spec.Reference.Namespace = et.GetNamespace()
if ets.Reference != nil {
ets.Reference.SetDefaults(ctx)
}
}
5 changes: 1 addition & 4 deletions pkg/reconciler/source/duck/duck.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@ func (r *Reconciler) makeEventTypes(ctx context.Context, src *duckv1.Source) []v
CeSchema: schemaURL,
Description: description,
})
if eventType.Spec.Reference.Namespace == "" {
eventType.Spec.Reference.Namespace = defaultNamespace
}
eventTypes = append(eventTypes, *eventType)
}
return eventTypes
Expand All @@ -235,7 +232,7 @@ func (r *Reconciler) computeDiff(current []v1beta2.EventType, expected []v1beta2
if c, ok := currentMap[keyFromEventType(&e)]; !ok {
toCreate = append(toCreate, e)
} else {
if !equality.Semantic.DeepEqual(e.Spec, c.Spec) {
if !equality.Semantic.DeepDerivative(e.Spec, c.Spec) {
Cali0707 marked this conversation as resolved.
Show resolved Hide resolved
toDelete = append(toDelete, c)
toCreate = append(toCreate, e)
}
Expand Down
Loading