diff --git a/go.mod b/go.mod index 8b13fa681e..7fdcc65bfa 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( k8s.io/client-go v0.26.5 k8s.io/code-generator v0.26.5 k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 - knative.dev/eventing v0.37.1-0.20230720121212-a13eebe803bf + knative.dev/eventing v0.37.1-0.20230725143141-855fbedc00d0 knative.dev/hack v0.0.0-20230712131415-ddae80293c43 knative.dev/pkg v0.0.0-20230718152110-aef227e72ead knative.dev/reconciler-test v0.0.0-20230720092812-7286e0a369dc diff --git a/go.sum b/go.sum index 36ead7b446..693c0c1be4 100644 --- a/go.sum +++ b/go.sum @@ -883,8 +883,8 @@ k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+O k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= k8s.io/utils v0.0.0-20230505201702-9f6742963106 h1:EObNQ3TW2D+WptiYXlApGNLVy0zm/JIBVY9i+M4wpAU= k8s.io/utils v0.0.0-20230505201702-9f6742963106/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -knative.dev/eventing v0.37.1-0.20230720121212-a13eebe803bf h1:KqqwFQD+qM6utzZH3l7B1/HT+LBT6F61t8cChde1weg= -knative.dev/eventing v0.37.1-0.20230720121212-a13eebe803bf/go.mod h1:nd7MZ/O5nyNKlZ1m9XAxI9eSq2bYWJQfYogSXflRpqc= +knative.dev/eventing v0.37.1-0.20230725143141-855fbedc00d0 h1:Et24SoigIUlapBOHOMK3gy8+84ZF+JXfAgAJp/2TaMY= +knative.dev/eventing v0.37.1-0.20230725143141-855fbedc00d0/go.mod h1:nd7MZ/O5nyNKlZ1m9XAxI9eSq2bYWJQfYogSXflRpqc= knative.dev/hack v0.0.0-20230712131415-ddae80293c43 h1:3SE06uNfSFGm/5XS+0trbyCUpgsOaBeyhPQU8FPNFz8= knative.dev/hack v0.0.0-20230712131415-ddae80293c43/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q= knative.dev/pkg v0.0.0-20230718152110-aef227e72ead h1:2dDzorpKuVZW3Qp7TbirMMq16FbId8f6bacQFX8jXLw= diff --git a/vendor/knative.dev/eventing/pkg/broker/eventtypes.go b/vendor/knative.dev/eventing/pkg/broker/eventtypes.go deleted file mode 100644 index 42568ea7c1..0000000000 --- a/vendor/knative.dev/eventing/pkg/broker/eventtypes.go +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright 2023 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package broker - -import ( - "context" - "encoding/base64" - "fmt" - - "github.com/cloudevents/sdk-go/v2/event" - "go.uber.org/zap" - - apierrs "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - - "knative.dev/eventing/pkg/apis/eventing/v1beta2" - "knative.dev/eventing/pkg/apis/feature" - eventingv1beta2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta2" - v1beta22 "knative.dev/eventing/pkg/client/listers/eventing/v1beta2" - "knative.dev/eventing/pkg/utils" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" -) - -type EventTypeAutoHandler struct { - EventTypeLister v1beta22.EventTypeLister - EventingClient eventingv1beta2.EventingV1beta2Interface - FeatureStore *feature.Store - Logger *zap.Logger -} - -// generateEventTypeName is a pseudo unique name for EvenType object based on on the input params -func generateEventTypeName(name, namespace, eventType, eventSource string) string { - suffixParts := name + namespace + eventType + eventSource - suffix := base64.StdEncoding.EncodeToString([]byte(suffixParts))[:10] - return utils.ToDNS1123Subdomain(fmt.Sprintf("%s-%s-%s", "et", name, suffix)) -} - -// AutoCreateEventType creates EventType object based on processed events's types from addressable KReference objects -func (h *EventTypeAutoHandler) AutoCreateEventType(ctx context.Context, event *event.Event, addressable *duckv1.KReference, ownerUID types.UID) error { - // Feature flag gate - if !h.FeatureStore.IsEnabled(feature.EvenTypeAutoCreate) { - h.Logger.Debug("Event Type auto creation is disabled") - return nil - } - h.Logger.Debug("Event Types auto creation is enabled") - - eventTypeName := generateEventTypeName(addressable.Name, addressable.Namespace, event.Type(), event.Source()) - - exists, err := h.EventTypeLister.EventTypes(addressable.Namespace).Get(eventTypeName) - if err != nil && !apierrs.IsNotFound(err) { - h.Logger.Error("Failed to retrieve Even Type", zap.Error(err)) - return err - } - if exists != nil { - return nil - } - - source, _ := apis.ParseURL(event.Source()) - schema, _ := apis.ParseURL(event.DataSchema()) - - et := &v1beta2.EventType{ - ObjectMeta: metav1.ObjectMeta{ - Name: eventTypeName, - Namespace: addressable.Namespace, - OwnerReferences: []metav1.OwnerReference{ - { - APIVersion: addressable.APIVersion, - Kind: addressable.Kind, - Name: addressable.Name, - UID: ownerUID, - }, - }, - }, - Spec: v1beta2.EventTypeSpec{ - Type: event.Type(), - Source: source, - Schema: schema, - SchemaData: event.DataSchema(), - Reference: addressable, - Description: "Event Type auto-created by controller", - }, - } - - _, err = h.EventingClient.EventTypes(et.Namespace).Create(ctx, et, metav1.CreateOptions{}) - if err != nil && !apierrs.IsAlreadyExists(err) { - h.Logger.Error("Failed to create Event Type", zap.Error(err)) - return err - } - return nil -} diff --git a/vendor/modules.txt b/vendor/modules.txt index e629a3c164..54431ce2b9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1053,7 +1053,7 @@ k8s.io/utils/net k8s.io/utils/pointer k8s.io/utils/strings/slices k8s.io/utils/trace -# knative.dev/eventing v0.37.1-0.20230720121212-a13eebe803bf +# knative.dev/eventing v0.37.1-0.20230725143141-855fbedc00d0 ## explicit; go 1.19 knative.dev/eventing/cmd/heartbeats knative.dev/eventing/pkg/adapter/v2