Skip to content

Commit 474a608

Browse files
committed
More linter corrections
1 parent e8b2fc1 commit 474a608

9 files changed

Lines changed: 29 additions & 31 deletions

internal/controller/aggregates_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ func (r *AggregatesController) Reconcile(ctx context.Context, req ctrl.Request)
8989

9090
if len(toRemove) > 0 {
9191
log.Info("Removing", "aggregates", toRemove)
92-
for item, _ := range toRemove {
92+
for item := range toRemove {
9393
err = removeFromAggregate(ctx, r.computeClient, aggs, computeHost, item)
9494
if err != nil {
9595
return ctrl.Result{}, err
9696
}
9797
}
9898
}
9999

100-
_, err = setNodeAnnotations(ctx, r.Client, node, map[string]string{annotationAggregatesApplied: node.Annotations[annotationAggregates]})
100+
err = setNodeAnnotations(ctx, r.Client, node, map[string]string{annotationAggregatesApplied: node.Annotations[annotationAggregates]})
101101

102102
return ctrl.Result{}, err
103103
}

internal/controller/decomission_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var _ = Describe("Decommission Controller", func() {
6565
resource := &corev1.Node{
6666
ObjectMeta: metav1.ObjectMeta{
6767
Name: nodeName,
68-
Labels: map[string]string{labelEvictionRequired: "true"},
68+
Labels: map[string]string{labelEvictionRequired: "true"}, //nolint:goconst
6969
},
7070
}
7171
Expect(k8sClient.Create(ctx, resource)).To(Succeed())

internal/controller/maintenance_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (r *MaintenanceController) ensureSignallingDeployment(ctx context.Context,
176176
deployment.Labels = labels
177177

178178
podLabels := maps.Clone(labels)
179-
podLabels[labelCriticalComponent] = "true"
179+
podLabels[labelCriticalComponent] = "true" //nolint:goconst
180180

181181
var command []string
182182
if ready {

internal/controller/maintenance_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var _ = Describe("Maintenance Controller", func() {
6565
resource := &corev1.Node{
6666
ObjectMeta: metav1.ObjectMeta{
6767
Name: nodeName,
68-
Labels: map[string]string{labelEvictionRequired: "true"},
68+
Labels: map[string]string{labelEvictionRequired: "true"}, //nolint:goconst
6969
},
7070
}
7171
Expect(k8sClient.Create(ctx, resource)).To(Succeed())

internal/controller/node_certificate_controller.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ import (
3535
logger "sigs.k8s.io/controller-runtime/pkg/log"
3636
)
3737

38-
const ()
39-
4038
type NodeCertificateController struct {
4139
k8sclient.Client
4240
Scheme *runtime.Scheme

internal/controller/node_eviction_label_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (r *NodeEvictionLabelReconciler) Reconcile(ctx context.Context, req ctrl.Re
9191

9292
var value string
9393
if _, onboarding := node.Labels[labelOnboardingState]; !onboarding {
94-
value = "true"
94+
value = "true" //nolint:goconst
9595
} else {
9696
// check for existing eviction, else create it
9797
value, err = r.reconcileEviction(ctx, eviction, node, hostname, maintenanceValue)
@@ -102,7 +102,7 @@ func (r *NodeEvictionLabelReconciler) Reconcile(ctx context.Context, req ctrl.Re
102102

103103
if value != "" {
104104
newNode := node.DeepCopy()
105-
if value == "true" {
105+
if value == "true" { //nolint:goconst
106106
evictAgentsLabels(newNode.Labels)
107107
}
108108
newNode.Labels[labelEvictionApproved] = maintenanceValue
@@ -136,7 +136,7 @@ func (r *NodeEvictionLabelReconciler) reconcileEviction(ctx context.Context, evi
136136
// check if the eviction is already succeeded
137137
switch eviction.Status.EvictionState {
138138
case "Succeeded":
139-
return "true", nil
139+
return "true", nil //nolint:goconst
140140
case "Failed":
141141
return "false", nil
142142
default:

internal/controller/onboarding_controller.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ func (r *OnboardingController) createOrGetTestServer(ctx context.Context, zone,
324324
}
325325

326326
imagesList, err := images.ExtractImages(imagePages)
327+
if err != nil {
328+
return nil, err
329+
}
330+
327331
for _, image := range imagesList {
328332
if image.Name == testImageName {
329333
imageRef = image.ID
@@ -362,23 +366,19 @@ func (r *OnboardingController) createOrGetTestServer(ctx context.Context, zone,
362366
Name: serverName,
363367
AvailabilityZone: fmt.Sprintf("%v:%v", zone, computeHost),
364368
FlavorRef: flavorRef,
365-
BlockDevice: []servers.BlockDevice{
366-
servers.BlockDevice{
367-
UUID: imageRef,
368-
BootIndex: 0,
369-
SourceType: "image",
370-
VolumeSize: 64,
371-
DiskBus: "virtio",
372-
DeleteOnTermination: true,
373-
DestinationType: "volume",
374-
VolumeType: testVolumeType,
375-
},
376-
},
377-
Networks: []servers.Network{
378-
servers.Network{
379-
UUID: networkRef,
380-
},
381-
},
369+
BlockDevice: []servers.BlockDevice{{
370+
UUID: imageRef,
371+
BootIndex: 0,
372+
SourceType: "image",
373+
VolumeSize: 64,
374+
DiskBus: "virtio",
375+
DeleteOnTermination: true,
376+
DestinationType: "volume",
377+
VolumeType: testVolumeType,
378+
}},
379+
Networks: []servers.Network{{
380+
UUID: networkRef,
381+
}},
382382
}, nil).Extract()
383383

384384
if err != nil {

internal/controller/onboarding_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var _ = Describe("Onboarding Controller", func() {
6565
resource := &corev1.Node{
6666
ObjectMeta: metav1.ObjectMeta{
6767
Name: nodeName,
68-
Labels: map[string]string{labelEvictionRequired: "true"},
68+
Labels: map[string]string{labelEvictionRequired: "true"}, //nolint:goconst
6969
},
7070
}
7171
Expect(k8sClient.Create(ctx, resource)).To(Succeed())

internal/controller/traits_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (r *TraitsController) Reconcile(ctx context.Context, req ctrl.Request) (ctr
9191
}
9292
}
9393

94-
for item, _ := range toAdd {
94+
for item := range toAdd {
9595
targetTraitsSet[item] = true
9696
}
9797

@@ -107,7 +107,7 @@ func (r *TraitsController) Reconcile(ctx context.Context, req ctrl.Request) (ctr
107107
return ctrl.Result{}, result.Err
108108
}
109109

110-
_, err = setNodeAnnotations(ctx, r.Client, node, map[string]string{annotationAppliedCustomTraits: node.Annotations[annotationCustomTraits]})
110+
err = setNodeAnnotations(ctx, r.Client, node, map[string]string{annotationAppliedCustomTraits: node.Annotations[annotationCustomTraits]})
111111

112112
return ctrl.Result{}, err
113113
}
@@ -142,7 +142,7 @@ func extractTraits(node *corev1.Node, key string) (values map[string]bool) {
142142
// returns all elements in b not in a
143143
func difference(a, b map[string]bool) (diff map[string]bool) {
144144
diff = make(map[string]bool, 0)
145-
for item, _ := range b {
145+
for item := range b {
146146
_, found := a[item]
147147
if !found {
148148
diff[item] = true

0 commit comments

Comments
 (0)