From b4c496757c6c06d3fdbc7f4fb57f7b0bb678d057 Mon Sep 17 00:00:00 2001 From: Evan Cordell Date: Fri, 1 Mar 2024 16:30:40 -0500 Subject: [PATCH] fix linter errors --- cmd/spicedb-operator/main.go | 2 +- pkg/cmd/run/run.go | 2 +- pkg/controller/check_migrations_test.go | 6 +++--- pkg/controller/cleanup_job_test.go | 8 ++++---- pkg/controller/controller.go | 18 +++++++++--------- pkg/controller/ensure_deployment_test.go | 10 +++++----- pkg/controller/pause_test.go | 4 ++-- pkg/controller/run_migration_test.go | 6 +++--- pkg/controller/secret_adoption_test.go | 10 +++++----- pkg/controller/validate_config_test.go | 4 ++-- pkg/controller/wait_for_migrations_test.go | 4 ++-- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/cmd/spicedb-operator/main.go b/cmd/spicedb-operator/main.go index 6877151e..ea418e35 100644 --- a/cmd/spicedb-operator/main.go +++ b/cmd/spicedb-operator/main.go @@ -23,7 +23,7 @@ func main() { versionCmd := &cobra.Command{ Use: "version", Short: "display operator version information", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { fmt.Println(version.UsageVersion(includeDeps)) }, } diff --git a/pkg/cmd/run/run.go b/pkg/cmd/run/run.go index 8eca3d1e..98339579 100644 --- a/pkg/cmd/run/run.go +++ b/pkg/cmd/run/run.go @@ -61,7 +61,7 @@ func NewCmdRun(o *Options) *cobra.Command { Use: "run [flags]", DisableFlagsInUseLine: true, Short: "run SpiceDB operator", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { ctx := genericapiserver.SetupSignalContext() cmdutil.CheckErr(o.Validate()) cmdutil.CheckErr(o.Run(ctx, f)) diff --git a/pkg/controller/check_migrations_test.go b/pkg/controller/check_migrations_test.go index 32b02568..161b95fa 100644 --- a/pkg/controller/check_migrations_test.go +++ b/pkg/controller/check_migrations_test.go @@ -115,13 +115,13 @@ func TestCheckMigrationsHandler(t *testing.T) { var called handler.Key h := &MigrationCheckHandler{ recorder: recorder, - nextDeploymentHandler: handler.ContextHandlerFunc(func(ctx context.Context) { + nextDeploymentHandler: handler.ContextHandlerFunc(func(_ context.Context) { called = HandlerDeploymentKey }), - nextWaitForJobHandler: handler.ContextHandlerFunc(func(ctx context.Context) { + nextWaitForJobHandler: handler.ContextHandlerFunc(func(_ context.Context) { called = HandlerWaitForMigrationsKey }), - nextMigrationRunHandler: handler.ContextHandlerFunc(func(ctx context.Context) { + nextMigrationRunHandler: handler.ContextHandlerFunc(func(_ context.Context) { called = HandlerMigrationRunKey }), } diff --git a/pkg/controller/cleanup_job_test.go b/pkg/controller/cleanup_job_test.go index fdeb99c2..c761ada4 100644 --- a/pkg/controller/cleanup_job_test.go +++ b/pkg/controller/cleanup_job_test.go @@ -159,17 +159,17 @@ func TestCleanupJobsHandler(t *testing.T) { deletedPods := make([]string, 0) deletedJobs := make([]string, 0) h := &JobCleanupHandler{ - getJobs: func(ctx context.Context) []*batchv1.Job { + getJobs: func(_ context.Context) []*batchv1.Job { return tt.existingJobs }, - getJobPods: func(ctx context.Context) []*corev1.Pod { + getJobPods: func(_ context.Context) []*corev1.Pod { return tt.existingJobPods }, - deletePod: func(ctx context.Context, nn types.NamespacedName) error { + deletePod: func(_ context.Context, nn types.NamespacedName) error { deletedPods = append(deletedPods, nn.Name) return nil }, - deleteJob: func(ctx context.Context, nn types.NamespacedName) error { + deleteJob: func(_ context.Context, nn types.NamespacedName) error { deletedJobs = append(deletedJobs, nn.Name) return nil }, diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 7c2f11eb..6090f63f 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -108,9 +108,9 @@ func NewController(ctx context.Context, registry *typed.Registry, dclient dynami if len(configFilePath) > 0 { inf := fileInformerFactory.ForResource(fileinformer.FileGroupVersion.WithResource(configFilePath)).Informer() if _, err := inf.AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { c.loadConfig(configFilePath) }, - UpdateFunc: func(_, obj interface{}) { c.loadConfig(configFilePath) }, - DeleteFunc: func(obj interface{}) { c.loadConfig(configFilePath) }, + AddFunc: func(_ any) { c.loadConfig(configFilePath) }, + UpdateFunc: func(_, _ any) { c.loadConfig(configFilePath) }, + DeleteFunc: func(_ any) { c.loadConfig(configFilePath) }, }); err != nil { return nil, err } @@ -126,8 +126,8 @@ func NewController(ctx context.Context, registry *typed.Registry, dclient dynami nil, ) if _, err := ownedInformerFactory.ForResource(v1alpha1ClusterGVR).Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { c.enqueue(v1alpha1ClusterGVR, obj) }, - UpdateFunc: func(_, obj interface{}) { c.enqueue(v1alpha1ClusterGVR, obj) }, + AddFunc: func(obj any) { c.enqueue(v1alpha1ClusterGVR, obj) }, + UpdateFunc: func(_, obj any) { c.enqueue(v1alpha1ClusterGVR, obj) }, // Delete is not used right now, we rely on ownerrefs to clean up }); err != nil { return nil, err @@ -158,9 +158,9 @@ func NewController(ctx context.Context, registry *typed.Registry, dclient dynami return nil, err } if _, err := inf.AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { c.syncExternalResource(obj) }, - UpdateFunc: func(_, obj interface{}) { c.syncExternalResource(obj) }, - DeleteFunc: func(obj interface{}) { c.syncExternalResource(obj) }, + AddFunc: func(obj any) { c.syncExternalResource(obj) }, + UpdateFunc: func(_, obj any) { c.syncExternalResource(obj) }, + DeleteFunc: func(obj any) { c.syncExternalResource(obj) }, }); err != nil { return nil, err } @@ -447,7 +447,7 @@ func (c *Controller) secretAdopter(next ...handler.Handler) handler.Handler { QueueOps.RequeueAPIErr(ctx, err) } // keep checking to see if the secret is added - QueueOps.Requeue(ctx) + QueueOps.RequeueErr(ctx, err) }, typed.IndexerFor[*corev1.Secret](c.Registry, typed.NewRegistryKey(DependentFactoryKey, secretsGVR)), func(ctx context.Context, secret *applycorev1.SecretApplyConfiguration, options metav1.ApplyOptions) (*corev1.Secret, error) { diff --git a/pkg/controller/ensure_deployment_test.go b/pkg/controller/ensure_deployment_test.go index 3aa65a5d..c7573f7d 100644 --- a/pkg/controller/ensure_deployment_test.go +++ b/pkg/controller/ensure_deployment_test.go @@ -366,22 +366,22 @@ func TestEnsureDeploymentHandler(t *testing.T) { var called handler.Key h := &DeploymentHandler{ - applyDeployment: func(ctx context.Context, dep *applyappsv1.DeploymentApplyConfiguration) (*appsv1.Deployment, error) { + applyDeployment: func(_ context.Context, _ *applyappsv1.DeploymentApplyConfiguration) (*appsv1.Deployment, error) { applyCalled = true return nil, nil }, - deleteDeployment: func(ctx context.Context, nn types.NamespacedName) error { + deleteDeployment: func(_ context.Context, _ types.NamespacedName) error { deleteCalled = true return nil }, - getDeploymentPods: func(ctx context.Context) []*corev1.Pod { + getDeploymentPods: func(_ context.Context) []*corev1.Pod { return tt.pods }, - patchStatus: func(ctx context.Context, patch *v1alpha1.SpiceDBCluster) error { + patchStatus: func(_ context.Context, _ *v1alpha1.SpiceDBCluster) error { patchCalled = true return nil }, - next: handler.ContextHandlerFunc(func(ctx context.Context) { + next: handler.ContextHandlerFunc(func(_ context.Context) { called = nextKey }), } diff --git a/pkg/controller/pause_test.go b/pkg/controller/pause_test.go index a3961c53..cbd3740e 100644 --- a/pkg/controller/pause_test.go +++ b/pkg/controller/pause_test.go @@ -107,7 +107,7 @@ func TestPauseHandler(t *testing.T) { ctx = CtxCluster.WithValue(ctx, tt.cluster) ctx = CtxCluster.WithValue(ctx, tt.cluster) var called handler.Key - NewPauseHandler(func(ctx context.Context, patch *v1alpha1.SpiceDBCluster) error { + NewPauseHandler(func(_ context.Context, patch *v1alpha1.SpiceDBCluster) error { patchCalled = true if tt.patchError != nil { @@ -123,7 +123,7 @@ func TestPauseHandler(t *testing.T) { }), "conditions not equal:\na: %#v\nb: %#v", tt.expectConditions, patch.Status.Conditions) return nil - }, handler.ContextHandlerFunc(func(ctx context.Context) { + }, handler.ContextHandlerFunc(func(_ context.Context) { called = nextKey })).Handle(ctx) diff --git a/pkg/controller/run_migration_test.go b/pkg/controller/run_migration_test.go index cbb22709..535ff18e 100644 --- a/pkg/controller/run_migration_test.go +++ b/pkg/controller/run_migration_test.go @@ -102,14 +102,14 @@ func TestRunMigrationHandler(t *testing.T) { ctx = CtxMigrationHash.WithValue(ctx, tt.migrationHash) h := &MigrationRunHandler{ - patchStatus: func(ctx context.Context, patch *v1alpha1.SpiceDBCluster) error { + patchStatus: func(_ context.Context, _ *v1alpha1.SpiceDBCluster) error { return nil }, - applyJob: func(ctx context.Context, job *applybatchv1.JobApplyConfiguration) error { + applyJob: func(_ context.Context, _ *applybatchv1.JobApplyConfiguration) error { applyCalled = true return tt.jobApplyErr }, - deleteJob: func(ctx context.Context, nn types.NamespacedName) error { + deleteJob: func(_ context.Context, _ types.NamespacedName) error { deleteCalled = true return tt.jobDeleteErr }, diff --git a/pkg/controller/secret_adoption_test.go b/pkg/controller/secret_adoption_test.go index 44834533..54eef041 100644 --- a/pkg/controller/secret_adoption_test.go +++ b/pkg/controller/secret_adoption_test.go @@ -30,7 +30,7 @@ func TestSecretAdopterHandler(t *testing.T) { err error } - secretNotFound := func(name string) error { + secretNotFound := func(_ string) error { return apierrors.NewNotFound( corev1.SchemeGroupVersion.WithResource("secrets").GroupResource(), "test") @@ -308,21 +308,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) { diff --git a/pkg/controller/validate_config_test.go b/pkg/controller/validate_config_test.go index 84405330..0b169c11 100644 --- a/pkg/controller/validate_config_test.go +++ b/pkg/controller/validate_config_test.go @@ -243,12 +243,12 @@ func TestValidateConfigHandler(t *testing.T) { }) var called handler.Key h := &ValidateConfigHandler{ - patchStatus: func(ctx context.Context, patch *v1alpha1.SpiceDBCluster) error { + patchStatus: func(_ context.Context, _ *v1alpha1.SpiceDBCluster) error { patchCalled = true return nil }, recorder: recorder, - next: handler.ContextHandlerFunc(func(ctx context.Context) { + next: handler.ContextHandlerFunc(func(_ context.Context) { called = nextKey }), } diff --git a/pkg/controller/wait_for_migrations_test.go b/pkg/controller/wait_for_migrations_test.go index 2b2aa3b7..d08e5d9d 100644 --- a/pkg/controller/wait_for_migrations_test.go +++ b/pkg/controller/wait_for_migrations_test.go @@ -66,10 +66,10 @@ func TestWaitForMigrationsHandler(t *testing.T) { var called handler.Key h := &WaitForMigrationsHandler{ recorder: recorder, - nextSelfPause: handler.ContextHandlerFunc(func(ctx context.Context) { + nextSelfPause: handler.ContextHandlerFunc(func(_ context.Context) { called = HandlerSelfPauseKey }), - nextDeploymentHandler: handler.ContextHandlerFunc(func(ctx context.Context) { + nextDeploymentHandler: handler.ContextHandlerFunc(func(_ context.Context) { called = HandlerDeploymentKey }), }