Skip to content

Commit

Permalink
dynamic client should have registered types in it's schema
Browse files Browse the repository at this point in the history
  • Loading branch information
dprotaso committed Jun 7, 2021
1 parent db83525 commit f2f7451
Show file tree
Hide file tree
Showing 18 changed files with 8 additions and 129 deletions.
6 changes: 0 additions & 6 deletions pkg/broker/filter/filter_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"go.uber.org/zap/zaptest"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
"knative.dev/pkg/apis"

eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
Expand All @@ -64,11 +63,6 @@ var (
validPath = fmt.Sprintf("/triggers/%s/%s/%s", testNS, triggerName, triggerUID)
)

func init() {
// Add types to scheme.
_ = eventingv1.AddToScheme(scheme.Scheme)
}

func TestReceiver(t *testing.T) {
testCases := map[string]struct {
triggers []*eventingv1.Trigger
Expand Down
6 changes: 0 additions & 6 deletions pkg/duck/listable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,10 @@ import (
"k8s.io/client-go/tools/cache"
"knative.dev/pkg/apis/duck"
duckv1 "knative.dev/pkg/apis/duck/v1"
duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1"
"knative.dev/pkg/client/injection/ducks/duck/v1alpha1/addressable"
fakedynamicclient "knative.dev/pkg/injection/clients/dynamicclient/fake"
)

func init() {
// Add types to scheme
_ = duckv1alpha1.AddToScheme(scheme.Scheme)
}

const ns = "test-ns"

var errTest = errors.New("test error")
Expand Down
11 changes: 0 additions & 11 deletions pkg/duck/subscriber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,12 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"

"k8s.io/client-go/kubernetes/scheme"

eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
duckv1 "knative.dev/pkg/apis/duck/v1"
)

var (
testNS = "testnamespace"
)

func init() {
// Add types to scheme
_ = eventingv1.AddToScheme(scheme.Scheme)
_ = duckv1.AddToScheme(scheme.Scheme)
}

func TestDomainToURL(t *testing.T) {
d := "default-broker.default.svc.cluster.local"
e := fmt.Sprintf("http://%s/", d)
Expand Down
8 changes: 0 additions & 8 deletions pkg/reconciler/apiserversource/apiserversource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
clientgotesting "k8s.io/client-go/testing"

sourcesv1 "knative.dev/eventing/pkg/apis/sources/v1"
Expand Down Expand Up @@ -88,13 +87,6 @@ const (
generation = 1
)

func init() {
// Add types to scheme
_ = appsv1.AddToScheme(scheme.Scheme)
_ = corev1.AddToScheme(scheme.Scheme)
_ = duckv1.AddToScheme(scheme.Scheme)
}

func TestReconcile(t *testing.T) {
table := TableTest{{
Name: "not enough permissions",
Expand Down
8 changes: 0 additions & 8 deletions pkg/reconciler/broker/broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"

clientgotesting "k8s.io/client-go/testing"
"knative.dev/eventing/pkg/apis/eventing"
eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake"
"knative.dev/eventing/pkg/client/injection/ducks/duck/v1/channelable"
"knative.dev/eventing/pkg/client/injection/reconciler/eventing/v1/broker"
Expand Down Expand Up @@ -84,12 +82,6 @@ var (
}
)

func init() {
// Add types to scheme
_ = eventingv1.AddToScheme(scheme.Scheme)
_ = duckv1.AddToScheme(scheme.Scheme)
}

func TestReconcile(t *testing.T) {
table := TableTest{
{
Expand Down
7 changes: 0 additions & 7 deletions pkg/reconciler/broker/trigger/trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
clientgotesting "k8s.io/client-go/testing"
eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
v1 "knative.dev/eventing/pkg/apis/duck/v1"
Expand Down Expand Up @@ -140,12 +139,6 @@ var (
}
)

func init() {
// Add types to scheme
_ = eventingv1.AddToScheme(scheme.Scheme)
_ = duckv1.AddToScheme(scheme.Scheme)
}

func TestReconcile(t *testing.T) {
table := TableTest{
{
Expand Down
10 changes: 1 addition & 9 deletions pkg/reconciler/channel/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
clientgotesting "k8s.io/client-go/testing"
"k8s.io/utils/pointer"
eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1"
fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake"
"knative.dev/eventing/pkg/client/injection/ducks/duck/v1/channelable"
channelreconciler "knative.dev/eventing/pkg/client/injection/reconciler/messaging/v1/channel"
Expand Down Expand Up @@ -58,12 +56,6 @@ var (
}
)

func init() {
// Add types to scheme
_ = messagingv1.AddToScheme(scheme.Scheme)
_ = eventingduckv1.AddToScheme(scheme.Scheme)
}

func TestReconcile(t *testing.T) {

table := TableTest{{
Expand Down Expand Up @@ -325,7 +317,7 @@ func channelCRD() metav1.TypeMeta {
func channelCRDBadGvk() metav1.TypeMeta {
return metav1.TypeMeta{
APIVersion: "",
Kind: "",
Kind: "-BrokenKind",
}
}

Expand Down
8 changes: 0 additions & 8 deletions pkg/reconciler/containersource/containersource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
clientgotesting "k8s.io/client-go/testing"
fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake"
"knative.dev/pkg/apis"
Expand Down Expand Up @@ -76,13 +75,6 @@ var (
}
)

func init() {
// Add types to scheme
_ = appsv1.AddToScheme(scheme.Scheme)
_ = corev1.AddToScheme(scheme.Scheme)
_ = duckv1.AddToScheme(scheme.Scheme)
}

func TestAllCases(t *testing.T) {
table := TableTest{
{
Expand Down
7 changes: 0 additions & 7 deletions pkg/reconciler/eventtype/eventtype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
clientgotesting "k8s.io/client-go/testing"
v1 "knative.dev/eventing/pkg/apis/eventing/v1"
fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake"
"knative.dev/eventing/pkg/client/injection/reconciler/eventing/v1beta1/eventtype"
. "knative.dev/eventing/pkg/reconciler/testing/v1"
Expand All @@ -53,11 +51,6 @@ var (
}
)

func init() {
// Add types to scheme
_ = v1.AddToScheme(scheme.Scheme)
}

func TestReconcile(t *testing.T) {
table := TableTest{{
Name: "bad workqueue key",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
clientgotesting "k8s.io/client-go/testing"
eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
v1 "knative.dev/eventing/pkg/apis/messaging/v1"
"knative.dev/eventing/pkg/reconciler/inmemorychannel/controller/resources"
. "knative.dev/eventing/pkg/reconciler/testing/v1"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
"knative.dev/pkg/configmap"
"knative.dev/pkg/controller"
"knative.dev/pkg/kmeta"
Expand All @@ -67,12 +65,6 @@ const (
imcGeneration = 7
)

func init() {
// Add types to scheme
_ = v1.AddToScheme(scheme.Scheme)
_ = duckv1.AddToScheme(scheme.Scheme)
}

func TestAllCases(t *testing.T) {
imcKey := testNS + "/" + imcName
subscriber1UID := types.UID("2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
clientgotesting "k8s.io/client-go/testing"
"k8s.io/utils/pointer"
"knative.dev/pkg/apis"
Expand Down Expand Up @@ -101,11 +100,6 @@ var (
subscribers = []eventingduckv1.SubscriberSpec{subscriber1, subscriber2}
)

func init() {
// Add types to scheme
_ = v1.AddToScheme(scheme.Scheme)
}

func TestAllCases(t *testing.T) {
backoffPolicy := eventingduckv1.BackoffPolicyLinear

Expand Down
7 changes: 0 additions & 7 deletions pkg/reconciler/parallel/parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
clientgotesting "k8s.io/client-go/testing"
eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
"knative.dev/eventing/pkg/client/injection/ducks/duck/v1/channelable"
Expand Down Expand Up @@ -66,12 +65,6 @@ var (
}
)

func init() {
// Add types to scheme
_ = v1.AddToScheme(scheme.Scheme)
_ = duckv1.AddToScheme(scheme.Scheme)
}

func TestAllBranches(t *testing.T) {
pKey := testNS + "/" + parallelName
imc := &messagingv1.ChannelTemplateSpec{
Expand Down
8 changes: 0 additions & 8 deletions pkg/reconciler/pingsource/pingsource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
clientgotesting "k8s.io/client-go/testing"

"knative.dev/pkg/apis"
Expand Down Expand Up @@ -92,13 +91,6 @@ const (
generation = 1
)

func init() {
// Add types to scheme
_ = appsv1.AddToScheme(scheme.Scheme)
_ = corev1.AddToScheme(scheme.Scheme)
_ = duckv1.AddToScheme(scheme.Scheme)
}

func TestAllCases(t *testing.T) {
table := TableTest{
{
Expand Down
7 changes: 0 additions & 7 deletions pkg/reconciler/sequence/sequence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
clientgotesting "k8s.io/client-go/testing"
v1 "knative.dev/eventing/pkg/apis/flows/v1"
messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1"
Expand Down Expand Up @@ -64,12 +63,6 @@ var (
}
)

func init() {
// Add types to scheme
_ = v1.AddToScheme(scheme.Scheme)
_ = duckv1.AddToScheme(scheme.Scheme)
}

func createReplyChannel(channelName string) *duckv1.Destination {
return &duckv1.Destination{
Ref: &duckv1.KReference{
Expand Down
7 changes: 7 additions & 0 deletions pkg/reconciler/source/crd/crd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
. "knative.dev/pkg/reconciler/testing"

// Fake injection informers

_ "knative.dev/eventing/pkg/client/injection/informers/eventing/v1beta1/eventtype/fake"
fakeclient "knative.dev/pkg/client/injection/apiextensions/client/fake"
_ "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition/fake"
Expand Down Expand Up @@ -67,6 +68,12 @@ var crdGVK = schema.GroupVersionKind{
Kind: crdKind,
}

var crdListGVK = schema.GroupVersionKind{
Group: crdGroup,
Version: crdVersionServed,
Kind: crdKind + "List",
}

func TestAllCases(t *testing.T) {
ctx := context.Background()
ctx, _ = injection.Fake.SetupInformers(ctx, &rest.Config{})
Expand Down
11 changes: 0 additions & 11 deletions pkg/reconciler/subscription/subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@ import (
"knative.dev/pkg/injection/clients/dynamicclient"
"knative.dev/pkg/network"

eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
eventingclient "knative.dev/eventing/pkg/client/injection/client"
"knative.dev/eventing/pkg/client/injection/ducks/duck/v1/channelable"

corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
clientgotesting "k8s.io/client-go/testing"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
Expand Down Expand Up @@ -130,14 +127,6 @@ var (
}
)

func init() {
// Add types to scheme
_ = eventingv1.AddToScheme(scheme.Scheme)
_ = duckv1.AddToScheme(scheme.Scheme)
_ = apiextensionsv1.AddToScheme(scheme.Scheme)
_ = messagingv1.AddToScheme(scheme.Scheme)
}

func TestAllCases(t *testing.T) {
linear := eventingduck.BackoffPolicyLinear

Expand Down
6 changes: 0 additions & 6 deletions pkg/reconciler/sugar/namespace/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
v1 "knative.dev/eventing/pkg/apis/eventing/v1"
fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake"
"knative.dev/eventing/pkg/reconciler/sugar/resources"
Expand All @@ -43,11 +42,6 @@ const (
testNS = "test-namespace"
)

func init() {
// Add types to scheme
_ = v1.AddToScheme(scheme.Scheme)
}

func TestEnabledByDefault(t *testing.T) {
// Events
brokerEvent := Eventf(corev1.EventTypeNormal, "BrokerCreated", "Default eventing.knative.dev Broker created.")
Expand Down
Loading

0 comments on commit f2f7451

Please sign in to comment.