Skip to content

Commit 1927d7d

Browse files
authored
Use new 1.23.6 builder (#3652)
* Use new 1.23.6 builder Signed-off-by: Alex Kalenyuk <[email protected]> * Bump linter to 1.60.3 for go 1.23 support Signed-off-by: Alex Kalenyuk <[email protected]> * Disable linter failures over G115 Signed-off-by: Alex Kalenyuk <[email protected]> * Fix lint issues related to error format formatting Signed-off-by: Alex Kalenyuk <[email protected]> * Address remaining lint failures len is enough/sprintf not really used Signed-off-by: Alex Kalenyuk <[email protected]> --------- Signed-off-by: Alex Kalenyuk <[email protected]>
1 parent 67d1f3d commit 1927d7d

File tree

16 files changed

+24
-21
lines changed

16 files changed

+24
-21
lines changed

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@ linters-settings:
4949
forbid-focus-container: true
5050
nakedret:
5151
max-func-lines: 0
52+
gosec:
53+
excludes:
54+
# This is changing things up quite a bit and requires evaluation
55+
# per conversion
56+
- G115

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module kubevirt.io/containerized-data-importer
22

3-
go 1.22.0
3+
go 1.23.0
44

55
require (
66
cloud.google.com/go/storage v1.38.0

hack/build/config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ FUNC_TEST_PROXY="cdi-func-test-proxy"
2929
FUNC_TEST_POPULATOR="cdi-func-test-sample-populator"
3030

3131
# update this whenever new builder tag is created
32-
BUILDER_IMAGE=${BUILDER_IMAGE:-quay.io/kubevirt/kubevirt-cdi-bazel-builder:2409021308-e6939c6c2}
32+
BUILDER_IMAGE=${BUILDER_IMAGE:-quay.io/kubevirt/kubevirt-cdi-bazel-builder:2503021312-67d1f3d4d}
3333

3434
BINARIES="cmd/${OPERATOR} cmd/${CONTROLLER} cmd/${IMPORTER} cmd/${CLONER} cmd/${APISERVER} cmd/${UPLOADPROXY} cmd/${UPLOADSERVER} cmd/${OPERATOR} tools/${FUNC_TEST_INIT} tools/${FUNC_TEST_REGISTRY_INIT} tools/${FUNC_TEST_BAD_WEBSERVER} tools/${FUNC_TEST_PROXY} tools/${FUNC_TEST_POPULATOR}"
3535
CDI_PKGS="cmd/ pkg/ test/"

hack/build/run-linters.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh -ex
22

3-
GOLANGCI_VERSION="${GOLANGCI_VERSION:-v1.58.0}"
3+
GOLANGCI_VERSION="${GOLANGCI_VERSION:-v1.60.3}"
44
MONITORING_LINTER_VERSION="${MONITORING_LINTER_VERSION:-e2be790}"
55

66
go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_VERSION}"

pkg/apiserver/webhooks/cdi-validate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
sdkapi "kubevirt.io/controller-lifecycle-operator-sdk/api"
3535
)
3636

37-
const uninstallErrorMsg = "Rejecting the uninstall request, since there are still DataVolumes present. Either delete all DataVolumes or change the uninstall strategy before uninstalling CDI."
37+
const uninstallErrorMsg = "rejecting the uninstall request, since there are still %d DataVolumes present. Either delete all DataVolumes or change the uninstall strategy before uninstalling CDI"
3838

3939
type cdiValidatingWebhook struct {
4040
client cdiclient.Interface
@@ -69,8 +69,8 @@ func (wh *cdiValidatingWebhook) Admit(ar admissionv1.AdmissionReview) *admission
6969
return toAdmissionResponseError(err)
7070
}
7171

72-
if len(dvs.Items) > 0 {
73-
return toAdmissionResponseError(fmt.Errorf(uninstallErrorMsg))
72+
if numDvs := len(dvs.Items); numDvs > 0 {
73+
return toAdmissionResponseError(fmt.Errorf(uninstallErrorMsg, numDvs))
7474
}
7575
}
7676

pkg/apiserver/webhooks/cdi-validate_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ var _ = Describe("CDI Delete Webhook", func() {
155155

156156
resp := validateCDIs(ar, newDataVolumeWithName("foo"))
157157
Expect(resp.Allowed).To(BeFalse())
158-
Expect(resp.Result.Message).To(ContainSubstring("Rejecting the uninstall request, since there are still DataVolumes present."))
158+
Expect(resp.Result.Message).To(ContainSubstring("rejecting the uninstall request, since there are still 1 DataVolumes present."))
159159
})
160160

161161
It("should reject with DataVolumes present and oldobject not populated", func() {
@@ -187,7 +187,7 @@ var _ = Describe("CDI Delete Webhook", func() {
187187

188188
resp := validateCDIs(ar, cdi, newDataVolumeWithName("foo"))
189189
Expect(resp.Allowed).To(BeFalse())
190-
Expect(resp.Result.Message).To(ContainSubstring("Rejecting the uninstall request, since there are still DataVolumes present."))
190+
Expect(resp.Result.Message).To(ContainSubstring("rejecting the uninstall request, since there are still 1 DataVolumes present."))
191191
})
192192

193193
It("should allow error CDI to be deleted with DataVolumes present", func() {

pkg/controller/datavolume/controller-base.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ func (r *ReconcilerBase) validatePVC(dv *cdiv1.DataVolume, pvc *corev1.Persisten
716716
if pvc.DeletionTimestamp != nil {
717717
msg := fmt.Sprintf(MessageResourceMarkedForDeletion, pvc.Name)
718718
r.recorder.Event(dv, corev1.EventTypeWarning, ErrResourceMarkedForDeletion, msg)
719-
return errors.Errorf(msg)
719+
return errors.New(msg)
720720
}
721721
// If the PVC is not controlled by this DataVolume resource, we should log
722722
// a warning to the event recorder and return
@@ -732,7 +732,7 @@ func (r *ReconcilerBase) validatePVC(dv *cdiv1.DataVolume, pvc *corev1.Persisten
732732
} else {
733733
msg := fmt.Sprintf(MessageResourceExists, pvc.Name)
734734
r.recorder.Event(dv, corev1.EventTypeWarning, ErrResourceExists, msg)
735-
return errors.Errorf(msg)
735+
return errors.New(msg)
736736
}
737737
}
738738
return nil

pkg/controller/populators/forklift-populator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func (r *ForkliftPopulatorReconciler) reconcileTargetPVC(pvc, pvcPrime *corev1.P
321321
return reconcile.Result{}, nil
322322
}
323323

324-
if pod.Status.ContainerStatuses == nil || len(pod.Status.ContainerStatuses) == 0 {
324+
if len(pod.Status.ContainerStatuses) == 0 {
325325
return reconcile.Result{RequeueAfter: 2 * time.Second}, nil
326326
}
327327

pkg/image/qemu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (o *qemuOperations) Info(url *url.URL) (*ImgInfo, error) {
217217
if nbdkitLog, err := os.ReadFile(common.NbdkitLogPath); err == nil {
218218
errorMsg += " " + string(nbdkitLog)
219219
}
220-
return nil, errors.Errorf(errorMsg)
220+
return nil, errors.New(errorMsg)
221221
}
222222
return checkOutputQemuImgInfo(output, url.String())
223223
}

pkg/importer/gcs-datasource.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package importer
22

33
import (
44
"context"
5-
"fmt"
65
"io"
76
"net/url"
87
"path/filepath"
@@ -56,7 +55,7 @@ func NewGCSDataSource(endpoint, keyFile string) (*GCSDataSource, error) {
5655
ep, err := ParseEndpoint(endpoint)
5756

5857
if err != nil {
59-
return nil, errors.Wrapf(err, fmt.Sprintf("GCS Importer: unable to parse endpoint %q", endpoint))
58+
return nil, errors.Wrapf(err, "GCS Importer: unable to parse endpoint %q", endpoint)
6059
}
6160

6261
// Getting Context

0 commit comments

Comments
 (0)