From 44c2c7da6e3a3b54bf001c8088f130d20484b38d Mon Sep 17 00:00:00 2001 From: James Alseth Date: Mon, 29 Apr 2024 17:53:02 -0700 Subject: [PATCH 1/2] ci: Bump Go to 1.22.x --- .github/workflows/cron_e2e.yaml | 2 +- .github/workflows/pull_request.yaml | 4 ++-- .github/workflows/push_container.yaml | 2 +- .github/workflows/update_cli_docs.yaml | 2 +- go.mod | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cron_e2e.yaml b/.github/workflows/cron_e2e.yaml index 1cb135b9..4b8573c0 100644 --- a/.github/workflows/cron_e2e.yaml +++ b/.github/workflows/cron_e2e.yaml @@ -13,7 +13,7 @@ jobs: - name: setup go uses: actions/setup-go@v5 with: - go-version: 1.20.x + go-version: 1.22.x - name: checkout source uses: actions/checkout@v4 diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index d9e60096..f815da76 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -9,7 +9,7 @@ jobs: - name: setup go uses: actions/setup-go@v5 with: - go-version: 1.20.x + go-version: 1.22.x - name: checkout uses: actions/checkout@v4 @@ -31,7 +31,7 @@ jobs: - name: setup go uses: actions/setup-go@v5 with: - go-version: 1.20.x + go-version: 1.22.x - name: checkout source uses: actions/checkout@v4 diff --git a/.github/workflows/push_container.yaml b/.github/workflows/push_container.yaml index 91dcf03a..95a6229b 100644 --- a/.github/workflows/push_container.yaml +++ b/.github/workflows/push_container.yaml @@ -12,7 +12,7 @@ jobs: - name: setup go uses: actions/setup-go@v5 with: - go-version: 1.20.x + go-version: 1.22.x - name: checkout uses: actions/checkout@v4 diff --git a/.github/workflows/update_cli_docs.yaml b/.github/workflows/update_cli_docs.yaml index 2b50319a..79ff59d8 100644 --- a/.github/workflows/update_cli_docs.yaml +++ b/.github/workflows/update_cli_docs.yaml @@ -17,7 +17,7 @@ jobs: - name: setup go uses: actions/setup-go@v5 with: - go-version: 1.20.x + go-version: 1.22.x - name: checkout source uses: actions/checkout@v4 diff --git a/go.mod b/go.mod index 8f4eecd3..d544509b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/plexsystems/konstraint -go 1.21 +go 1.22 require ( github.com/open-policy-agent/frameworks/constraint v0.0.0-20220218180203-c2a0d8cdf85a From 22b963a72f59556afe7f4007d51b6e906c975080 Mon Sep 17 00:00:00 2001 From: James Alseth Date: Wed, 12 Jun 2024 17:31:00 -0700 Subject: [PATCH 2/2] Bump golangci-lint to v1.59 ... and fix issues reported by the new version. Signed-off-by: James Alseth --- .github/workflows/pull_request.yaml | 2 +- .golangci.yaml | 3 --- internal/commands/convert.go | 2 +- internal/rego/rego.go | 20 +++++++++++--------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index f815da76..d37a72b8 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -17,7 +17,7 @@ jobs: - name: lint go uses: golangci/golangci-lint-action@v6 with: - version: v1.52 + version: v1.59 args: --timeout=5m --color=always --max-same-issues=0 --max-issues-per-linter=0 acceptance: diff --git a/.golangci.yaml b/.golangci.yaml index b000df4a..acdb9d52 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -6,7 +6,6 @@ linter-settings: linters: disable-all: true enable: - - deadcode - errcheck - goconst - gofmt @@ -20,10 +19,8 @@ linters: - predeclared - revive - staticcheck - - structcheck - typecheck - unconvert - unparam - unused - - varcheck - wastedassign diff --git a/internal/commands/convert.go b/internal/commands/convert.go index f2fef069..a066a5e2 100644 --- a/internal/commands/convert.go +++ b/internal/commands/convert.go @@ -20,7 +20,7 @@ func newConvertCommand() *cobra.Command { konstraint convert examples`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { path := "." if len(args) > 0 { path = args[0] diff --git a/internal/rego/rego.go b/internal/rego/rego.go index 000999f8..b30889e1 100644 --- a/internal/rego/rego.go +++ b/internal/rego/rego.go @@ -657,17 +657,19 @@ func (r Rego) SkipConstraint() bool { func parseDirectory(directory string, parseImports bool) ([]Rego, error) { // Recursively find all rego files (ignoring test files), starting at the given directory. - result, err := loader.NewFileLoader().WithProcessAnnotation(true).Filtered([]string{directory}, func(abspath string, info os.FileInfo, depth int) bool { - if strings.HasSuffix(info.Name(), "_test.rego") { - return true - } + result, err := loader.NewFileLoader(). + WithProcessAnnotation(true). + Filtered([]string{directory}, func(_ string, info os.FileInfo, _ int) bool { + if strings.HasSuffix(info.Name(), "_test.rego") { + return true + } - if !info.IsDir() && filepath.Ext(info.Name()) != ".rego" { - return true - } + if !info.IsDir() && filepath.Ext(info.Name()) != ".rego" { + return true + } - return false - }) + return false + }) if err != nil { return nil, fmt.Errorf("filter rego files: %w", err) }