From 78aacd1db3da8577b57b348497e13a4ce8f357fb Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Tue, 13 Jun 2023 13:21:10 +0200 Subject: [PATCH] Update golangci-lint and add depguard rules (#3051) * update golangci-lint to v1.53.x Signed-off-by: cpanato * add golangci-lint depguard rules Signed-off-by: cpanato --------- Signed-off-by: cpanato --- .github/workflows/tests.yaml | 2 +- .golangci.yml | 75 ++++++++++++++++++++++++++++++++++++ Makefile | 2 +- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 8e0c84e5d2a..3b3d16e20cb 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -178,5 +178,5 @@ jobs: uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.52 + version: v1.53 args: --timeout=5m diff --git a/.golangci.yml b/.golangci.yml index deaceaac10b..eeb8a1aa738 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -43,6 +43,81 @@ linters-settings: - 'os\.Getenv.*' - 'os\.LookupEnv.*' exclude_godoc_examples: false + depguard: + rules: + main: + files: + - $all + - "!$test" + allow: + - $gostd + + - github.com/open-policy-agent/opa/rego + - github.com/xanzy/go-gitlab + - github.com/spf13/cobra + - github.com/spf13/viper + - github.com/spf13/pflag + - github.com/pkg/errors + - github.com/moby/term + - github.com/google/go-cmp/cmp + - github.com/in-toto/in-toto-golang + - github.com/secure-systems-lab/go-securesystemslib + - github.com/cyberphone/json-canonicalization/go/src/webpki.org/jsoncanonicalizer + - github.com/digitorus/timestamp + - github.com/transparency-dev/merkle + - github.com/google/certificate-transparency-go + - github.com/go-openapi + - github.com/theupdateframework/go-tuf + - github.com/kelseyhightower/envconfig + - github.com/google/go-github + - github.com/buildkite/agent + - github.com/mitchellh/go-wordwrap + - github.com/withfig/autocomplete-tools/integrations/cobra + - github.com/awslabs/amazon-ecr-credential-helper/ecr-login + - github.com/chrismellard/docker-credential-acr-env/pkg/credhelper + - github.com/mozillazg/docker-credential-acr-helper/pkg/credhelper + + - cuelang.org/go/cue/load + - cuelang.org/go/cue/cuecontext + - cuelang.org/go/encoding/json + + - k8s.io/utils/pointer + - k8s.io/client-go + - k8s.io/api/core + - k8s.io/apimachinery + - sigs.k8s.io/release-utils/version + + - github.com/spiffe/go-spiffe + - github.com/google/go-containerregistry + - github.com/sigstore + + test: + files: + - $test + allow: + - $gostd + - github.com/google/go-cmp/cmp + - github.com/go-openapi + - github.com/google/go-containerregistry + - github.com/in-toto/in-toto-golang + - github.com/stretchr/testify + - github.com/pkg/errors + - github.com/theupdateframework/go-tuf + - github.com/google/certificate-transparency-go + - github.com/secure-systems-lab/go-securesystemslib + - github.com/transparency-dev/merkle/rfc6962 + - github.com/depcheck-test/depcheck-test/depcheck + - github.com/cyberphone/json-canonicalization/go/src/webpki.org/jsoncanonicalizer + + - k8s.io/api/core + - k8s.io/apimachinery + - k8s.io/utils/pointer + + - github.com/sigstore/cosign + - github.com/sigstore/sigstore + - github.com/sigstore/rekor + - github.com/sigstore/fulcio + output: uniq-by-line: false issues: diff --git a/Makefile b/Makefile index 2ce7d7ba9fd..91e9a4d9380 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,7 @@ cross: golangci-lint: rm -f $(GOLANGCI_LINT_BIN) || : set -e ;\ - GOBIN=$(GOLANGCI_LINT_DIR) $(GOEXE) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 ;\ + GOBIN=$(GOLANGCI_LINT_DIR) $(GOEXE) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2 ;\ lint: golangci-lint ## Run golangci-lint linter $(GOLANGCI_LINT_BIN) run -n