Skip to content

Commit

Permalink
fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ecordell committed Mar 1, 2024
1 parent aa151d5 commit bc21aa6
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion cmd/spicedb-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/check_migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}),
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/cleanup_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
18 changes: 9 additions & 9 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/controller/ensure_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}),
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/pause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/run_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,18 @@ 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
},
next: handler.ContextHandlerFunc(func(ctx context.Context) {
next: handler.ContextHandlerFunc(func(_ context.Context) {
nextCalled = true
require.Equal(t, matchingJob, CtxCurrentMigrationJob.MustValue(ctx))
}),
Expand Down
10 changes: 5 additions & 5 deletions pkg/controller/secret_adoption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/validate_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}),
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/wait_for_migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}),
}
Expand Down

0 comments on commit bc21aa6

Please sign in to comment.