Skip to content

Commit cccff91

Browse files
committed
Fix lint errors
1 parent 440e011 commit cccff91

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

pkg/controller/controller.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type Controller interface {
5454
Start(stop <-chan struct{}) error
5555
}
5656

57+
// New returns a new Controller registered with mrg.
5758
func New(name string, mrg manager.Manager, options Options) (Controller, error) {
5859
if options.Reconcile == nil {
5960
return nil, fmt.Errorf("must specify Reconcile")
@@ -67,6 +68,14 @@ func New(name string, mrg manager.Manager, options Options) (Controller, error)
6768
options.MaxConcurrentReconciles = 1
6869
}
6970

71+
if options.Reconcile == nil {
72+
options.Reconcile = reconcile.Func(func(o reconcile.Request) (reconcile.Result, error) {
73+
log.Error(nil, "Reconcile function not implemented", "Controller", name)
74+
fmt.Printf("Received Reconcile request on Controller %s for %s/%s", name, o.Namespace, o.Name)
75+
return reconcile.Result{}, nil
76+
})
77+
}
78+
7079
// Inject dependencies into Reconcile
7180
if err := mrg.SetFields(options.Reconcile); err != nil {
7281
return nil, err
@@ -84,7 +93,6 @@ func New(name string, mrg manager.Manager, options Options) (Controller, error)
8493
Name: name,
8594
}
8695

87-
// Add the controller as a Manager componentsw
88-
mrg.Add(c)
89-
return c, nil
96+
// Add the controller as a Manager components
97+
return c, mrg.Add(c)
9098
}

pkg/handler/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License.
1515
*/
1616

1717
/*
18-
Package eventhandler defines EventHandlers that enqueue reconcile.Requests in response to Create, Update, Deletion Events
18+
Package handler defines EventHandlers that enqueue reconcile.Requests in response to Create, Update, Deletion Events
1919
observed from Watching Kubernetes APIs.
2020
2121
EventHandlers

pkg/internal/controller/controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ var log = logf.KBLog.WithName("controller")
4141

4242
var _ inject.Injector = &Controller{}
4343

44+
// Controller implements controller.Controller
4445
type Controller struct {
4546
// Name is used to uniquely identify a Controller in tracing, logging and monitoring. Name is required.
4647
Name string
@@ -89,6 +90,7 @@ type Controller struct {
8990
// TODO(community): Consider initializing a logger with the Controller Name as the tag
9091
}
9192

93+
// Watch implements controller.Controller
9294
func (c *Controller) Watch(src source.Source, evthdler handler.EventHandler, prct ...predicate.Predicate) error {
9395
c.mu.Lock()
9496
defer c.mu.Unlock()
@@ -112,6 +114,7 @@ func (c *Controller) Watch(src source.Source, evthdler handler.EventHandler, prc
112114
return src.Start(evthdler, c.Queue, prct...)
113115
}
114116

117+
// Start implements controller.Controller
115118
func (c *Controller) Start(stop <-chan struct{}) error {
116119
c.mu.Lock()
117120
defer c.mu.Unlock()

pkg/manager/internal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (cm *controllerManager) SetFields(i interface{}) error {
9393
if _, err := inject.CacheInto(cm.cache, i); err != nil {
9494
return err
9595
}
96-
if _, err := inject.InjectInjector(cm.SetFields, i); err != nil {
96+
if _, err := inject.InjectorInto(cm.SetFields, i); err != nil {
9797
return err
9898
}
9999
return nil

pkg/runtime/inject/inject.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ type Scheme interface {
7474
InjectScheme(scheme *runtime.Scheme) error
7575
}
7676

77-
// SchemeInto will set client and return the result on i if it implements Scheme. Returns
77+
// SchemeInto will set scheme and return the result on i if it implements Scheme. Returns
7878
// false if i does not implement Scheme.
7979
func SchemeInto(scheme *runtime.Scheme, i interface{}) (bool, error) {
8080
if is, ok := i.(Scheme); ok {
@@ -86,11 +86,14 @@ func SchemeInto(scheme *runtime.Scheme, i interface{}) (bool, error) {
8686
// Func injects dependencies into i.
8787
type Func func(i interface{}) error
8888

89+
// Injector is used by the ControllerManager to inject Func into Controllers
8990
type Injector interface {
9091
InjectFunc(f Func) error
9192
}
9293

93-
func InjectInjector(f Func, i interface{}) (bool, error) {
94+
// InjectorInto will set f and return the result on i if it implements Injector. Returns
95+
// false if i does not implement Injector.
96+
func InjectorInto(f Func, i interface{}) (bool, error) {
9497
if ii, ok := i.(Injector); ok {
9598
return true, ii.InjectFunc(f)
9699
}

0 commit comments

Comments
 (0)