Skip to content

Commit 0b746da

Browse files
authored
Merge pull request #2668 from shiftstack/golangci-lint
🌱 Bump golangci-lint to v2
2 parents 91e5fbc + b883c94 commit 0b746da

File tree

9 files changed

+231
-218
lines changed

9 files changed

+231
-218
lines changed

.golangci.yml

Lines changed: 211 additions & 199 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ $(GOVULNCHECK): # Build govulncheck.
278278

279279
.PHONY: lint
280280
lint: $(GOLANGCI_LINT) ## Lint codebase
281-
$(GOLANGCI_LINT) run -v --fast=false
281+
$(GOLANGCI_LINT) run -v
282282

283283
.PHONY: lint-update
284284
lint-update: $(GOLANGCI_LINT) ## Lint codebase
285-
$(GOLANGCI_LINT) run -v --fast=false --fix
285+
$(GOLANGCI_LINT) run -v --fix
286286

287287
lint-fast: $(GOLANGCI_LINT) ## Run only faster linters to detect possible issues
288-
$(GOLANGCI_LINT) run -v --fast=true
288+
$(GOLANGCI_LINT) run -v --fast-only
289289

290290
## --------------------------------------
291291
##@ Generate

controllers/openstackfloatingippool_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (r *OpenStackFloatingIPPoolReconciler) Reconcile(ctx context.Context, req c
9191
return ctrl.Result{}, err
9292
}
9393

94-
if pool.ObjectMeta.DeletionTimestamp.IsZero() {
94+
if pool.DeletionTimestamp.IsZero() {
9595
// Add finalizer if it does not exist
9696
if controllerutil.AddFinalizer(pool, infrav1alpha1.OpenStackFloatingIPPoolFinalizer) {
9797
return ctrl.Result{}, r.Client.Update(ctx, pool)
@@ -125,7 +125,7 @@ func (r *OpenStackFloatingIPPoolReconciler) Reconcile(ctx context.Context, req c
125125

126126
for _, claim := range claims.Items {
127127
log := log.WithValues("claim", claim.Name)
128-
if !claim.ObjectMeta.DeletionTimestamp.IsZero() {
128+
if !claim.DeletionTimestamp.IsZero() {
129129
continue
130130
}
131131

@@ -281,7 +281,7 @@ func (r *OpenStackFloatingIPPoolReconciler) reconcileIPAddresses(ctx context.Con
281281

282282
for i := 0; i < len(ipAddresses.Items); i++ {
283283
ipAddress := &(ipAddresses.Items[i])
284-
if ipAddress.ObjectMeta.DeletionTimestamp.IsZero() {
284+
if ipAddress.DeletionTimestamp.IsZero() {
285285
pool.Status.ClaimedIPs = append(pool.Status.ClaimedIPs, ipAddress.Spec.Address)
286286
continue
287287
}

controllers/openstackmachine_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope
380380

381381
if instanceStatus == nil {
382382
v1beta1conditions.MarkFalse(openStackMachine, infrav1.InstanceReadyCondition, infrav1.InstanceDeletedReason, clusterv1beta1.ConditionSeverityError, infrav1.ServerUnexpectedDeletedMessage)
383-
openStackMachine.SetFailure(capoerrors.DeprecatedCAPIUpdateMachineError, errors.New(infrav1.ServerUnexpectedDeletedMessage)) //nolint:stylecheck // This error is not used as an error
383+
openStackMachine.SetFailure(capoerrors.DeprecatedCAPIUpdateMachineError, errors.New(infrav1.ServerUnexpectedDeletedMessage)) //nolint:staticcheck // This error is not used as an error
384384
return ctrl.Result{}, nil
385385
}
386386

@@ -714,7 +714,7 @@ func (r *OpenStackMachineReconciler) OpenStackClusterToOpenStackMachines(ctx con
714714
log := log.WithValues("objectMapper", "openStackClusterToOpenStackMachine", "namespace", c.Namespace, "openStackCluster", c.Name)
715715

716716
// Don't handle deleted OpenStackClusters
717-
if !c.ObjectMeta.DeletionTimestamp.IsZero() {
717+
if !c.DeletionTimestamp.IsZero() {
718718
log.V(4).Info("OpenStackClusters has a deletion timestamp, skipping mapping.")
719719
return nil
720720
}
@@ -744,7 +744,7 @@ func (r *OpenStackMachineReconciler) requeueOpenStackMachinesForUnpausedCluster(
744744
log := log.WithValues("objectMapper", "clusterToOpenStackMachine", "namespace", c.Namespace, "cluster", c.Name)
745745

746746
// Don't handle deleted clusters
747-
if !c.ObjectMeta.DeletionTimestamp.IsZero() {
747+
if !c.DeletionTimestamp.IsZero() {
748748
log.V(4).Info("Cluster has a deletion timestamp, skipping mapping.")
749749
return nil
750750
}

controllers/openstackserver_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (r *OpenStackServerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
132132
}
133133
}()
134134

135-
if !openStackServer.ObjectMeta.DeletionTimestamp.IsZero() {
135+
if !openStackServer.DeletionTimestamp.IsZero() {
136136
// When moving a cluster, we need to populate the server status with the resources
137137
// that were in another object's status.
138138
// This is because the status is not persisted across CAPI resources moves.
@@ -626,8 +626,8 @@ func (r *OpenStackServerReconciler) getOrCreateIPAddressClaimForFloatingAddress(
626626

627627
// If the OpenStackServer has a ClusterNameLabel, set it on the IPAddressClaim as well.
628628
// This is useful for garbage collection of IPAddressClaims when a Cluster is deleted.
629-
if openStackServer.ObjectMeta.Labels[clusterv1.ClusterNameLabel] != "" {
630-
claim.ObjectMeta.Labels[clusterv1.ClusterNameLabel] = openStackServer.ObjectMeta.Labels[clusterv1.ClusterNameLabel]
629+
if openStackServer.Labels[clusterv1.ClusterNameLabel] != "" {
630+
claim.Labels[clusterv1.ClusterNameLabel] = openStackServer.Labels[clusterv1.ClusterNameLabel]
631631
}
632632

633633
if err := r.Client.Create(ctx, claim); err != nil {

hack/tools/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ROOT_DIR_RELATIVE := ../..
1616
include $(ROOT_DIR_RELATIVE)/common.mk
1717

18-
GOLANGCI_LINT_VERSION ?= v1.64.6
18+
GOLANGCI_LINT_VERSION ?= v2.4.0
1919

2020
# GOTESTSUM version without the leading 'v'
2121
GOTESTSUM_VERSION ?= 1.12.0

pkg/cloud/services/compute/instance.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,19 +311,20 @@ func (s *Service) getBlockDevices(eventObject runtime.Object, instanceSpec *Inst
311311
return nil, fmt.Errorf("block device name 'root' is reserved")
312312
}
313313

314-
if blockDeviceSpec.Storage.Type == infrav1.VolumeBlockDevice {
314+
switch blockDeviceSpec.Storage.Type {
315+
case infrav1.VolumeBlockDevice:
315316
blockDevice, err := s.getOrCreateVolumeBuilder(eventObject, instanceSpec, &blockDeviceSpec, "", fmt.Sprintf("Additional block device for %s", instanceSpec.Name))
316317
if err != nil {
317318
return nil, err
318319
}
319320
bdUUID = blockDevice.ID
320321
sourceType = servers.SourceVolume
321322
destinationType = servers.DestinationVolume
322-
} else if blockDeviceSpec.Storage.Type == infrav1.LocalBlockDevice {
323+
case infrav1.LocalBlockDevice:
323324
sourceType = servers.SourceBlank
324325
destinationType = servers.DestinationLocal
325326
localDiskSizeGiB = blockDeviceSpec.SizeGiB
326-
} else {
327+
default:
327328
return nil, fmt.Errorf("invalid block device type %s", blockDeviceSpec.Storage.Type)
328329
}
329330

pkg/cloud/services/compute/referenced_resources.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ func ResolveServerSpec(ctx context.Context, scope *scope.WithLogger, k8sClient c
5252

5353
// If the server is bound to a cluster, we use the cluster name to generate the port description.
5454
var clusterName string
55-
if openStackServer.ObjectMeta.Labels[clusterv1.ClusterNameLabel] != "" {
56-
clusterName = openStackServer.ObjectMeta.Labels[clusterv1.ClusterNameLabel]
55+
if openStackServer.Labels[clusterv1.ClusterNameLabel] != "" {
56+
clusterName = openStackServer.Labels[clusterv1.ClusterNameLabel]
5757
}
5858

5959
computeService, err := NewService(scope)

test/e2e/shared/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ type OpenStackLogCollector struct {
187187

188188
// CollectMachineLog gets logs for the OpenStack resources related to the given machine.
189189
func (o OpenStackLogCollector) CollectMachineLog(ctx context.Context, managementClusterClient client.Client, m *clusterv1.Machine, outputPath string) error {
190-
Logf("Collecting logs for machine %q and storing them in %q", m.ObjectMeta.Name, outputPath)
190+
Logf("Collecting logs for machine %q and storing them in %q", m.Name, outputPath)
191191

192192
if err := os.MkdirAll(outputPath, 0o750); err != nil {
193193
return fmt.Errorf("couldn't create directory %q for logs: %s", outputPath, err)

0 commit comments

Comments
 (0)