Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 2 additions & 4 deletions pkg/reconciler/v1alpha1/broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -58,9 +57,8 @@ const (
)

type reconciler struct {
client client.Client
restConfig *rest.Config
recorder record.EventRecorder
client client.Client
recorder record.EventRecorder

logger *zap.Logger

Expand Down
16 changes: 7 additions & 9 deletions pkg/reconciler/v1alpha1/broker/broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -70,11 +69,11 @@ var (

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

func TestProvideController(t *testing.T) {
//TODO(grantr) This needs a mock of manager.Manager. Creating a manager
// TODO(grantr) This needs a mock of manager.Manager. Creating a manager
// with a fake Config fails because the Manager tries to contact the
// apiserver.

Expand Down Expand Up @@ -189,7 +188,7 @@ func TestReconcile(t *testing.T) {
// differ from expected.
// TODO uncomment the following line once our test framework supports searching for
// GenerateName.
//makeDifferentChannel(),
// makeDifferentChannel(),
},
WantEvent: []corev1.Event{
{
Expand Down Expand Up @@ -535,7 +534,7 @@ func TestReconcile(t *testing.T) {
WantPresent: []runtime.Object{
makeReadyBroker(),
// TODO Uncomment makeChannel() when our test framework handles generateName.
//makeChannel(),
// makeChannel(),
makeFilterDeployment(),
makeFilterService(),
makeIngressDeployment(),
Expand All @@ -553,10 +552,9 @@ func TestReconcile(t *testing.T) {
recorder := tc.GetEventRecorder()

r := &reconciler{
client: c,
restConfig: &rest.Config{},
recorder: recorder,
logger: zap.NewNop(),
client: c,
recorder: recorder,
logger: zap.NewNop(),

filterImage: filterImage,
filterServiceAccountName: filterSA,
Expand Down
6 changes: 2 additions & 4 deletions pkg/reconciler/v1alpha1/namespace/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand Down Expand Up @@ -62,9 +61,8 @@ const (
)

type reconciler struct {
client client.Client
restConfig *rest.Config
recorder record.EventRecorder
client client.Client
recorder record.EventRecorder

logger *zap.Logger
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/reconciler/v1alpha1/namespace/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/handler"
Expand Down Expand Up @@ -241,10 +240,9 @@ func TestReconcile(t *testing.T) {
recorder := tc.GetEventRecorder()

r := &reconciler{
client: c,
restConfig: &rest.Config{},
recorder: recorder,
logger: zap.NewNop(),
client: c,
recorder: recorder,
logger: zap.NewNop(),
}
tc.ReconcileKey = fmt.Sprintf("%s/%s", "", testNS)
tc.IgnoreTimes = true
Expand Down
2 changes: 0 additions & 2 deletions pkg/reconciler/v1alpha1/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const (

type reconciler struct {
client client.Client
restConfig *rest.Config
dynamicClient dynamic.Interface
recorder record.EventRecorder

Expand Down Expand Up @@ -159,7 +158,6 @@ func (r *reconciler) InjectClient(c client.Client) error {
}

func (r *reconciler) InjectConfig(c *rest.Config) error {
r.restConfig = c
var err error
r.dynamicClient, err = dynamic.NewForConfig(c)
return err
Expand Down
7 changes: 0 additions & 7 deletions pkg/reconciler/v1alpha1/trigger/trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
"github.com/knative/eventing/pkg/reconciler/names"
controllertesting "github.com/knative/eventing/pkg/reconciler/testing"
Expand Down Expand Up @@ -120,11 +119,6 @@ func TestInjectConfig(t *testing.T) {
t.Fatalf("Unexpected error injecting the config: %v", err)
}

gotCfg := r.restConfig
if diff := cmp.Diff(wantCfg, gotCfg); diff != "" {
t.Errorf("Unexpected config (-want, +got): %v", diff)
}

wantDynClient, err := dynamic.NewForConfig(wantCfg)
if err != nil {
t.Fatalf("Unexpected error generating dynamic client: %v", err)
Expand Down Expand Up @@ -463,7 +457,6 @@ func TestReconcile(t *testing.T) {
r := &reconciler{
client: c,
dynamicClient: dc,
restConfig: &rest.Config{},
recorder: recorder,
logger: zap.NewNop(),
}
Expand Down