Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump to opa 0.45 #253

Merged
merged 3 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/gatekeeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ jobs:
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.45.2
version: v1.50.0
working-directory: constraint

test:
name: "Unit test"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
5 changes: 1 addition & 4 deletions constraint/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ linters-settings:
locale: US
staticcheck:
# Select the Go version to target. The default is '1.13'.
go: "1.18"
go: "1.19"

linters:
disable-all: true
enable:
- deadcode
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are deprecated linters

- errcheck
- exportloopref
- forcetypeassert
Expand All @@ -38,8 +37,6 @@ linters:
- nilerr
- revive # replacement for golint
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- whitespace
2 changes: 1 addition & 1 deletion constraint/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.18 as builder
FROM golang:1.19 as builder

RUN apt-get update &&\
apt-get install -y apt-utils make
Expand Down
8 changes: 4 additions & 4 deletions constraint/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/open-policy-agent/frameworks/constraint

go 1.17
go 1.18

// Prevent otel dependencies from getting out of sync.
// Cannot be upgraded until k8s.io/component-base uses a more recent version of
Expand All @@ -18,7 +18,7 @@ require (
github.com/davecgh/go-spew v1.1.1
github.com/golang/glog v1.0.0
github.com/google/go-cmp v0.5.9
github.com/open-policy-agent/opa v0.44.0
github.com/open-policy-agent/opa v0.45.0
github.com/spf13/cobra v1.5.0
github.com/spf13/pflag v1.0.5
k8s.io/apiextensions-apiserver v0.24.6
Expand Down Expand Up @@ -89,9 +89,9 @@ require (
go.opentelemetry.io/otel/sdk/metric v0.20.0 // indirect
go.opentelemetry.io/otel/trace v1.7.0 // indirect
go.opentelemetry.io/proto/otlp v0.16.0 // indirect
golang.org/x/net v0.0.0-20220401154927-543a649e0bdd // indirect
golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
Expand Down
675 changes: 7 additions & 668 deletions constraint/go.sum

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions constraint/pkg/client/drivers/local/driver_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/tls"
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
"sort"
Expand Down Expand Up @@ -240,7 +239,7 @@ func TestDriver_ExternalData(t *testing.T) {
},
} {
t.Run(tt.name, func(t *testing.T) {
clientCertFile, err := ioutil.TempFile("", "client-cert")
clientCertFile, err := os.CreateTemp("", "client-cert")
if err != nil {
t.Fatal(err)
}
Expand All @@ -249,7 +248,7 @@ func TestDriver_ExternalData(t *testing.T) {
_, _ = clientCertFile.WriteString(tt.clientCertContent)
clientCertFile.Close()

clientKeyFile, err := ioutil.TempFile("", "client-key")
clientKeyFile, err := os.CreateTemp("", "client-key")
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions constraint/pkg/client/drivers/remote/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"strings"
)
Expand Down Expand Up @@ -240,7 +239,7 @@ func (c *httpClient) handleErrors(resp *http.Response) error {
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
return nil
}
msg, err := ioutil.ReadAll(resp.Body)
msg, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("got handleErrors: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions constraint/pkg/externaldata/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"time"
Expand Down Expand Up @@ -87,7 +87,7 @@ func DefaultSendRequestToProvider(ctx context.Context, provider *v1alpha1.Provid
}
defer resp.Body.Close()

respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return nil, http.StatusInternalServerError, fmt.Errorf("failed to read external data response: %w", err)
}
Expand Down
1 change: 1 addition & 0 deletions constraint/pkg/regorewriter/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func (errs Errors) Error() string {

// Format implements fmt.Formatter to make this play nice with handling stack traces produced from
// github.com/pkg/errors.
//
//nolint:errcheck // suppress errors rendering errors
func (errs Errors) Format(s fmt.State, verb rune) {
switch verb {
Expand Down
4 changes: 2 additions & 2 deletions constraint/pkg/regorewriter/module.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package regorewriter

import (
"io/ioutil"
"os"
"strings"

"github.com/open-policy-agent/opa/ast"
Expand All @@ -22,7 +22,7 @@ func (m *Module) Write() error {
if err != nil {
return err
}
return ioutil.WriteFile(m.Path(), b, 0o600)
return os.WriteFile(m.Path(), b, 0o600)
}

// Content returns the module as a byte slice of rego source code.
Expand Down
20 changes: 10 additions & 10 deletions constraint/pkg/regorewriter/regorewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package regorewriter

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -40,7 +39,8 @@ type RegoRewriter struct {

// New returns a new RegoRewriter
// args:
// pt - the PackageTransformer that will be used for updating the path
//
// pt - the PackageTransformer that will be used for updating the path
// libs - a list of package prefixes that are allowed for library use
// externs - a list of packages that the rego is allowed to reference but not declared in any libs
func New(pt PackageTransformer, libs []string, externs []string) (*RegoRewriter, error) {
Expand Down Expand Up @@ -100,7 +100,7 @@ func (r *RegoRewriter) addTestDir(testDirPath string) error {
}

glog.V(vLog).Infof("reading %s", path)
bytes, err := ioutil.ReadFile(path)
bytes, err := os.ReadFile(path)
if err != nil {
return fmt.Errorf("%w: %v", ErrReadingFile, err)
}
Expand All @@ -119,7 +119,7 @@ func (r *RegoRewriter) addFileFromFs(path string, slice *[]*Module) error {
return fmt.Errorf("invalid file specified %s", path)
}

bytes, err := ioutil.ReadFile(path)
bytes, err := os.ReadFile(path)
if err != nil {
return fmt.Errorf("%w: %v", ErrReadingFile, err)
}
Expand All @@ -134,19 +134,19 @@ func (r *RegoRewriter) addFileFromFs(path string, slice *[]*Module) error {

// addPathFromFs adds a module from the local filesystem.
// Loading from the filesystem is based on how "opa test" operates in terms of scoping.
// 1. the 'test' directory must exist as a member of one of the paths passed to 'opa test'.
// 2. the '.rego' source can exist anywhere in the subtree of the specified path
// 3. any '.rego' loaded by "opa test" can reference any "test" data member that is loaded by
// opa test, for example, if "opa test foo/ bar/" is specified, a test in foo/ can see test data
// from bar/test/.
// 1. the 'test' directory must exist as a member of one of the paths passed to 'opa test'.
// 2. the '.rego' source can exist anywhere in the subtree of the specified path
// 3. any '.rego' loaded by "opa test" can reference any "test" data member that is loaded by
// opa test, for example, if "opa test foo/ bar/" is specified, a test in foo/ can see test data
// from bar/test/.
func (r *RegoRewriter) addPathFromFs(path string, slice *[]*Module) error {
fileStat, err := os.Stat(path)
if err != nil {
return fmt.Errorf("%w: %v", ErrReadingFile, err)
}

if fileStat.IsDir() {
infos, err := ioutil.ReadDir(path)
infos, err := os.ReadDir(path)
if err != nil {
return fmt.Errorf("%w: %v", ErrReadingFile, err)
}
Expand Down
3 changes: 1 addition & 2 deletions constraint/pkg/regorewriter/sources.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package regorewriter

import (
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -103,7 +102,7 @@ func (s *Sources) Write() error {
return err
}
glog.Infof("Writing %s", path)
if err := ioutil.WriteFile(path, content, 0o600); err != nil {
if err := os.WriteFile(path, content, 0o600); err != nil {
return err
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading