diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cbc80a9..abe74f9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,11 +25,13 @@ jobs: with: go-version-file: go.mod - name: Run golangci-lint - uses: golangci/golangci-lint-action@v6.5.2 - with: - version: v1.62.2 - only-new-issues: false - args: --config .golangci.yml + run: make golint +# TODO(prometherion): enable back once golangci-lint is built from v1.24 rather than v1.23 +# uses: golangci/golangci-lint-action@v6.5.2 +# with: +# version: v1.62.2 +# only-new-issues: false +# args: --config .golangci.yml diff: name: diff runs-on: ubuntu-22.04 diff --git a/.golangci.yml b/.golangci.yml index 45d6a31..3d4cef9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,53 +1,76 @@ -run: - timeout: 10m - -linters-settings: - revive: - rules: - - name: dot-imports - arguments: - - allowedPackages: - - "github.com/onsi/ginkgo/v2" - - "github.com/onsi/gomega" - gci: - sections: - - standard - - default - - prefix(github.com/clastix/kamaji/) - goheader: - template: |- - Copyright 2022 Clastix Labs - SPDX-License-Identifier: Apache-2.0 - +version: "2" linters: + default: all disable: - - depguard - - wrapcheck - - mnd - - varnamelen - - testpackage - - tagliatelle - - paralleltest - - ireturn - - err113 - - gochecknoglobals - - wsl - - exhaustive - - nosprintfhostport - - nonamedreturns - - interfacebloat - - exhaustruct - - lll - - gosec - - gomoddirectives - - godox - - gochecknoinits - - funlen - - dupl - cyclop + - depguard + - dupl + - err113 + - exhaustive + - exhaustruct + - funlen + - gochecknoglobals + - gochecknoinits - gocognit + - godox + - gomoddirectives + - gosec + - interfacebloat + - ireturn + - lll + - mnd - nestif + - nonamedreturns + - nosprintfhostport + - paralleltest - perfsprint - # deprecated linters - - exportloopref - enable-all: true + - tagliatelle + - testpackage + - varnamelen + - wrapcheck + - wsl + settings: + staticcheck: + checks: + - all + - -QF1008 + goheader: + template: |- + Copyright 2022 Clastix Labs + SPDX-License-Identifier: Apache-2.0 + revive: + rules: + - name: dot-imports + arguments: + - allowedPackages: + - github.com/onsi/ginkgo/v2 + - github.com/onsi/gomega + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gci + - gofmt + - gofumpt + - goimports + settings: + gci: + sections: + - standard + - default + - prefix(github.com/clastix/kamaji/) + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ \ No newline at end of file diff --git a/Makefile b/Makefile index a3c9d82..93766c1 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,7 @@ $(CONTROLLER_GEN): $(LOCALBIN) .PHONY: golangci-lint golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. $(GOLANGCI_LINT): $(LOCALBIN) - test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2 + test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2 .PHONY: apidocs-gen apidocs-gen: $(APIDOCS_GEN) ## Download crdoc locally if necessary. diff --git a/api/v1alpha1/tenantcontrolplane_types_test.go b/api/v1alpha1/tenantcontrolplane_types_test.go index 2f6b83f..e48f75d 100644 --- a/api/v1alpha1/tenantcontrolplane_types_test.go +++ b/api/v1alpha1/tenantcontrolplane_types_test.go @@ -19,7 +19,7 @@ var _ = Describe("Cluster controller", func() { ) BeforeEach(func() { - ctx = context.Background() //nolint:fatcontext + ctx = context.Background() tcp = &TenantControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "tcp", diff --git a/api/v1alpha1/validations_test.go b/api/v1alpha1/validations_test.go index fb4e000..1bc30f0 100644 --- a/api/v1alpha1/validations_test.go +++ b/api/v1alpha1/validations_test.go @@ -19,7 +19,7 @@ var _ = Describe("Datastores validation test", func() { ) BeforeEach(func() { - ctx = context.Background() //nolint:fatcontext + ctx = context.Background() ds = &DataStore{ ObjectMeta: metav1.ObjectMeta{ Name: "ds", diff --git a/go.mod b/go.mod index 66b1859..7d62e29 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/clastix/kamaji -go 1.23.0 +go 1.24 require ( github.com/JamesStewy/go-mysqldump v0.2.2 diff --git a/internal/resources/datastore/datastore_storage_config_test.go b/internal/resources/datastore/datastore_storage_config_test.go index 266839f..84754c0 100644 --- a/internal/resources/datastore/datastore_storage_config_test.go +++ b/internal/resources/datastore/datastore_storage_config_test.go @@ -28,7 +28,7 @@ var _ = Describe("DatastoreStorageConfig", func() { ) BeforeEach(func() { - ctx = context.Background() //nolint:fatcontext + ctx = context.Background() tcp = &kamajiv1alpha1.TenantControlPlane{ ObjectMeta: metav1.ObjectMeta{ diff --git a/internal/webhook/handlers/tcp_defaults_test.go b/internal/webhook/handlers/tcp_defaults_test.go index 41078ec..43e848e 100644 --- a/internal/webhook/handlers/tcp_defaults_test.go +++ b/internal/webhook/handlers/tcp_defaults_test.go @@ -42,7 +42,7 @@ var _ = Describe("TCP Defaulting Webhook", func() { }, }, } - ctx = context.Background() //nolint:fatcontext + ctx = context.Background() }) Describe("fields missing", func() { diff --git a/internal/webhook/handlers/tcp_lb_src_ranges_test.go b/internal/webhook/handlers/tcp_lb_src_ranges_test.go index 4c4d675..7c86d36 100644 --- a/internal/webhook/handlers/tcp_lb_src_ranges_test.go +++ b/internal/webhook/handlers/tcp_lb_src_ranges_test.go @@ -31,7 +31,7 @@ var _ = Describe("TCP LoadBalancer Source Ranges Webhook", func() { }, Spec: kamajiv1alpha1.TenantControlPlaneSpec{}, } - ctx = context.Background() //nolint:fatcontext + ctx = context.Background() }) It("allows creation when valid CIDR ranges are provided", func() {