diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index 2c9a401e2..5ed5008bb 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.23.1 + go-version: 1.21 - name: Run golangci-lint run: make golangci diff --git a/.golangci.yml b/.golangci.yml index 9de61a5ca..c8d26644d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,10 +2,9 @@ run: tests: true timeout: 15m - issues: - exclude-files: - - third_party/ - - pkg/client/ + skip-files: + - third_party/ + - pkg/client/ skip-dirs-use-default: true linters-settings: @@ -22,9 +21,6 @@ linters-settings: - name: superfluous-else - name: var-declaration - name: duplicated-imports - gosec: - excludes: - - G115 linters: disable-all: true @@ -35,7 +31,7 @@ linters: - staticcheck - gosec - goimports - - govet + - vet - revive issues: diff --git a/Makefile b/Makefile index 3d402dd54..7068aa97b 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ GOFLAGS := BINDIR ?= $(CURDIR)/bin GO_FILES := $(shell find . -type d -name '.cache' -prune -o -type f -name '*.go' -print) -GOLANGCI_LINT_VERSION := v1.61.0 +GOLANGCI_LINT_VERSION := v1.54.0 GOLANGCI_LINT_BINDIR := $(CURDIR)/.golangci-bin GOLANGCI_LINT_BIN := $(GOLANGCI_LINT_BINDIR)/$(GOLANGCI_LINT_VERSION)/golangci-lint diff --git a/build/image/photon/Dockerfile b/build/image/photon/Dockerfile index 09a952597..2729746e9 100644 --- a/build/image/photon/Dockerfile +++ b/build/image/photon/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.23.1 as golang-build +FROM golang:1.22.7 as golang-build WORKDIR /source diff --git a/go.mod b/go.mod index c5a1b6551..c38c892c8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/vmware-tanzu/nsx-operator -go 1.23.1 +go 1.22.5 replace ( github.com/vmware-tanzu/nsx-operator/pkg/apis => ./pkg/apis diff --git a/pkg/apis/go.mod b/pkg/apis/go.mod index 123a81cae..606c7c856 100644 --- a/pkg/apis/go.mod +++ b/pkg/apis/go.mod @@ -1,6 +1,6 @@ module github.com/vmware-tanzu/nsx-operator/pkg/apis -go 1.23.1 +go 1.21 require ( k8s.io/api v0.26.1 diff --git a/pkg/client/go.mod b/pkg/client/go.mod index 4e2577e08..85ac652cb 100644 --- a/pkg/client/go.mod +++ b/pkg/client/go.mod @@ -1,6 +1,6 @@ module github.com/vmware-tanzu/nsx-operator/pkg/client -go 1.23.1 +go 1.22.5 require ( github.com/vmware-tanzu/nsx-operator/pkg/apis v0.0.0-20240813023528-cb525458c6ee @@ -19,7 +19,6 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/josharian/intern v1.0.0 // indirect diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 39f6ae819..1b3cb5bb3 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -227,6 +227,12 @@ func parseCIDRRange(cidr string) (startIP, endIP net.IP, err error) { func calculateOffsetIP(ip net.IP, offset int) (net.IP, error) { ipInt := ipToUint32(ip) ipInt += uint32(offset) + if int(ipInt) < 0 { + return nil, fmt.Errorf("resulting IP is less than 0") + } + if ipInt > 0xFFFFFFFF { + return nil, fmt.Errorf("resulting IP is greater than 255.255.255.255") + } return uint32ToIP(ipInt), nil } diff --git a/pkg/util/utils_test.go b/pkg/util/utils_test.go index c39c19460..a46ca0a9f 100644 --- a/pkg/util/utils_test.go +++ b/pkg/util/utils_test.go @@ -84,7 +84,7 @@ func TestUtil_IsNsInSystemNamespace(t *testing.T) { isCRInSysNs, err := IsSystemNamespace(client, ns.Namespace, nil) if err != nil { - t.Fatalf("%s", err.Error()) + t.Fatalf(err.Error()) } if isCRInSysNs { t.Fatalf("Non-system namespace identied as a system namespace") @@ -103,7 +103,7 @@ func TestUtil_IsNsInSystemNamespace(t *testing.T) { isCRInSysNs, err = IsSystemNamespace(client, ns.Namespace, nil) if err != nil { - t.Fatalf("%s", err.Error()) + t.Fatalf(err.Error()) } if !isCRInSysNs { t.Fatalf("System namespace not identied as a system namespace")