Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Use wire-gen injection for all controllers #1733

Merged
merged 6 commits into from
Sep 22, 2020

Conversation

zhongduo
Copy link
Contributor

Fixes #

Currently some controllers are not using wire-gen. By changing all controller to the same style we can achieve:

  1. consistent coding style for all controllers
  2. easy to support new singleton configuration maps
  3. use same singleton object from the top level.

This PR will be rebased after merge of #1681

Proposed Changes

  • Use wire-gen to generate all controllers.

@zhongduo zhongduo changed the title WIP: Use wire-gen injection for all controllers Use wire-gen injection for all controllers Sep 21, 2020
@zhongduo
Copy link
Contributor Author

/assign @grantr

@zhongduo
Copy link
Contributor Author

/assign @ian-mi

}
}

func newController(ctx context.Context, cmw configmap.Watcher, dataresidencyss *dataresidency.Store) *controller.Impl {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func newController(ctx context.Context, cmw configmap.Watcher, dataresidencyss *dataresidency.Store) *controller.Impl {
func newController(ctx context.Context, cmw configmap.Watcher, drs *dataresidency.Store) *controller.Impl {

}
}

func newController(ctx context.Context, cmw configmap.Watcher, dataresidencyss *dataresidency.Store) *controller.Impl {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func newController(ctx context.Context, cmw configmap.Watcher, dataresidencyss *dataresidency.Store) *controller.Impl {
func newController(ctx context.Context, cmw configmap.Watcher, drs *dataresidency.Store) *controller.Impl {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I was planning to change the name last Friday but somehow it skipped my mind. Thanks.

@@ -44,7 +44,11 @@ import (
func TestNew(t *testing.T) {
ctx, _ := SetupFakeContext(t)

c := NewController(ctx, configmap.NewStaticWatcher(
dataresidencySs := &dataresidency.StoreSingleton{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline this, as we don't use it again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as suggested.

@@ -38,7 +38,11 @@ import (
func TestNew(t *testing.T) {
ctx, _ := SetupFakeContext(t)

c := NewController(ctx, configmap.NewStaticWatcher(
dataresidencySs := &dataresidency.StoreSingleton{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline this, as we don't use it again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as suggested.

@@ -38,7 +38,9 @@ import (
func TestNew(t *testing.T) {
ctx, _ := SetupFakeContext(t)

c := NewController(ctx, configmap.NewStaticWatcher(
ctor := NewConstructor(&dataresidency.StoreSingleton{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would inline the constructor as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as suggested.

@@ -48,7 +48,9 @@ func TestNew(t *testing.T) {

setReconcilerEnv()

c := NewController(ctx, configmap.NewStaticWatcher(
ctor := NewConstructor()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as suggested.

@@ -31,7 +31,9 @@ import (
func TestNew(t *testing.T) {
ctx, _ := SetupFakeContext(t)

c := NewController(ctx, configmap.NewStaticWatcher())
ctor := NewConstructor()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as suggested.

@@ -44,7 +44,9 @@ import (
func TestNew(t *testing.T) {
ctx, _ := SetupFakeContext(t)

c := NewController(ctx, configmap.NewStaticWatcher(
ctor := NewConstructor(&dataresidency.StoreSingleton{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as suggested.

@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-google-knative-gcp-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/broker/controller.go 60.6% 67.6% 7.0
pkg/reconciler/brokercell/controller.go 54.3% 56.8% 2.5
pkg/reconciler/deployment/controller.go 81.8% 84.6% 2.8
pkg/reconciler/trigger/controller.go 69.2% 70.0% 0.8

@ian-mi
Copy link
Contributor

ian-mi commented Sep 22, 2020

/lgtm
/approve

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ian-mi, zhongduo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zhongduo
Copy link
Contributor Author

/retest

@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-google-knative-gcp-integration-tests 2020-09-22 17:32:25.058 +0000 UTC 1/3
pull-google-knative-gcp-wi-tests 2020-09-22 13:39:54.82 +0000 UTC
2020-09-22 17:38:24.902 +0000 UTC
2020-09-22 19:31:24.923 +0000 UTC
2020-09-22 19:45:55.037 +0000 UTC
3/3

Job pull-google-knative-gcp-wi-tests expended all 3 retries without success.

@zhongduo
Copy link
Contributor Author

/retest

@knative-prow-robot knative-prow-robot merged commit b305538 into google:master Sep 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved cla: yes (override cla status due to multiple authors bug) lgtm size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants