Skip to content

Commit

Permalink
fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ecordell committed May 1, 2024
1 parent be1010f commit 596172c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions adopt/adopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ const Owned = "owned"

var (
// AlwaysExistsFunc is an ExistsFunc that always returns nil
AlwaysExistsFunc ExistsFunc = func(ctx context.Context, nn types.NamespacedName) error {
AlwaysExistsFunc ExistsFunc = func(_ context.Context, _ types.NamespacedName) error {
return nil
}
// NoopObjectMissingFunc is an ObjectMissing func that does nothing
NoopObjectMissingFunc = func(ctx context.Context, err error) {}
NoopObjectMissingFunc = func(_ context.Context, _ error) {}
)

// AdoptionHandler implements handler.Handler to "adopt" an existing resource
Expand Down
8 changes: 4 additions & 4 deletions adopt/adopt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,21 +324,21 @@ func TestSecretAdopterHandler(t *testing.T) {
applyCallIndex := 0
s := NewSecretAdoptionHandler(
recorder,
func(ctx context.Context) (*corev1.Secret, error) {
func(_ context.Context) (*corev1.Secret, error) {
return tt.secretInCache, tt.cacheErr
},
func(ctx context.Context, err error) {
func(_ context.Context, err error) {
require.Equal(t, tt.expectObjectMissingErr, err)
},
typed.NewIndexer[*corev1.Secret](indexer),
func(ctx context.Context, secret *applycorev1.SecretApplyConfiguration, opts metav1.ApplyOptions) (result *corev1.Secret, err error) {
func(_ context.Context, secret *applycorev1.SecretApplyConfiguration, _ metav1.ApplyOptions) (result *corev1.Secret, err error) {
defer func() { applyCallIndex++ }()
call := tt.applyCalls[applyCallIndex]
call.called = true
require.Equal(t, call.input, secret, "error on call %d", applyCallIndex)
return call.result, call.err
},
func(ctx context.Context, nn types.NamespacedName) error {
func(_ context.Context, _ types.NamespacedName) error {
return tt.secretExistsErr
},
handler.NewHandlerFromFunc(func(ctx context.Context) {
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func waitForDiscovery(ctx context.Context, config *rest.Config, crds []*apiexten
return err
}

return wait.PollUntilContextTimeout(ctx, crdInstallPollInterval, maxCRDInstallTime, true, func(ctx context.Context) (done bool, err error) {
return wait.PollUntilContextTimeout(ctx, crdInstallPollInterval, maxCRDInstallTime, true, func(_ context.Context) (done bool, err error) {
_, serverGVRs, err := discoveryClient.ServerGroupsAndResources()
if err != nil {
return false, nil
Expand Down
8 changes: 4 additions & 4 deletions component/ensure_component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,23 @@ func TestEnsureServiceHandler(t *testing.T) {
NewIndexedComponent(
indexer,
ownerIndex,
func(ctx context.Context) labels.Selector {
func(_ context.Context) labels.Selector {
return labels.SelectorFromSet(map[string]string{
"example.com/component": "the-main-service-component",
})
}),
hash.NewObjectHash(), hashKey),
ctxOwner,
queueOps,
func(ctx context.Context, apply *applycorev1.ServiceApplyConfiguration) (*corev1.Service, error) {
func(_ context.Context, _ *applycorev1.ServiceApplyConfiguration) (*corev1.Service, error) {
applyCalled = true
return nil, nil
},
func(ctx context.Context, nn types.NamespacedName) error {
func(_ context.Context, _ types.NamespacedName) error {
deleteCalled = true
return nil
},
func(ctx context.Context) *applycorev1.ServiceApplyConfiguration {
func(_ context.Context) *applycorev1.ServiceApplyConfiguration {
return applycorev1.Service("test", "test").
WithLabels(map[string]string{
"example.com/component": "the-main-service-component",
Expand Down
7 changes: 4 additions & 3 deletions manager/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func ExampleNewOwnedResourceController() {

// the controller processes objects on the queue, but doesn't set up any
// informers by default.
controller := NewOwnedResourceController(klogr.New(), "my-controller", gvr, CtxQueue, registry, broadcaster, func(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string) {
// process object
controller := NewOwnedResourceController(klogr.New(), "my-controller", gvr, CtxQueue, registry, broadcaster, func(_ context.Context, gvr schema.GroupVersionResource, namespace, name string) {
fmt.Println("processing", gvr, namespace, name)
})

mgr := NewManager(ctrlmanageropts.RecommendedDebuggingOptions().DebuggingConfiguration, ":", broadcaster, eventSink)
Expand All @@ -54,7 +54,8 @@ func TestControllerQueueDone(t *testing.T) {
broadcaster := record.NewBroadcaster()
eventSink := &typedcorev1.EventSinkImpl{Interface: fake.NewSimpleClientset().CoreV1().Events("")}

controller := NewOwnedResourceController(klogr.New(), "my-controller", gvr, CtxQueue, registry, broadcaster, func(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string) {
controller := NewOwnedResourceController(klogr.New(), "my-controller", gvr, CtxQueue, registry, broadcaster, func(_ context.Context, gvr schema.GroupVersionResource, namespace, name string) {
fmt.Println("processing", gvr, namespace, name)
})

mgr := NewManager(ctrlmanageropts.RecommendedDebuggingOptions().DebuggingConfiguration, ":", broadcaster, eventSink)
Expand Down
6 changes: 3 additions & 3 deletions pause/pause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func ExampleNewPauseContextHandler() {
queueOperations.Key,
"example.com/paused",
ctxObject,
func(ctx context.Context, patch *MyObject) error {
func(_ context.Context, _ *MyObject) error {
// update status
return nil
},
Expand Down Expand Up @@ -184,7 +184,7 @@ func TestPauseHandler(t *testing.T) {
ctrls := &fake.FakeInterface{}
patchCalled := false

patchStatus := func(ctx context.Context, patch *MyObject) error {
patchStatus := func(_ context.Context, patch *MyObject) error {
patchCalled = true

if tt.patchError != nil {
Expand All @@ -209,7 +209,7 @@ func TestPauseHandler(t *testing.T) {
ctx = ctxMyObject.WithValue(ctx, tt.obj)
var called handler.Key

NewPauseContextHandler(queueOps.Key, PauseLabelKey, ctxMyObject, patchStatus, handler.ContextHandlerFunc(func(ctx context.Context) {
NewPauseContextHandler(queueOps.Key, PauseLabelKey, ctxMyObject, patchStatus, handler.ContextHandlerFunc(func(_ context.Context) {
called = nextKey
})).Handle(ctx)

Expand Down
6 changes: 3 additions & 3 deletions static/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func NewStaticController[K bootstrap.KubeResourceObject](log logr.Logger, name s
func (c *Controller[K]) Start(ctx context.Context, _ int) {
inf := c.fileInformerFactory.ForResource(c.staticClusterResource).Informer()
_, err := inf.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) { c.handleStaticResource(ctx) },
UpdateFunc: func(_, obj interface{}) { c.handleStaticResource(ctx) },
DeleteFunc: func(obj interface{}) { c.handleStaticResource(ctx) },
AddFunc: func(_ any) { c.handleStaticResource(ctx) },
UpdateFunc: func(_, _ any) { c.handleStaticResource(ctx) },
DeleteFunc: func(_ any) { c.handleStaticResource(ctx) },
})
if err != nil {
panic("failed to add handlers: " + err.Error())
Expand Down

0 comments on commit 596172c

Please sign in to comment.