From b6aa6236d3ce19d7fb8afbc42597b5f1e2925acf Mon Sep 17 00:00:00 2001 From: Shachar Sharon Date: Mon, 19 May 2025 11:13:18 +0300 Subject: [PATCH 1/6] build: require golang 1.23 or later Upgrade project to support the latest two version of golang. Signed-off-by: Shachar Sharon --- go.mod | 18 +++++++++--------- go.sum | 3 +++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index fd56ac5..0ef3793 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/samba-in-kubernetes/smbmetrics -go 1.19 +go 1.23 require ( github.com/go-logr/logr v1.2.3 @@ -68,21 +68,21 @@ exclude ( k8s.io/client-go v1.5.0 k8s.io/client-go v1.5.1 k8s.io/client-go v1.5.2 - k8s.io/client-go v10.0.0+incompatible - k8s.io/client-go v11.0.0+incompatible - k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible - k8s.io/client-go v12.0.0+incompatible - k8s.io/client-go v2.0.0+incompatible k8s.io/client-go v2.0.0-alpha.1+incompatible - k8s.io/client-go v3.0.0+incompatible + k8s.io/client-go v2.0.0+incompatible k8s.io/client-go v3.0.0-beta.0+incompatible - k8s.io/client-go v4.0.0+incompatible + k8s.io/client-go v3.0.0+incompatible k8s.io/client-go v4.0.0-beta.0+incompatible + k8s.io/client-go v4.0.0+incompatible k8s.io/client-go v5.0.0+incompatible k8s.io/client-go v5.0.1+incompatible k8s.io/client-go v6.0.0+incompatible k8s.io/client-go v7.0.0+incompatible k8s.io/client-go v8.0.0+incompatible - k8s.io/client-go v9.0.0+incompatible k8s.io/client-go v9.0.0-invalid+incompatible + k8s.io/client-go v9.0.0+incompatible + k8s.io/client-go v10.0.0+incompatible + k8s.io/client-go v11.0.0+incompatible + k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible + k8s.io/client-go v12.0.0+incompatible ) diff --git a/go.sum b/go.sum index 45effdb..5aa86e7 100644 --- a/go.sum +++ b/go.sum @@ -200,7 +200,9 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/onsi/ginkgo/v2 v2.6.0 h1:9t9b9vRUbFq3C4qKFCGkVuq/fIHji802N1nrtkh1mNc= +github.com/onsi/ginkgo/v2 v2.6.0/go.mod h1:63DOGlLAH8+REH8jUGdL3YpCpu7JODesutUjdENfUAc= github.com/onsi/gomega v1.24.1 h1:KORJXNNTzJXzu4ScJWssJfJMnJ+2QJqhoQSRwNlze9E= +github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -265,6 +267,7 @@ go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= From 2e6e27024c4976c4a16920eedeef3a8c52f3b51a Mon Sep 17 00:00:00 2001 From: Shachar Sharon Date: Mon, 19 May 2025 12:29:43 +0300 Subject: [PATCH 2/6] hack: upgrade yq to v4.45.4 Using latest yq release. Signed-off-by: Shachar Sharon --- hack/install-tools.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/install-tools.sh b/hack/install-tools.sh index d106d3a..83e7d37 100755 --- a/hack/install-tools.sh +++ b/hack/install-tools.sh @@ -50,7 +50,7 @@ _install_golangci_lint() { } _install_yq() { - _install_tool github.com/mikefarah/yq/v4@v4.23.1 + _install_tool github.com/mikefarah/yq/v4@v4.45.4 } _install_gosec() { From e644c999a9cd816115be8755b662b490094ab2f5 Mon Sep 17 00:00:00 2001 From: Shachar Sharon Date: Mon, 19 May 2025 12:31:56 +0300 Subject: [PATCH 3/6] hack: upgrade 'revive' to v1.9.0 Using latest 'revive' release. Signed-off-by: Shachar Sharon --- hack/install-tools.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/install-tools.sh b/hack/install-tools.sh index 83e7d37..fd771a1 100755 --- a/hack/install-tools.sh +++ b/hack/install-tools.sh @@ -42,7 +42,7 @@ _install_controller_gen() { } _install_revive() { - _install_tool github.com/mgechev/revive@v1.3.7 + _install_tool github.com/mgechev/revive@v1.9.0 } _install_golangci_lint() { From f2b70d478006f2dbe81cd68672835c39edd44646 Mon Sep 17 00:00:00 2001 From: Shachar Sharon Date: Mon, 19 May 2025 11:12:55 +0300 Subject: [PATCH 4/6] hack: upgrade golangci-lint to v2.1.6 Upgrade to latest golangci-lint version. Used migration-guide[1] to adjust golangci configuration file to new version. [1] https://golangci-lint.run/product/migration-guide/ Signed-off-by: Shachar Sharon --- .golangci.yaml | 178 ++++++++++++++++++++++-------------------- hack/install-tools.sh | 2 +- 2 files changed, 94 insertions(+), 86 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index bdc11db..275734e 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,103 +1,111 @@ ---- -run: - timeout: 3m +version: "2" linters: - disable-all: true + default: none enable: - asciicheck - # - deadcode + - copyloopvar - dupl - errcheck - exhaustive - - copyloopvar - funlen - # - gci - goconst - gocritic - # - godot - # - godox - goheader - - gofmt - - gosimple - govet - # - ineffassign - # - ifshort - lll - misspell - # - nlreturn - # - nolintlint - revive - staticcheck - # - structcheck - # - tagliatelle - # - testpackage - - typecheck - unconvert - # - unparam - unused - whitespace -linters-settings: - funlen: - lines: 188 - statements: 60 - govet: - enable-all: true - disable: - - fieldalignment - - shadow - lll: - line-length: 98 - revive: - ignore-generated-header: false - severity: error - rules: - - name: blank-imports - - name: context-as-argument - - name: context-keys-type - - name: dot-imports - - name: error-return - - name: error-strings - - name: error-naming - - name: exported - - name: if-return - - name: increment-decrement - - name: var-naming - arguments: [["UID", "GID"]] - - name: var-declaration - - name: package-comments - - name: range - - name: receiver-naming - - name: time-naming - - name: unexported-return - - name: indent-error-flow - - name: errorf - - name: empty-block - - name: superfluous-else - - name: unused-parameter - - name: unreachable-code - - name: redefines-builtin-id - - name: atomic - - name: bool-literal-in-expr - - name: constant-logical-expr - - name: unnecessary-stmt - - name: unused-receiver - - name: get-return - - name: flag-parameter - - name: confusing-results - - name: confusing-naming - - name: modifies-parameter - - name: modifies-value-receiver - - name: import-shadowing - - name: range-val-in-closure - - name: waitgroup-by-value - - name: call-to-gc - - name: duplicated-imports - - name: argument-limit - arguments: [7] - - name: function-result-limit - arguments: [3] - - name: unhandled-error - arguments: ["fmt.Printf", "fmt.Println"] - # - name: struct-tag - - name: line-length-limit - arguments: [98] + settings: + funlen: + lines: 188 + statements: 60 + govet: + disable: + - fieldalignment + - shadow + enable-all: true + lll: + line-length: 98 + revive: + severity: error + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: exported + - name: if-return + - name: increment-decrement + - name: var-naming + arguments: + - - UID + - GID + - name: var-declaration + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: empty-block + - name: superfluous-else + - name: unused-parameter + - name: unreachable-code + - name: redefines-builtin-id + - name: atomic + - name: bool-literal-in-expr + - name: constant-logical-expr + - name: unnecessary-stmt + - name: unused-receiver + - name: get-return + - name: flag-parameter + - name: confusing-results + - name: confusing-naming + - name: modifies-parameter + - name: modifies-value-receiver + - name: import-shadowing + - name: range-val-in-closure + - name: waitgroup-by-value + - name: call-to-gc + - name: duplicated-imports + - name: argument-limit + arguments: + - 7 + - name: function-result-limit + arguments: + - 3 + - name: unhandled-error + arguments: + - fmt.Printf + - fmt.Println + - name: line-length-limit + arguments: + - 98 + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/hack/install-tools.sh b/hack/install-tools.sh index fd771a1..fdaee25 100755 --- a/hack/install-tools.sh +++ b/hack/install-tools.sh @@ -46,7 +46,7 @@ _install_revive() { } _install_golangci_lint() { - _install_tool github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.2 + _install_tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 } _install_yq() { From e988ef8a07b65ff2d8ec349076624d53a1a18354 Mon Sep 17 00:00:00 2001 From: Shachar Sharon Date: Mon, 19 May 2025 09:41:05 +0300 Subject: [PATCH 5/6] workflows: upgrade to 'actions/setup-go@v5' Align github workflow with recommended[1] setup-go and go-version settings. [1] https://github.com/actions/ \ setup-go?tab=readme-ov-file#using-stableoldstable-aliases Signed-off-by: Shachar Sharon --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 16ccd1f..afa820f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,9 +10,9 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v5 with: - go-version: ">=1.21.0" + go-version: "stable" - uses: actions/checkout@v4 - name: Build run: make @@ -20,9 +20,9 @@ jobs: check: runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v5 with: - go-version: ">=1.21.0" + go-version: "stable" - uses: actions/checkout@v4 - name: Install build tools run: make build-tools From 511f6f93431a152f6e4d542745a14811e57c5c4a Mon Sep 17 00:00:00 2001 From: Shachar Sharon Date: Thu, 15 May 2025 10:40:37 +0300 Subject: [PATCH 6/6] image: use golang builder 1.24 Update to latest (from Feb 2025) golang version. Signed-off-by: Shachar Sharon --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8acf09d..3a736af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build smbmetrics -FROM docker.io/golang:1.21 as builder +FROM docker.io/golang:1.24 as builder ARG GIT_VERSION="(unset)" ARG COMMIT_ID="(unset)" ARG ARCH=""