From 6558f949e75a7b415a3873cc792d01803c99b482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Tue, 3 Oct 2023 17:04:18 +0200 Subject: [PATCH] fix: linter (#4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- .github/{workflow => workflows}/lint.yaml | 19 ++-------- .golangci.yml | 45 +++++++++++++++++++++++ go.mod | 2 +- pkg/engine/assert/parse.go | 2 +- 4 files changed, 51 insertions(+), 17 deletions(-) rename .github/{workflow => workflows}/lint.yaml (56%) create mode 100644 .golangci.yml diff --git a/.github/workflow/lint.yaml b/.github/workflows/lint.yaml similarity index 56% rename from .github/workflow/lint.yaml rename to .github/workflows/lint.yaml index 4e275ec6..b2304010 100644 --- a/.github/workflow/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,11 +1,8 @@ name: Lint -permissions: {} +# permissions: {} on: - push: - branches: - - '*' pull_request: branches: - 'main' @@ -21,16 +18,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 + with: + go-version: ~1.21.1 - name: golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 - with: - version: v1.54.2 - skip-cache: true - - name: go fmt check - run: make fmt-check - - name: goimports check - run: make imports-check - - name: Checking unused pkgs using go mod tidy - run: make unused-package-check - - name: Go vet - run: make vet diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..92229235 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,45 @@ +linters: + enable: + - asasalint + - asciicheck + - bidichk + - bodyclose + - containedctx + - decorder + - dogsled + - durationcheck + - errcheck + - errname + - exportloopref + - gci + - gochecknoinits + - gofmt + - gofumpt + - goimports + - goprintffuncname + - gosec + - gosimple + - govet + - grouper + - importas + - ineffassign + - makezero + - misspell + - noctx + - nolintlint + - nosprintfhostport + # - paralleltest + - staticcheck + - tenv + - thelper + - tparallel + - typecheck + - unconvert + - unused + - wastedassign + - whitespace + +run: + timeout: 15m + skip-files: + - ".+\\.generated.go" diff --git a/go.mod b/go.mod index 864b0ef7..21869142 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/kyverno/kyverno-json go 1.21 require ( + github.com/jinzhu/copier v0.4.0 github.com/jmespath-community/go-jmespath v1.1.1 github.com/kyverno/kyverno v1.5.0-rc1.0.20230927190803-27858f634e28 github.com/spf13/cobra v1.7.0 @@ -154,7 +155,6 @@ require ( github.com/in-toto/in-toto-golang v0.9.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jedisct1/go-minisign v0.0.0-20230811132847-661be99b8267 // indirect - github.com/jinzhu/copier v0.4.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect diff --git a/pkg/engine/assert/parse.go b/pkg/engine/assert/parse.go index 8f6947a7..f23d410e 100644 --- a/pkg/engine/assert/parse.go +++ b/pkg/engine/assert/parse.go @@ -34,7 +34,7 @@ func Parse(assertion interface{}) Assertion { } // mapNode is the assertion type represented by a map. -// it is reponsible for projecting the analysed resource and passing the result to the descendant +// it is responsible for projecting the analysed resource and passing the result to the descendant type mapNode map[interface{}]Assertion func (n mapNode) assert(path *field.Path, value interface{}, bindings jpbinding.Bindings) (field.ErrorList, error) {