diff --git a/Gopkg.lock b/Gopkg.lock index 9da7309b66e..1763c3d9235 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1396,13 +1396,18 @@ "apis/duck/v1beta1", "changeset", "client/injection/apiextensions/client", + "client/injection/apiextensions/client/fake", "client/injection/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition", + "client/injection/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition/fake", "client/injection/apiextensions/informers/factory", + "client/injection/apiextensions/informers/factory/fake", "client/injection/ducks/duck/v1/addressable", "client/injection/ducks/duck/v1/addressable/fake", "client/injection/ducks/duck/v1/conditions", "client/injection/ducks/duck/v1/conditions/fake", "client/injection/ducks/duck/v1/podspecable", + "client/injection/ducks/duck/v1/source", + "client/injection/ducks/duck/v1/source/fake", "client/injection/ducks/duck/v1alpha1/addressable", "client/injection/ducks/duck/v1alpha1/addressable/fake", "client/injection/ducks/duck/v1beta1/addressable", @@ -1617,11 +1622,14 @@ "knative.dev/pkg/apis/duck/v1alpha1", "knative.dev/pkg/apis/duck/v1beta1", "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition", + "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition/fake", "knative.dev/pkg/client/injection/ducks/duck/v1/addressable", "knative.dev/pkg/client/injection/ducks/duck/v1/addressable/fake", "knative.dev/pkg/client/injection/ducks/duck/v1/conditions", "knative.dev/pkg/client/injection/ducks/duck/v1/conditions/fake", "knative.dev/pkg/client/injection/ducks/duck/v1/podspecable", + "knative.dev/pkg/client/injection/ducks/duck/v1/source", + "knative.dev/pkg/client/injection/ducks/duck/v1/source/fake", "knative.dev/pkg/client/injection/ducks/duck/v1alpha1/addressable", "knative.dev/pkg/client/injection/ducks/duck/v1alpha1/addressable/fake", "knative.dev/pkg/client/injection/ducks/duck/v1beta1/addressable", diff --git a/pkg/apis/sources/register.go b/pkg/apis/sources/register.go index 55899c3fd77..427b8aad843 100644 --- a/pkg/apis/sources/register.go +++ b/pkg/apis/sources/register.go @@ -24,14 +24,14 @@ import ( const ( GroupName = "sources.knative.dev" - // SourceDuckAnnotationKey is the annotation key to indicate + // SourceDuckLabelKey is the label key to indicate // whether the CRD is a Source duck type. // Valid values: "true" or "false" - SourceDuckAnnotationKey = duck.GroupName + "/source" + SourceDuckLabelKey = duck.GroupName + "/source" - // SourceDuckAnnotationValue is the annotation value to indicate + // SourceDuckLabelValue is the label value to indicate // the CRD is a Source duck type. - SourceDuckAnnotationValue = "true" + SourceDuckLabelValue = "true" ) var ( diff --git a/pkg/reconciler/source/crd/controller.go b/pkg/reconciler/source/crd/controller.go index 85741668728..0e136cbdd96 100644 --- a/pkg/reconciler/source/crd/controller.go +++ b/pkg/reconciler/source/crd/controller.go @@ -80,7 +80,7 @@ func NewController( logger.Info("Setting up event handlers") crdInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ - FilterFunc: pkgreconciler.LabelFilterFunc(sources.SourceDuckAnnotationKey, sources.SourceDuckAnnotationValue, false), + FilterFunc: pkgreconciler.LabelFilterFunc(sources.SourceDuckLabelKey, sources.SourceDuckLabelValue, false), Handler: controller.HandleAll(impl.Enqueue), }) diff --git a/pkg/reconciler/source/crd/controller_test.go b/pkg/reconciler/source/crd/controller_test.go new file mode 100644 index 00000000000..cf77fbae20e --- /dev/null +++ b/pkg/reconciler/source/crd/controller_test.go @@ -0,0 +1,37 @@ +/* +Copyright 2020 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 crd + +import ( + "testing" + + "knative.dev/pkg/configmap" + . "knative.dev/pkg/reconciler/testing" + + // Fake injection informers + _ "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition/fake" +) + +func TestNew(t *testing.T) { + ctx, _ := SetupFakeContext(t) + + c := NewController(ctx, configmap.NewStaticWatcher()) + + if c == nil { + t.Fatal("Expected NewController to return a non-nil value") + } +} diff --git a/pkg/reconciler/source/crd/crd_test.go b/pkg/reconciler/source/crd/crd_test.go new file mode 100644 index 00000000000..7d783dcd9e2 --- /dev/null +++ b/pkg/reconciler/source/crd/crd_test.go @@ -0,0 +1,104 @@ +/* +Copyright 2020 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 crd + +import ( + "context" + "testing" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" + "knative.dev/eventing/pkg/apis/sources" + "knative.dev/pkg/client/injection/ducks/duck/v1/source" + "knative.dev/pkg/configmap" + "knative.dev/pkg/controller" + logtesting "knative.dev/pkg/logging/testing" + + . "knative.dev/eventing/pkg/reconciler/testing" + . "knative.dev/pkg/reconciler/testing" + + // Fake injection informers + _ "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/eventtype/fake" + _ "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition/fake" + _ "knative.dev/pkg/client/injection/ducks/duck/v1/source/fake" +) + +const ( + crdName = "test-crd" + crdGroup = "testing.sources.knative.dev" + crdKind = "TestSource" + crdPlural = "testsources" + crdVersionServed = "v1alpha1" +) + +func TestAllCases(t *testing.T) { + table := TableTest{{ + Name: "bad workqueue key", + // Make sure Reconcile handles bad keys. + Key: "too/many/parts", + }, { + Name: "key not found", + // Make sure Reconcile handles good keys that don't exist. + Key: "not-found", + }, { + Name: "reconcile failed, cannot find GVR or GVK", + Objects: []runtime.Object{ + NewCustomResourceDefinition(crdName, + WithCustomResourceDefinitionLabels(map[string]string{ + sources.SourceDuckLabelKey: sources.SourceDuckLabelValue, + })), + }, + Key: crdName, + WantErr: true, + WantEvents: []string{ + Eventf(corev1.EventTypeWarning, "SourceCRDReconcileFailed", "Source CRD reconciliation failed: unable to find GVR or GVK for %s", crdName), + }, + }, + //}, { + // TODO uncomment the following once we figure out why the eventtype informer is missing from the duck.controller. + //Name: "reconcile succeeded", + //Objects: []runtime.Object{ + // NewCustomResourceDefinition(crdName, + // WithCustomResourceDefinitionLabels(map[string]string{ + // sources.SourceDuckLabelKey: sources.SourceDuckLabelValue, + // }), + // WithCustomResourceDefinitionGroup(crdGroup), + // WithCustomResourceDefinitionNames(apiextensionsv1beta1.CustomResourceDefinitionNames{ + // Kind: crdKind, + // Plural: crdPlural, + // }), + // WithCustomResourceDefinitionVersions([]apiextensionsv1beta1.CustomResourceDefinitionVersion{{ + // Name: crdVersionServed, + // Served: true, + // }})), + //}, + //Key: crdName, + } + + logger := logtesting.TestLogger(t) + table.Test(t, MakeFactory(func(ctx context.Context, listers *Listers, cmw configmap.Watcher) controller.Reconciler { + ctx = source.WithDuck(ctx) + return &Reconciler{ + crdLister: listers.GetCustomResourceDefinitionLister(), + ogctx: ctx, + ogcmw: cmw, + recorder: controller.GetEventRecorder(ctx), + } + }, + false, logger, + )) +} diff --git a/pkg/reconciler/source/duck/controller.go b/pkg/reconciler/source/duck/controller.go index 4b239a9dbeb..6a5f363b4b8 100644 --- a/pkg/reconciler/source/duck/controller.go +++ b/pkg/reconciler/source/duck/controller.go @@ -23,17 +23,15 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/tools/cache" - "knative.dev/pkg/apis/duck" "knative.dev/pkg/configmap" "knative.dev/pkg/controller" "knative.dev/pkg/injection" - "knative.dev/pkg/injection/clients/dynamicclient" "knative.dev/pkg/logging" eventingclient "knative.dev/eventing/pkg/client/injection/client" eventtypeinformer "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/eventtype" - duckv1 "knative.dev/pkg/apis/duck/v1" crdinfomer "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition" + sourceinformer "knative.dev/pkg/client/injection/ducks/duck/v1/source" ) const ( @@ -50,28 +48,21 @@ func NewController(crd string, gvr schema.GroupVersionResource, gvk schema.Group logger := logging.FromContext(ctx) eventTypeInformer := eventtypeinformer.Get(ctx) crdInformer := crdinfomer.Get(ctx) + sourceduckInformer := sourceinformer.Get(ctx) - // Create a duck TypedInformer for duckv1.Source resources. - sourceinformer := &duck.TypedInformerFactory{ - Client: dynamicclient.Get(ctx), - Type: &duckv1.Source{}, - ResyncPeriod: controller.DefaultResyncPeriod, - StopChannel: ctx.Done(), - } - - sourceInformer, sourceLister, err := sourceinformer.Get(gvr) + sourceInformer, sourceLister, err := sourceduckInformer.Get(gvr) if err != nil { logger.Errorw("Error getting source informer", zap.String("GVR", gvr.String()), zap.Error(err)) return nil } r := &Reconciler{ + eventingClientSet: eventingclient.Get(ctx), eventTypeLister: eventTypeInformer.Lister(), crdLister: crdInformer.Lister(), sourceLister: sourceLister, gvr: gvr, crdName: crd, - eventingClientSet: eventingclient.Get(ctx), } impl := controller.NewImpl(r, logger, ReconcilerName) diff --git a/pkg/reconciler/source/duck/controller_test.go b/pkg/reconciler/source/duck/controller_test.go new file mode 100644 index 00000000000..69e7d8babe4 --- /dev/null +++ b/pkg/reconciler/source/duck/controller_test.go @@ -0,0 +1,51 @@ +/* +Copyright 2020 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 duck + +import ( + "testing" + + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/configmap" + . "knative.dev/pkg/reconciler/testing" + + // Fake injection informers + _ "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/eventtype/fake" + _ "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition/fake" + _ "knative.dev/pkg/client/injection/ducks/duck/v1/source/fake" +) + +func TestNew(t *testing.T) { + ctx, _ := SetupFakeContext(t) + + gvr := schema.GroupVersionResource{ + Group: "testing.sources.knative.dev", + Version: "v1alpha1", + Resource: "testsources", + } + gvk := schema.GroupVersionKind{ + Group: "testing.sources.knative.dev", + Version: "v1alpha1", + Kind: "TestSource", + } + crd := "testsources.testing.sources.knative.dev" + + c := NewController(crd, gvr, gvk)(ctx, configmap.NewStaticWatcher()) + if c == nil { + t.Fatal("Expected NewController to return a non-nil value") + } +} diff --git a/pkg/reconciler/source/duck/duck_test.go b/pkg/reconciler/source/duck/duck_test.go new file mode 100644 index 00000000000..7d19987d13f --- /dev/null +++ b/pkg/reconciler/source/duck/duck_test.go @@ -0,0 +1,209 @@ +/* +Copyright 2020 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 duck + +import ( + "context" + "crypto/md5" + "fmt" + "testing" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + clientgotesting "k8s.io/client-go/testing" + "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake" + "knative.dev/eventing/pkg/reconciler/source/duck/resources" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/client/injection/ducks/duck/v1/source" + "knative.dev/pkg/configmap" + "knative.dev/pkg/controller" + logtesting "knative.dev/pkg/logging/testing" + "knative.dev/pkg/ptr" + + . "knative.dev/eventing/pkg/reconciler/testing" + . "knative.dev/pkg/reconciler/testing" +) + +const ( + testNS = "test-namespace" + sourceName = "test-source" + sourceUID = "test-source-uid" + sinkName = "testsink" + + crdName = "testsources.testing.sources.knative.dev" +) + +var ( + brokerDest = duckv1.Destination{ + Ref: &duckv1.KReference{ + Name: sinkName, + Kind: "Broker", + APIVersion: "eventing.knative.dev/v1alpha1", + }, + } + + gvr = schema.GroupVersionResource{ + Group: "testing.sources.knative.dev", + Version: "v1alpha1", + Resource: "testsources", + } + + gvk = schema.GroupVersionKind{ + Group: "testing.sources.knative.dev", + Version: "v1alpha1", + Kind: "TestSource", + } +) + +func TestAllCases(t *testing.T) { + // key := testNS + "/" + sourceName + table := + TableTest{{ + Name: "bad workqueue key", + // Make sure Reconcile handles bad keys. + Key: "too/many/parts", + }, { + Name: "key not found", + // Make sure Reconcile handles good keys that don't exist. + Key: "foo/not-found", + }, { + Name: "valid source with broker sink, create event types", + Objects: []runtime.Object{ + makeSource([]duckv1.CloudEventAttributes{{ + Type: "my-type-1", + Source: "my-source-1", + }, { + Type: "my-type-2", + Source: "my-source-1", + }}), + }, + Key: testNS + "/" + sourceName, + WantCreates: []runtime.Object{ + makeEventType("my-type-1", "my-source-1"), + makeEventType("my-type-2", "my-source-1"), + }, + }, { + Name: "valid source with broker sink, delete event type", + Objects: []runtime.Object{ + makeSource([]duckv1.CloudEventAttributes{{ + Type: "my-type-1", + Source: "my-source-1", + }, { + Type: "my-type-2", + Source: "my-source-1", + }}), + // https://github.com/knative/pkg/issues/411 + // Be careful adding more EventTypes here, the current unit test lister does not + // return items in a fixed order, so the EventTypes can come back in any order. + // WantDeletes requires the order to be correct, so will be flaky if we add more + // than one EventType here. + makeEventTypeWithName("other-type", "my-source-1", "name-1"), + }, + Key: testNS + "/" + sourceName, + WantDeletes: []clientgotesting.DeleteActionImpl{ + {Name: "name-1"}, + }, + WantCreates: []runtime.Object{ + makeEventType("my-type-1", "my-source-1"), + makeEventType("my-type-2", "my-source-1"), + }, + }, { + Name: "valid source with broker sink, create missing event types", + Objects: []runtime.Object{ + makeSource([]duckv1.CloudEventAttributes{{ + Type: "my-type-1", + Source: "my-source-1", + }, { + Type: "my-type-2", + Source: "my-source-1", + }}), + makeEventType("my-type-1", "my-source-1"), + }, + Key: testNS + "/" + sourceName, + WantCreates: []runtime.Object{ + makeEventType("my-type-2", "my-source-1"), + }, + // TODO add tests that read the CRD registry annotation. + }} + + logger := logtesting.TestLogger(t) + table.Test(t, MakeFactory(func(ctx context.Context, listers *Listers, cmw configmap.Watcher) controller.Reconciler { + ctx = source.WithDuck(ctx) + _, sourceLister, _ := source.Get(ctx).Get(gvr) + return &Reconciler{ + crdLister: listers.GetCustomResourceDefinitionLister(), + eventTypeLister: listers.GetEventTypeLister(), + sourceLister: sourceLister, + gvr: gvr, + crdName: crdName, + eventingClientSet: fakeeventingclient.Get(ctx), + } + }, + false, logger, + )) +} + +func makeSource(attributes []duckv1.CloudEventAttributes) *duckv1.Source { + return &duckv1.Source{ + TypeMeta: metav1.TypeMeta{ + Kind: gvk.Kind, + APIVersion: gvk.GroupVersion().String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: sourceName, + Namespace: testNS, + UID: sourceUID, + }, + Spec: duckv1.SourceSpec{ + Sink: brokerDest, + }, + Status: duckv1.SourceStatus{ + CloudEventAttributes: attributes, + }, + } +} + +func makeEventType(ceType, ceSource string) *v1alpha1.EventType { + return &v1alpha1.EventType{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("%x", md5.Sum([]byte(ceType+ceSource+sourceUID))), + Labels: resources.Labels(sourceName), + Namespace: testNS, + OwnerReferences: []metav1.OwnerReference{{ + APIVersion: gvk.GroupVersion().String(), + Kind: gvk.Kind, + Name: sourceName, + UID: sourceUID, + BlockOwnerDeletion: ptr.Bool(true), + Controller: ptr.Bool(true), + }}, + }, + Spec: v1alpha1.EventTypeSpec{ + Type: ceType, + Source: ceSource, + Broker: sinkName, + }, + } +} + +func makeEventTypeWithName(ceType, ceSource, name string) *v1alpha1.EventType { + et := makeEventType(ceType, ceSource) + et.Name = name + return et +} diff --git a/pkg/reconciler/source/duck/resources/eventtype_test.go b/pkg/reconciler/source/duck/resources/eventtype_test.go new file mode 100644 index 00000000000..2de919879a7 --- /dev/null +++ b/pkg/reconciler/source/duck/resources/eventtype_test.go @@ -0,0 +1,85 @@ +/* +Copyright 2020 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 resources + +import ( + "crypto/md5" + "fmt" + "testing" + + "github.com/google/go-cmp/cmp" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/ptr" +) + +func TestMakeEventType(t *testing.T) { + args := &EventTypeArgs{ + Source: &duckv1.Source{ + ObjectMeta: metav1.ObjectMeta{ + Name: "source-name", + Namespace: "source-namespace", + UID: "source-uid", + }, + TypeMeta: metav1.TypeMeta{ + APIVersion: "testing.sources.knative.dev/v1alpha1", + Kind: "TestSource", + }, + Spec: duckv1.SourceSpec{ + Sink: duckv1.Destination{ + Ref: &duckv1.KReference{ + Name: "sink-name", + }, + }, + }, + }, + CeType: "my-type", + CeSource: "my-source", + CeSchema: "my-schema", + Description: "my-description", + } + + got := MakeEventType(args) + + want := &v1alpha1.EventType{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("%x", md5.Sum([]byte("my-type"+"my-source"+"my-schema"+"source-uid"))), + Labels: Labels("source-name"), + Namespace: "source-namespace", + OwnerReferences: []metav1.OwnerReference{{ + APIVersion: "testing.sources.knative.dev/v1alpha1", + Kind: "TestSource", + Name: "source-name", + UID: "source-uid", + BlockOwnerDeletion: ptr.Bool(true), + Controller: ptr.Bool(true), + }}, + }, + Spec: v1alpha1.EventTypeSpec{ + Type: "my-type", + Source: "my-source", + Schema: "my-schema", + Description: "my-description", + Broker: "sink-name", + }, + } + + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("unexpected difference (-want, +got) = %v", diff) + } +} diff --git a/pkg/reconciler/testing/customresourcedefinition.go b/pkg/reconciler/testing/customresourcedefinition.go index 85cdf03139d..20f51a11305 100644 --- a/pkg/reconciler/testing/customresourcedefinition.go +++ b/pkg/reconciler/testing/customresourcedefinition.go @@ -43,3 +43,21 @@ func WithCustomResourceDefinitionLabels(labels map[string]string) CustomResource crd.Labels = labels } } + +func WithCustomResourceDefinitionVersions(versions []apiextensionsv1beta1.CustomResourceDefinitionVersion) CustomResourceDefinitionOption { + return func(crd *apiextensionsv1beta1.CustomResourceDefinition) { + crd.Spec.Versions = versions + } +} + +func WithCustomResourceDefinitionGroup(group string) CustomResourceDefinitionOption { + return func(crd *apiextensionsv1beta1.CustomResourceDefinition) { + crd.Spec.Group = group + } +} + +func WithCustomResourceDefinitionNames(names apiextensionsv1beta1.CustomResourceDefinitionNames) CustomResourceDefinitionOption { + return func(crd *apiextensionsv1beta1.CustomResourceDefinition) { + crd.Spec.Names = names + } +} diff --git a/pkg/reconciler/testing/listers.go b/pkg/reconciler/testing/listers.go index 9d644929d86..3365e97c6f6 100644 --- a/pkg/reconciler/testing/listers.go +++ b/pkg/reconciler/testing/listers.go @@ -46,6 +46,7 @@ import ( messaginglisters "knative.dev/eventing/pkg/client/listers/messaging/v1alpha1" sourcelisters "knative.dev/eventing/pkg/client/listers/sources/v1alpha1" sourcev1alpha2listers "knative.dev/eventing/pkg/client/listers/sources/v1alpha2" + duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/reconciler/testing" ) @@ -54,11 +55,17 @@ var subscriberAddToScheme = func(scheme *runtime.Scheme) error { return nil } +var sourceAddToScheme = func(scheme *runtime.Scheme) error { + scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "testing.sources.knative.dev", Version: "v1alpha1", Kind: "TestSource"}, &duckv1.Source{}) + return nil +} + var clientSetSchemes = []func(*runtime.Scheme) error{ fakekubeclientset.AddToScheme, fakeeventingclientset.AddToScheme, fakeapiextensionsclientset.AddToScheme, subscriberAddToScheme, + sourceAddToScheme, } type Listers struct {