Merge pull request #24957 from Luap99/lint
update golangci/golangci-lint to v1.63.4
This commit is contained in:
commit
564b8f338e
2
Makefile
2
Makefile
|
|
@ -62,7 +62,7 @@ BUILDTAGS += ${EXTRA_BUILDTAGS}
|
|||
# N/B: This value is managed by Renovate, manual changes are
|
||||
# possible, as long as they don't disturb the formatting
|
||||
# (i.e. DO NOT ADD A 'v' prefix!)
|
||||
GOLANGCI_LINT_VERSION := 1.62.2
|
||||
GOLANGCI_LINT_VERSION := 1.63.4
|
||||
PYTHON ?= $(shell command -v python3 python|head -n1)
|
||||
PKG_MANAGER ?= $(shell command -v dnf yum|head -n1)
|
||||
# ~/.local/bin is not in PATH on all systems
|
||||
|
|
|
|||
|
|
@ -95,11 +95,7 @@ func TestUnitDirs(t *testing.T) {
|
|||
unitDirs = getUnitDirs(false)
|
||||
assert.Equal(t, []string{}, unitDirs)
|
||||
|
||||
name, err := os.MkdirTemp("", "dir")
|
||||
assert.Nil(t, err)
|
||||
// remove the temporary directory at the end of the program
|
||||
defer os.RemoveAll(name)
|
||||
|
||||
name := t.TempDir()
|
||||
t.Setenv("QUADLET_UNIT_DIRS", name)
|
||||
unitDirs = getUnitDirs(false)
|
||||
assert.Equal(t, []string{name}, unitDirs, "rootful should use environment variable")
|
||||
|
|
@ -107,10 +103,7 @@ func TestUnitDirs(t *testing.T) {
|
|||
unitDirs = getUnitDirs(true)
|
||||
assert.Equal(t, []string{name}, unitDirs, "rootless should use environment variable")
|
||||
|
||||
symLinkTestBaseDir, err := os.MkdirTemp("", "podman-symlinktest")
|
||||
assert.Nil(t, err)
|
||||
// remove the temporary directory at the end of the program
|
||||
defer os.RemoveAll(symLinkTestBaseDir)
|
||||
symLinkTestBaseDir := t.TempDir()
|
||||
|
||||
actualDir := filepath.Join(symLinkTestBaseDir, "actual")
|
||||
err = os.Mkdir(actualDir, 0755)
|
||||
|
|
@ -152,10 +145,7 @@ func TestUnitDirs(t *testing.T) {
|
|||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
symLinkRecursiveTestBaseDir, err := os.MkdirTemp("", "podman-symlink-recursive-test")
|
||||
assert.Nil(t, err)
|
||||
// remove the temporary directory at the end of the program
|
||||
defer os.RemoveAll(symLinkRecursiveTestBaseDir)
|
||||
symLinkRecursiveTestBaseDir := t.TempDir()
|
||||
|
||||
expectedDirs := make([]string, 0)
|
||||
// Create <BASE>/unitDir
|
||||
|
|
@ -214,9 +204,7 @@ func TestUnitDirs(t *testing.T) {
|
|||
} else {
|
||||
fmt.Println(os.Args)
|
||||
|
||||
symLinkTestBaseDir, err := os.MkdirTemp("", "podman-symlinktest2")
|
||||
assert.Nil(t, err)
|
||||
defer os.RemoveAll(symLinkTestBaseDir)
|
||||
symLinkTestBaseDir := t.TempDir()
|
||||
rootF, err := os.Open("/")
|
||||
assert.Nil(t, err)
|
||||
defer rootF.Close()
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ func TestRotateLog(t *testing.T) {
|
|||
{1000, 600, 1500, true},
|
||||
}
|
||||
|
||||
tmpDir := t.TempDir()
|
||||
for _, test := range tests {
|
||||
tmp, err := os.CreateTemp("", "log-rotation-")
|
||||
tmp, err := os.CreateTemp(tmpDir, "log-rotation-")
|
||||
require.NoError(t, err)
|
||||
defer os.Remove(tmp.Name())
|
||||
defer tmp.Close()
|
||||
|
||||
// Create dummy file and content.
|
||||
|
|
@ -80,9 +80,8 @@ func TestTruncationOutput(t *testing.T) {
|
|||
10
|
||||
`
|
||||
// Create dummy file
|
||||
tmp, err := os.CreateTemp("", "log-rotation")
|
||||
tmp, err := os.CreateTemp(t.TempDir(), "log-rotation")
|
||||
require.NoError(t, err)
|
||||
defer os.Remove(tmp.Name())
|
||||
defer tmp.Close()
|
||||
|
||||
// Write content before truncation to dummy file
|
||||
|
|
@ -114,10 +113,11 @@ func TestRenameLog(t *testing.T) {
|
|||
4
|
||||
5
|
||||
`
|
||||
tmpDir := t.TempDir()
|
||||
// Create two dummy files
|
||||
source, err := os.CreateTemp("", "removing")
|
||||
source, err := os.CreateTemp(tmpDir, "removing")
|
||||
require.NoError(t, err)
|
||||
target, err := os.CreateTemp("", "renaming")
|
||||
target, err := os.CreateTemp(tmpDir, "renaming")
|
||||
require.NoError(t, err)
|
||||
|
||||
// Write to source dummy file
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
|
@ -44,7 +45,6 @@ import (
|
|||
jsoniter "github.com/json-iterator/go"
|
||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
// Set up the JSON library for all of Libpod
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
|
|
@ -18,7 +19,6 @@ import (
|
|||
"github.com/containers/podman/v5/pkg/domain/entities"
|
||||
"github.com/containers/podman/v5/pkg/domain/infra/abi"
|
||||
"github.com/containers/podman/v5/pkg/util"
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
dockerNetwork "github.com/docker/docker/api/types/network"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"maps"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
|
@ -33,7 +34,6 @@ import (
|
|||
"github.com/gorilla/schema"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
func ManifestCreate(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
|
|
@ -31,17 +31,17 @@ var largeAuthFileValues = map[string]types.DockerAuthConfig{
|
|||
// systemContextForAuthFile returns a types.SystemContext with AuthFilePath pointing
|
||||
// to a temporary file with fileContents, or nil if fileContents is empty; and a cleanup
|
||||
// function the caller must arrange to call.
|
||||
func systemContextForAuthFile(t *testing.T, fileContents string) (*types.SystemContext, func()) {
|
||||
func systemContextForAuthFile(t *testing.T, fileContents string) *types.SystemContext {
|
||||
if fileContents == "" {
|
||||
return nil, func() {}
|
||||
return nil
|
||||
}
|
||||
|
||||
f, err := os.CreateTemp("", "auth.json")
|
||||
f, err := os.CreateTemp(t.TempDir(), "auth.json")
|
||||
require.NoError(t, err)
|
||||
path := f.Name()
|
||||
err = os.WriteFile(path, []byte(fileContents), 0700)
|
||||
require.NoError(t, err)
|
||||
return &types.SystemContext{AuthFilePath: path}, func() { os.Remove(path) }
|
||||
return &types.SystemContext{AuthFilePath: path}
|
||||
}
|
||||
|
||||
// Test that GetCredentials() correctly parses what MakeXRegistryConfigHeader() produces
|
||||
|
|
@ -78,8 +78,7 @@ func TestMakeXRegistryConfigHeaderGetCredentialsRoundtrip(t *testing.T) {
|
|||
expectedFileValues: largeAuthFileValues,
|
||||
},
|
||||
} {
|
||||
sys, cleanup := systemContextForAuthFile(t, tc.fileContents)
|
||||
defer cleanup()
|
||||
sys := systemContextForAuthFile(t, tc.fileContents)
|
||||
headers, err := MakeXRegistryConfigHeader(sys, tc.username, tc.password)
|
||||
require.NoError(t, err)
|
||||
req, err := http.NewRequest(http.MethodPost, "/", nil)
|
||||
|
|
@ -130,8 +129,7 @@ func TestMakeXRegistryAuthHeaderGetCredentialsRoundtrip(t *testing.T) {
|
|||
expectedFileValues: largeAuthFileValues,
|
||||
},
|
||||
} {
|
||||
sys, cleanup := systemContextForAuthFile(t, tc.fileContents)
|
||||
defer cleanup()
|
||||
sys := systemContextForAuthFile(t, tc.fileContents)
|
||||
headers, err := MakeXRegistryAuthHeader(sys, tc.username, tc.password)
|
||||
require.NoError(t, err)
|
||||
req, err := http.NewRequest(http.MethodPost, "/", nil)
|
||||
|
|
@ -205,8 +203,7 @@ func TestMakeXRegistryConfigHeader(t *testing.T) {
|
|||
}`,
|
||||
},
|
||||
} {
|
||||
sys, cleanup := systemContextForAuthFile(t, tc.fileContents)
|
||||
defer cleanup()
|
||||
sys := systemContextForAuthFile(t, tc.fileContents)
|
||||
res, err := MakeXRegistryConfigHeader(sys, tc.username, tc.password)
|
||||
if tc.shouldErr {
|
||||
assert.Error(t, err, tc.name)
|
||||
|
|
@ -268,8 +265,7 @@ func TestMakeXRegistryAuthHeader(t *testing.T) {
|
|||
}`,
|
||||
},
|
||||
} {
|
||||
sys, cleanup := systemContextForAuthFile(t, tc.fileContents)
|
||||
defer cleanup()
|
||||
sys := systemContextForAuthFile(t, tc.fileContents)
|
||||
res, err := MakeXRegistryAuthHeader(sys, tc.username, tc.password)
|
||||
if tc.shouldErr {
|
||||
assert.Error(t, err, tc.name)
|
||||
|
|
|
|||
|
|
@ -9,17 +9,16 @@ import (
|
|||
func TestCreated(t *testing.T) {
|
||||
before := time.Now()
|
||||
|
||||
fileA, err := os.CreateTemp("", "ctime-test-")
|
||||
tmpDir := t.TempDir()
|
||||
fileA, err := os.CreateTemp(tmpDir, "ctime-test-")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
defer os.Remove(fileA.Name())
|
||||
|
||||
fileB, err := os.CreateTemp("", "ctime-test-")
|
||||
fileB, err := os.CreateTemp(tmpDir, "ctime-test-")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
defer os.Remove(fileB.Name())
|
||||
|
||||
after := time.Now()
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,9 @@ package env
|
|||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"maps"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
const whiteSpaces = " \t"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package compression
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
crcOs "github.com/crc-org/crc/v2/pkg/os"
|
||||
|
|
@ -11,11 +10,9 @@ import (
|
|||
func TestCopyFile(t *testing.T) {
|
||||
testStr := "test-machine"
|
||||
|
||||
srcFile, err := os.CreateTemp("", "machine-test-")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
srcFi, err := srcFile.Stat()
|
||||
tmpDir := t.TempDir()
|
||||
|
||||
srcFile, err := os.CreateTemp(tmpDir, "machine-test-")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -23,27 +20,18 @@ func TestCopyFile(t *testing.T) {
|
|||
_, _ = srcFile.Write([]byte(testStr)) //nolint:mirror
|
||||
srcFile.Close()
|
||||
|
||||
srcFilePath := filepath.Join(os.TempDir(), srcFi.Name())
|
||||
|
||||
destFile, err := os.CreateTemp("", "machine-copy-test-")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
destFi, err := destFile.Stat()
|
||||
destFile, err := os.CreateTemp(tmpDir, "machine-copy-test-")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
destFile.Close()
|
||||
|
||||
destFilePath := filepath.Join(os.TempDir(), destFi.Name())
|
||||
|
||||
if err := crcOs.CopyFile(srcFilePath, destFilePath); err != nil {
|
||||
if err := crcOs.CopyFile(srcFile.Name(), destFile.Name()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(destFilePath)
|
||||
data, err := os.ReadFile(destFile.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue