diff --git a/.golangci.yaml b/.golangci.yaml index 06ead6e5..8fdf04f9 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,59 +1,79 @@ +version: "2" run: - # Default timeout is 1m, up to give more room + # Default timeout is 0 (no limit), have an upper limit timeout: 4m - -linters: - enable: - - asciicheck - - unused - - depguard - - gofumpt - - goimports - - importas - - revive - - misspell - - stylecheck - - tparallel - - unconvert - - unparam - - whitespace - -linters-settings: - importas: - alias: - - pkg: k8s.io/api/core/v1 - alias: corev1 - - pkg: k8s.io/apimachinery/pkg/apis/meta/v1 - alias: metav1 - - pkg: k8s.io/apimachinery/pkg/api/errors - alias: apierrors - - pkg: github.com/operator-framework/api/pkg/operators/v1alpha1 - alias: operatorsv1alpha1 - - pkg: github.com/operator-framework/api/pkg/operators/v1 - alias: operatorsv1 - - pkg: github.com/openshift/api/image/v1 - alias: imagestreamv1 - revive: - rules: - - name: dot-imports - severity: warning - disabled: true - stylecheck: - dot-import-whitelist: - - github.com/onsi/gomega - - github.com/onsi/ginkgo - - github.com/onsi/ginkgo/v2 - goimports: - local-prefixes: github.com/redhat-certification/chart-verifier - depguard: - rules: - main: - list-mode: lax - files: - - !$test - allow: - - $gostd - output: formats: - - format: tab + tab: + path: stdout + colors: false +linters: + enable: + - asciicheck + - depguard + - importas + - misspell + - revive + - staticcheck + - tparallel + - unconvert + - unparam + - whitespace + settings: + depguard: + rules: + main: + list-mode: lax + files: + - "" + allow: + - $gostd + importas: + alias: + - pkg: k8s.io/api/core/v1 + alias: corev1 + - pkg: k8s.io/apimachinery/pkg/apis/meta/v1 + alias: metav1 + - pkg: k8s.io/apimachinery/pkg/api/errors + alias: apierrors + - pkg: github.com/operator-framework/api/pkg/operators/v1alpha1 + alias: operatorsv1alpha1 + - pkg: github.com/operator-framework/api/pkg/operators/v1 + alias: operatorsv1 + - pkg: github.com/openshift/api/image/v1 + alias: imagestreamv1 + revive: + rules: + - name: dot-imports + severity: warning + disabled: true + staticcheck: + dot-import-whitelist: + - github.com/onsi/gomega + - github.com/onsi/ginkgo + - github.com/onsi/ginkgo/v2 + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofumpt + - goimports + settings: + goimports: + local-prefixes: + - github.com/redhat-certification/chart-verifier + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/Dockerfile b/Dockerfile index 623e6c33..b9fae0c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/golang:1.23 as build +FROM docker.io/golang:1.24 as build WORKDIR /tmp/src diff --git a/Makefile b/Makefile index 664ba604..bb93eeac 100644 --- a/Makefile +++ b/Makefile @@ -158,10 +158,10 @@ install.gofumpt: # golangci-lint GOLANGCI_LINT = $(shell pwd)/out/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.63.4 +GOLANGCI_LINT_VERSION ?= v2.2.1 install.golangci-lint: $(GOLANGCI_LINT) $(GOLANGCI_LINT): - $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION))\ + $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION))\ # go-install-tool will 'go install' any package $2 and install it to $1. PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/go.mod b/go.mod index c7a4fa9e..b0b2f8fc 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/redhat-certification/chart-verifier -go 1.23.5 +go 1.24.5 require ( dario.cat/mergo v1.0.1 diff --git a/internal/chartverifier/profiles/profile_test.go b/internal/chartverifier/profiles/profile_test.go index 5bace3d5..a378627a 100644 --- a/internal/chartverifier/profiles/profile_test.go +++ b/internal/chartverifier/profiles/profile_test.go @@ -18,8 +18,7 @@ import ( const ( NoVersion string = "" configVersion00 string = "v0.0" - //nolint:deadcode // TODO(komish) identify where this was intended to be used, or remove. - // This should be unused but its triggering as deadcode which is replaced by the unused linter. + // TODO(komish) identify where this was intended to be used, or remove. configVersion10 string = "v1.0" configVersion11 string = "v1.1" configVersion12 string = "v1.2" diff --git a/internal/chartverifier/pyxis/pyxis.go b/internal/chartverifier/pyxis/pyxis.go index e89cae35..2bfa1b3c 100644 --- a/internal/chartverifier/pyxis/pyxis.go +++ b/internal/chartverifier/pyxis/pyxis.go @@ -222,7 +222,7 @@ Loops: // when working with certified images or internal registries. Better to deal with this // by itself at a future date than introduce a potentially subtle bug. // - //nolint:stylecheck + //nolint:staticcheck // ST1005 err = fmt.Errorf("No images found for Registry/Repository: %s/%s", registry, imageRef.Repository) } } else { diff --git a/internal/chartverifier/verifier_test.go b/internal/chartverifier/verifier_test.go index 66e7fa0c..b37b2c7f 100644 --- a/internal/chartverifier/verifier_test.go +++ b/internal/chartverifier/verifier_test.go @@ -35,7 +35,7 @@ import ( func isOk(c *apiReport.Report) bool { outcome := true for _, check := range c.Results { - if !(check.Outcome == apiReport.PassOutcomeType) { + if check.Outcome != apiReport.PassOutcomeType { outcome = false break } diff --git a/internal/helm/actions/template.go b/internal/helm/actions/template.go index 6c0bde44..c17d785e 100644 --- a/internal/helm/actions/template.go +++ b/internal/helm/actions/template.go @@ -38,7 +38,7 @@ func RenderManifests(name string, url string, vals map[string]interface{}, conf } client.ReleaseName = name - cp, err := client.ChartPathOptions.LocateChart(chart, cli.New()) + cp, err := client.LocateChart(chart, cli.New()) if err != nil { return emptyResponse, err } diff --git a/internal/tool/helm.go b/internal/tool/helm.go index 3e553fa6..86e01f8b 100644 --- a/internal/tool/helm.go +++ b/internal/tool/helm.go @@ -49,7 +49,7 @@ func (h Helm) Install(ctx context.Context, namespace, chart, release, valuesFile // ref: https://helm.sh/docs/helm/helm_install client.Timeout = h.timeout - cp, err := client.ChartPathOptions.LocateChart(chart, h.envSettings) + cp, err := client.LocateChart(chart, h.envSettings) if err != nil { utils.LogError(fmt.Sprintf("Error LocateChart: %v", err)) return err @@ -148,7 +148,7 @@ func (h Helm) Upgrade(ctx context.Context, namespace, chart, release string) err client.ReuseValues = true client.Wait = true - cp, err := client.ChartPathOptions.LocateChart(chart, h.envSettings) + cp, err := client.LocateChart(chart, h.envSettings) if err != nil { utils.LogError(fmt.Sprintf("Error LocateChart: %v", err)) return err diff --git a/internal/tool/pgp_test.go b/internal/tool/pgp_test.go index 3b0a47e0..0588291d 100644 --- a/internal/tool/pgp_test.go +++ b/internal/tool/pgp_test.go @@ -38,7 +38,7 @@ func TestDigest2(t *testing.T) { base64KeyFromCmd, _ := base64Cmd.Output() base64Key := strings.Trim(string(base64KeyFromCmd), " -\n") - base64Key = strings.Replace(base64Key, "\n", "", -1) + base64Key = strings.ReplaceAll(base64Key, "\n", "") encodedKey, encodeErr := GetEncodedKey(keyfileName) require.NoError(t, encodeErr) diff --git a/pkg/chartverifier/reportsummary/reportSummary.go b/pkg/chartverifier/reportsummary/reportSummary.go index 910f44b1..61995536 100644 --- a/pkg/chartverifier/reportsummary/reportSummary.go +++ b/pkg/chartverifier/reportsummary/reportSummary.go @@ -37,7 +37,7 @@ const ( SkipDigestCheck BooleanKey = "skipDigestCheck" ) -//nolint:deadcode,unused // Note(komish) need to ensure this isn't used, and research +//nolint:unused // Note(komish) need to ensure this isn't used, and research var setBooleanKeys = [...]BooleanKey{SkipDigestCheck} type APIReportSummary interface {