Skip to content

Commit ff6c49e

Browse files
committed
Upgrade golangci-lint and fix warnings
1 parent c94ec71 commit ff6c49e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+124
-124
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
run:
5-
deadline: 30m
5+
timeout: 30m
66

77
linters:
88
# please, do not use `enable-all`: it's deprecated and will be removed soon.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ all: generate license fix vet fmt test lint tidy
1616
go install github.com/google/[email protected]
1717

1818
"$(MYGOBIN)/golangci-lint":
19-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
19+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
2020

2121
"$(MYGOBIN)/deepcopy-gen":
2222
go install k8s.io/code-generator/cmd/[email protected]

pkg/apply/applier.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ func (a *Applier) Run(ctx context.Context, invInfo inventory.Info, objects objec
213213
}
214214
// Create a new TaskStatusRunner to execute the taskQueue.
215215
klog.V(4).Infoln("applier building TaskStatusRunner...")
216-
allIds := object.UnstructuredSetToObjMetadataSet(append(applyObjs, pruneObjs...))
216+
allIDs := object.UnstructuredSetToObjMetadataSet(append(applyObjs, pruneObjs...))
217217
statusWatcher := a.statusWatcher
218218
// Disable watcher for dry runs
219219
if opts.DryRunStrategy.ClientOrServerDryRun() {
220220
statusWatcher = watcher.BlindStatusWatcher{}
221221
}
222-
runner := taskrunner.NewTaskStatusRunner(allIds, statusWatcher)
222+
runner := taskrunner.NewTaskStatusRunner(allIDs, statusWatcher)
223223
klog.V(4).Infoln("applier running TaskStatusRunner...")
224224
err = runner.Run(ctx, taskContext, taskQueue.ToChannel(), taskrunner.Options{
225225
EmitStatusEvents: options.EmitStatusEvents,

pkg/apply/destroyer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ func (d *Destroyer) Run(ctx context.Context, invInfo inventory.Info, options Des
176176
}
177177
// Create a new TaskStatusRunner to execute the taskQueue.
178178
klog.V(4).Infoln("destroyer building TaskStatusRunner...")
179-
deleteIds := object.UnstructuredSetToObjMetadataSet(deleteObjs)
179+
deleteIDs := object.UnstructuredSetToObjMetadataSet(deleteObjs)
180180
statusWatcher := d.statusWatcher
181181
// Disable watcher for dry runs
182182
if opts.DryRunStrategy.ClientOrServerDryRun() {
183183
statusWatcher = watcher.BlindStatusWatcher{}
184184
}
185-
runner := taskrunner.NewTaskStatusRunner(deleteIds, statusWatcher)
185+
runner := taskrunner.NewTaskStatusRunner(deleteIDs, statusWatcher)
186186
klog.V(4).Infoln("destroyer running TaskStatusRunner...")
187187
err = runner.Run(ctx, taskContext, taskQueue.ToChannel(), taskrunner.Options{
188188
EmitStatusEvents: options.EmitStatusEvents,

pkg/apply/prune/prune_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,9 @@ func TestPrune(t *testing.T) {
574574
for _, obj := range tc.clusterObjs {
575575
clusterObjs = append(clusterObjs, obj)
576576
}
577-
pruneIds := object.UnstructuredSetToObjMetadataSet(tc.pruneObjs)
577+
pruneIDs := object.UnstructuredSetToObjMetadataSet(tc.pruneObjs)
578578
po := Pruner{
579-
InvClient: inventory.NewFakeClient(pruneIds),
579+
InvClient: inventory.NewFakeClient(pruneIDs),
580580
Client: fake.NewSimpleDynamicClient(scheme.Scheme, clusterObjs...),
581581
Mapper: testrestmapper.TestOnlyStaticRESTMapper(scheme.Scheme,
582582
scheme.Scheme.PrioritizedVersionsAllGroups()...),
@@ -620,21 +620,21 @@ func TestPrune(t *testing.T) {
620620
for _, id := range tc.expectedFailed {
621621
assert.Truef(t, im.IsFailedDelete(id), "Prune() should mark object as failed: %s", id)
622622
}
623-
for _, id := range pruneIds.Diff(tc.expectedFailed) {
623+
for _, id := range pruneIDs.Diff(tc.expectedFailed) {
624624
assert.Falsef(t, im.IsFailedDelete(id), "Prune() should NOT mark object as failed: %s", id)
625625
}
626626
// validate record of skipped prunes
627627
for _, id := range tc.expectedSkipped {
628628
assert.Truef(t, im.IsSkippedDelete(id), "Prune() should mark object as skipped: %s", id)
629629
}
630-
for _, id := range pruneIds.Diff(tc.expectedSkipped) {
630+
for _, id := range pruneIDs.Diff(tc.expectedSkipped) {
631631
assert.Falsef(t, im.IsSkippedDelete(id), "Prune() should NOT mark object as skipped: %s", id)
632632
}
633633
// validate record of abandoned objects
634634
for _, id := range tc.expectedAbandoned {
635635
assert.Truef(t, taskContext.IsAbandonedObject(id), "Prune() should mark object as abandoned: %s", id)
636636
}
637-
for _, id := range pruneIds.Diff(tc.expectedAbandoned) {
637+
for _, id := range pruneIDs.Diff(tc.expectedAbandoned) {
638638
assert.Falsef(t, taskContext.IsAbandonedObject(id), "Prune() should NOT mark object as abandoned: %s", id)
639639
}
640640
})
@@ -761,9 +761,9 @@ func TestPruneWithErrors(t *testing.T) {
761761
}
762762
for name, tc := range tests {
763763
t.Run(name, func(t *testing.T) {
764-
pruneIds := object.UnstructuredSetToObjMetadataSet(tc.pruneObjs)
764+
pruneIDs := object.UnstructuredSetToObjMetadataSet(tc.pruneObjs)
765765
po := Pruner{
766-
InvClient: inventory.NewFakeClient(pruneIds),
766+
InvClient: inventory.NewFakeClient(pruneIDs),
767767
// Set up the fake dynamic client to recognize all objects, and the RESTMapper.
768768
Client: &fakeDynamicClient{
769769
resourceInterface: &failureNamespaceClient{},
@@ -867,10 +867,10 @@ func TestGetPruneObjs(t *testing.T) {
867867
if len(tc.expectedObjs) != len(actualObjs) {
868868
t.Fatalf("expected %d prune objs, got %d", len(tc.expectedObjs), len(actualObjs))
869869
}
870-
actualIds := object.UnstructuredSetToObjMetadataSet(actualObjs)
871-
expectedIds := object.UnstructuredSetToObjMetadataSet(tc.expectedObjs)
872-
if !object.ObjMetadataSetEquals(expectedIds, actualIds) {
873-
t.Errorf("expected prune objects (%v), got (%v)", expectedIds, actualIds)
870+
actualIDs := object.UnstructuredSetToObjMetadataSet(actualObjs)
871+
expectedIDs := object.UnstructuredSetToObjMetadataSet(tc.expectedObjs)
872+
if !object.ObjMetadataSetEquals(expectedIDs, actualIDs) {
873+
t.Errorf("expected prune objects (%v), got (%v)", expectedIDs, actualIDs)
874874
}
875875
})
876876
}

pkg/apply/solver/solver.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ func (t *TaskQueueBuilder) Build(taskContext *taskrunner.TaskContext, o Options)
182182
t.newApplyTask(applySet, t.ApplyFilters, t.ApplyMutators, o))
183183
// dry-run skips wait tasks
184184
if !o.DryRunStrategy.ClientOrServerDryRun() {
185-
applyIds := object.UnstructuredSetToObjMetadataSet(applySet)
185+
applyIDs := object.UnstructuredSetToObjMetadataSet(applySet)
186186
tasks = append(tasks,
187-
t.newWaitTask(applyIds, taskrunner.AllCurrent, o.ReconcileTimeout))
187+
t.newWaitTask(applyIDs, taskrunner.AllCurrent, o.ReconcileTimeout))
188188
}
189189
}
190190
}
@@ -206,14 +206,14 @@ func (t *TaskQueueBuilder) Build(taskContext *taskrunner.TaskContext, o Options)
206206
t.newPruneTask(pruneSet, t.PruneFilters, o))
207207
// dry-run skips wait tasks
208208
if !o.DryRunStrategy.ClientOrServerDryRun() {
209-
pruneIds := object.UnstructuredSetToObjMetadataSet(pruneSet)
209+
pruneIDs := object.UnstructuredSetToObjMetadataSet(pruneSet)
210210
tasks = append(tasks,
211-
t.newWaitTask(pruneIds, taskrunner.AllNotFound, o.PruneTimeout))
211+
t.newWaitTask(pruneIDs, taskrunner.AllNotFound, o.PruneTimeout))
212212
}
213213
}
214214
}
215215

216-
prevInvIds, _ := t.InvClient.GetClusterObjs(t.invInfo)
216+
prevInvIDs, _ := t.InvClient.GetClusterObjs(t.invInfo)
217217
klog.V(2).Infoln("adding delete/update inventory task")
218218
var taskName string
219219
if o.Destroy {
@@ -225,7 +225,7 @@ func (t *TaskQueueBuilder) Build(taskContext *taskrunner.TaskContext, o Options)
225225
TaskName: taskName,
226226
InvClient: t.InvClient,
227227
InvInfo: t.invInfo,
228-
PrevInventory: prevInvIds,
228+
PrevInventory: prevInvIDs,
229229
DryRun: o.DryRunStrategy,
230230
Destroy: o.Destroy,
231231
})
@@ -257,13 +257,13 @@ func (t *TaskQueueBuilder) newApplyTask(applyObjs object.UnstructuredSet,
257257

258258
// AppendWaitTask appends a task to wait on the passed objects to the task queue.
259259
// Returns a pointer to the Builder to chain function calls.
260-
func (t *TaskQueueBuilder) newWaitTask(waitIds object.ObjMetadataSet, condition taskrunner.Condition,
260+
func (t *TaskQueueBuilder) newWaitTask(waitIDs object.ObjMetadataSet, condition taskrunner.Condition,
261261
waitTimeout time.Duration) taskrunner.Task {
262-
waitIds = t.Collector.FilterInvalidIds(waitIds)
262+
waitIDs = t.Collector.FilterInvalidIds(waitIDs)
263263
klog.V(2).Infoln("adding wait task")
264264
task := taskrunner.NewWaitTask(
265265
fmt.Sprintf("wait-%d", t.waitCounter),
266-
waitIds,
266+
waitIDs,
267267
condition,
268268
waitTimeout,
269269
t.Mapper,

pkg/apply/solver/solver_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,8 @@ func TestTaskQueueBuilder_ApplyBuild(t *testing.T) {
808808
}
809809
}
810810

811-
applyIds := object.UnstructuredSetToObjMetadataSet(tc.applyObjs)
812-
fakeInvClient := inventory.NewFakeClient(applyIds)
811+
applyIDs := object.UnstructuredSetToObjMetadataSet(tc.applyObjs)
812+
fakeInvClient := inventory.NewFakeClient(applyIDs)
813813
vCollector := &validation.Collector{}
814814
tqb := TaskQueueBuilder{
815815
Pruner: pruner,
@@ -1484,8 +1484,8 @@ func TestTaskQueueBuilder_PruneBuild(t *testing.T) {
14841484
}
14851485
}
14861486

1487-
pruneIds := object.UnstructuredSetToObjMetadataSet(tc.pruneObjs)
1488-
fakeInvClient := inventory.NewFakeClient(pruneIds)
1487+
pruneIDs := object.UnstructuredSetToObjMetadataSet(tc.pruneObjs)
1488+
fakeInvClient := inventory.NewFakeClient(pruneIDs)
14891489
vCollector := &validation.Collector{}
14901490
tqb := TaskQueueBuilder{
14911491
Pruner: pruner,

pkg/apply/task/apply_task_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,22 +492,22 @@ func TestApplyTaskWithError(t *testing.T) {
492492
assert.Equal(t, tc.expectedEvents[i].ApplyEvent.Error.Error(), e.ApplyEvent.Error.Error())
493493
}
494494

495-
applyIds := object.UnstructuredSetToObjMetadataSet(tc.objs)
495+
applyIDs := object.UnstructuredSetToObjMetadataSet(tc.objs)
496496

497497
im := taskContext.InventoryManager()
498498

499499
// validate record of failed prunes
500500
for _, id := range tc.expectedFailed {
501501
assert.Truef(t, im.IsFailedApply(id), "ApplyTask should mark object as failed: %s", id)
502502
}
503-
for _, id := range applyIds.Diff(tc.expectedFailed) {
503+
for _, id := range applyIDs.Diff(tc.expectedFailed) {
504504
assert.Falsef(t, im.IsFailedApply(id), "ApplyTask should NOT mark object as failed: %s", id)
505505
}
506506
// validate record of skipped prunes
507507
for _, id := range tc.expectedSkipped {
508508
assert.Truef(t, im.IsSkippedApply(id), "ApplyTask should mark object as skipped: %s", id)
509509
}
510-
for _, id := range applyIds.Diff(tc.expectedSkipped) {
510+
for _, id := range applyIDs.Diff(tc.expectedSkipped) {
511511
assert.Falsef(t, im.IsSkippedApply(id), "ApplyTask should NOT mark object as skipped: %s", id)
512512
}
513513
})

pkg/apply/task/inv_add_task_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ func TestInvAddTask(t *testing.T) {
158158
if taskName != task.Name() {
159159
t.Errorf("expected task name (%s), got (%s)", taskName, task.Name())
160160
}
161-
applyIds := object.UnstructuredSetToObjMetadataSet(tc.applyObjs)
162-
if !task.Identifiers().Equal(applyIds) {
163-
t.Errorf("expected task ids (%s), got (%s)", applyIds, task.Identifiers())
161+
applyIDs := object.UnstructuredSetToObjMetadataSet(tc.applyObjs)
162+
if !task.Identifiers().Equal(applyIDs) {
163+
t.Errorf("expected task ids (%s), got (%s)", applyIDs, task.Identifiers())
164164
}
165165
task.Start(context)
166166
result := <-context.TaskChannel()

pkg/apply/taskrunner/task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type WaitTask struct {
5656
// TaskName allows providing a name for the task.
5757
TaskName string
5858
// Ids is the full list of resources that we are waiting for.
59-
Ids object.ObjMetadataSet
59+
Ids object.ObjMetadataSet //nolint:revive
6060
// Condition defines the status we want all resources to reach
6161
Condition Condition
6262
// Timeout defines how long we are willing to wait for the condition

0 commit comments

Comments
 (0)