mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
Bump golangci-lint -> 1.64.5 (#7374)
Also: - Replace deprecated tenv linter with usetesting, and address the issues it reported (nice!) Signed-off-by: Anders Eknert <anders@styra.com>
This commit is contained in:
+1
-1
@@ -167,7 +167,7 @@ linters:
|
||||
- goimports
|
||||
- unused
|
||||
- misspell
|
||||
- tenv
|
||||
- usetesting
|
||||
- typecheck
|
||||
- staticcheck
|
||||
- gosimple
|
||||
|
||||
@@ -28,7 +28,7 @@ ifeq ($(WASM_ENABLED),1)
|
||||
GO_TAGS = -tags=opa_wasm
|
||||
endif
|
||||
|
||||
GOLANGCI_LINT_VERSION := v1.60.1
|
||||
GOLANGCI_LINT_VERSION := v1.64.5
|
||||
YAML_LINT_VERSION := 0.29.0
|
||||
YAML_LINT_FORMAT ?= auto
|
||||
|
||||
|
||||
+4
-15
@@ -2831,17 +2831,9 @@ foo contains __local1__1 if {
|
||||
// There's probably some common utilities that could be extracted at some point but for now this code is
|
||||
// local to the test until we need to reuse it elsewhere.
|
||||
func TestBuildWithFollowSymlinks(t *testing.T) {
|
||||
rootDir, err := os.MkdirTemp("", "build-follow-symlinks")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() {
|
||||
if err := os.RemoveAll(rootDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
rootDir := t.TempDir()
|
||||
bundleDir := path.Join(rootDir, "bundle")
|
||||
err = os.Mkdir(bundleDir, 0777)
|
||||
err := os.Mkdir(bundleDir, 0777)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -2944,17 +2936,14 @@ func TestBuildWithFollowSymlinks(t *testing.T) {
|
||||
// This test uses a local tmp filesystem to create a directory with a local file in the bundle directory, and
|
||||
// verifies that the built bundle contains the files from the symlinked directory.
|
||||
func TestBuildWithFollowSymlinksEntireDir(t *testing.T) {
|
||||
rootDir, err := os.MkdirTemp("", "build-follow-symlinks-dir")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rootDir := t.TempDir()
|
||||
defer func() {
|
||||
if err := os.RemoveAll(rootDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
bundleDir := path.Join(rootDir, "src")
|
||||
err = os.Mkdir(bundleDir, 0777)
|
||||
err := os.Mkdir(bundleDir, 0777)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
+1
-1
@@ -1420,7 +1420,7 @@ func TestExecWithInvalidInputOptions(t *testing.T) {
|
||||
params.BundlePaths = []string{dir + "/bundle/"}
|
||||
if tt.stdIn {
|
||||
params.StdIn = true
|
||||
tempFile, err := os.CreateTemp("", "test")
|
||||
tempFile, err := os.CreateTemp(t.TempDir(), "test")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error creating temp file: %q", err.Error())
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ func TestExec(t *testing.T) {
|
||||
params.FailNonEmpty = true
|
||||
if tt.stdIn {
|
||||
params.StdIn = true
|
||||
tempFile, err := os.CreateTemp("", "test")
|
||||
tempFile, err := os.CreateTemp(t.TempDir(), "test")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error creating temp file: %q", err.Error())
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ func TestMetadataCredentialService(t *testing.T) {
|
||||
test.WithTempFS(nil, func(path string) {
|
||||
// wrong path: bad file token
|
||||
t.Setenv(ecsFullPathEnvVar, "fullPath")
|
||||
os.Setenv(ecsAuthorizationTokenFileEnvVar, filepath.Join(path, "bad-file"))
|
||||
t.Setenv(ecsAuthorizationTokenFileEnvVar, filepath.Join(path, "bad-file"))
|
||||
_, err = cs.credentials(context.Background())
|
||||
assertErr("failed to read ECS metadata authorization token from file", err, t)
|
||||
os.Unsetenv(ecsFullPathEnvVar)
|
||||
|
||||
@@ -1927,8 +1927,6 @@ func TestS3SigningMultiCredentialProvider(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAWSCredentialServiceChain(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
@@ -1980,7 +1978,7 @@ func TestAWSCredentialServiceChain(t *testing.T) {
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
for key, val := range tc.env {
|
||||
_ = os.Setenv(key, val)
|
||||
t.Setenv(key, val)
|
||||
}
|
||||
|
||||
t.Cleanup(func() {
|
||||
|
||||
+2
-24
@@ -295,18 +295,7 @@ func TestDumpPath(t *testing.T) {
|
||||
var buffer bytes.Buffer
|
||||
repl := newRepl(store, &buffer)
|
||||
|
||||
dir, err := os.MkdirTemp("", "dump-path-test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
t.Cleanup(func() {
|
||||
err := os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
t.Errorf("error cleaning up with RemoveAll(): %v", err)
|
||||
}
|
||||
})
|
||||
file := filepath.Join(dir, "tmpfile")
|
||||
file := filepath.Join(t.TempDir(), "tmpfile")
|
||||
if err := repl.OneShot(ctx, "dump "+file); err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
@@ -342,18 +331,7 @@ func TestDumpPathCaseSensitive(t *testing.T) {
|
||||
var buffer bytes.Buffer
|
||||
repl := newRepl(store, &buffer)
|
||||
|
||||
dir, err := os.MkdirTemp("", "DumpPathCaseSensitiveTest")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
t.Cleanup(func() {
|
||||
err := os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
t.Errorf("error cleaning up with RemoveAll(): %v", err)
|
||||
}
|
||||
})
|
||||
file := filepath.Join(dir, "tmpfile")
|
||||
file := filepath.Join(t.TempDir(), "tmpfile")
|
||||
if err := repl.OneShot(ctx, "dump "+file); err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
@@ -607,7 +607,7 @@ allow if {
|
||||
input.path = ["health"]
|
||||
}`)
|
||||
|
||||
tmpfile, err := os.CreateTemp("", "authz.*.rego")
|
||||
tmpfile, err := os.CreateTemp(t.TempDir(), "authz.*.rego")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -3554,7 +3554,7 @@ func TestSocketHTTPGetRequest(t *testing.T) {
|
||||
people = append(people, Person{ID: "1", Firstname: "John"})
|
||||
|
||||
// Create a local socket
|
||||
tmpF, err := os.CreateTemp("", "")
|
||||
tmpF, err := os.CreateTemp(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user