Merge pull request #5835 from thaJeztah/bump_golangci_lint
Dockerfile: update golangci-lint to v1.64.5, replace deprecated `tenv` linter in favor of `usetesting`
This commit is contained in:
commit
5e32ccefac
@ -26,7 +26,6 @@ linters:
|
|||||||
- revive # Metalinter; drop-in replacement for golint.
|
- revive # Metalinter; drop-in replacement for golint.
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- stylecheck # Replacement for golint
|
- stylecheck # Replacement for golint
|
||||||
- tenv # Detects using os.Setenv instead of t.Setenv.
|
|
||||||
- thelper # Detects test helpers without t.Helper().
|
- thelper # Detects test helpers without t.Helper().
|
||||||
- tparallel # Detects inappropriate usage of t.Parallel().
|
- tparallel # Detects inappropriate usage of t.Parallel().
|
||||||
- typecheck
|
- typecheck
|
||||||
@ -34,6 +33,7 @@ linters:
|
|||||||
- unparam
|
- unparam
|
||||||
- unused
|
- unused
|
||||||
- usestdlibvars
|
- usestdlibvars
|
||||||
|
- usetesting # Reports uses of functions with replacement inside the testing package.
|
||||||
- wastedassign
|
- wastedassign
|
||||||
|
|
||||||
disable:
|
disable:
|
||||||
@ -42,6 +42,8 @@ linters:
|
|||||||
run:
|
run:
|
||||||
# prevent golangci-lint from deducting the go version to lint for through go.mod,
|
# prevent golangci-lint from deducting the go version to lint for through go.mod,
|
||||||
# which causes it to fallback to go1.17 semantics.
|
# which causes it to fallback to go1.17 semantics.
|
||||||
|
#
|
||||||
|
# TODO(thaJeztah): update "usetesting" settings to enable go1.24 features once our minimum version is go1.24
|
||||||
go: "1.23.6"
|
go: "1.23.6"
|
||||||
timeout: 5m
|
timeout: 5m
|
||||||
|
|
||||||
@ -111,6 +113,14 @@ linters-settings:
|
|||||||
severity: warning
|
severity: warning
|
||||||
disabled: false
|
disabled: false
|
||||||
|
|
||||||
|
usetesting:
|
||||||
|
# FIXME(thaJeztah): Disable `os.Chdir()` detections; should be automatically disabled on Go < 1.24; see https://github.com/docker/cli/pull/5835#issuecomment-2665302478
|
||||||
|
os-chdir: false
|
||||||
|
# FIXME(thaJeztah): Disable `context.Background()` detections; should be automatically disabled on Go < 1.24; see https://github.com/docker/cli/pull/5835#issuecomment-2665302478
|
||||||
|
context-background: false
|
||||||
|
# FIXME(thaJeztah): Disable `context.TODO()` detections; should be automatically disabled on Go < 1.24; see https://github.com/docker/cli/pull/5835#issuecomment-2665302478
|
||||||
|
context-todo: false
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
# The default exclusion rules are a bit too permissive, so copying the relevant ones below
|
# The default exclusion rules are a bit too permissive, so copying the relevant ones below
|
||||||
exclude-use-default: false
|
exclude-use-default: false
|
||||||
|
@ -68,19 +68,19 @@ func TestTrustSignerAddErrors(t *testing.T) {
|
|||||||
func TestSignerAddCommandNoTargetsKey(t *testing.T) {
|
func TestSignerAddCommandNoTargetsKey(t *testing.T) {
|
||||||
config.SetDir(t.TempDir())
|
config.SetDir(t.TempDir())
|
||||||
|
|
||||||
tmpfile, err := os.CreateTemp("", "pemfile")
|
tmpDir := t.TempDir()
|
||||||
|
tmpFile, err := os.CreateTemp(tmpDir, "pemfile")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
tmpfile.Close()
|
assert.Check(t, tmpFile.Close())
|
||||||
defer os.Remove(tmpfile.Name())
|
|
||||||
|
|
||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cli.SetNotaryClient(notaryfake.GetEmptyTargetsNotaryRepository)
|
cli.SetNotaryClient(notaryfake.GetEmptyTargetsNotaryRepository)
|
||||||
cmd := newSignerAddCommand(cli)
|
cmd := newSignerAddCommand(cli)
|
||||||
cmd.SetArgs([]string{"--key", tmpfile.Name(), "alice", "alpine", "linuxkit/alpine"})
|
cmd.SetArgs([]string{"--key", tmpFile.Name(), "alice", "alpine", "linuxkit/alpine"})
|
||||||
|
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
assert.Error(t, cmd.Execute(), fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name()))
|
assert.Error(t, cmd.Execute(), fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpFile.Name()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSignerAddCommandBadKeyPath(t *testing.T) {
|
func TestSignerAddCommandBadKeyPath(t *testing.T) {
|
||||||
@ -130,10 +130,10 @@ func TestIngestPublicKeys(t *testing.T) {
|
|||||||
}
|
}
|
||||||
assert.Error(t, err, expectedError)
|
assert.Error(t, err, expectedError)
|
||||||
// Call with real file path
|
// Call with real file path
|
||||||
tmpfile, err := os.CreateTemp("", "pemfile")
|
tmpDir := t.TempDir()
|
||||||
|
tmpFile, err := os.CreateTemp(tmpDir, "pemfile")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
tmpfile.Close()
|
assert.Check(t, tmpFile.Close())
|
||||||
defer os.Remove(tmpfile.Name())
|
_, err = ingestPublicKeys([]string{tmpFile.Name()})
|
||||||
_, err = ingestPublicKeys([]string{tmpfile.Name()})
|
assert.Error(t, err, fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpFile.Name()))
|
||||||
assert.Error(t, err, fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name()))
|
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,14 @@ import (
|
|||||||
// Enable sets the DEBUG env var to true
|
// Enable sets the DEBUG env var to true
|
||||||
// and makes the logger to log at debug level.
|
// and makes the logger to log at debug level.
|
||||||
func Enable() {
|
func Enable() {
|
||||||
os.Setenv("DEBUG", "1")
|
_ = os.Setenv("DEBUG", "1")
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable sets the DEBUG env var to false
|
// Disable sets the DEBUG env var to false
|
||||||
// and makes the logger to log at info level.
|
// and makes the logger to log at info level.
|
||||||
func Disable() {
|
func Disable() {
|
||||||
os.Setenv("DEBUG", "")
|
_ = os.Setenv("DEBUG", "")
|
||||||
logrus.SetLevel(logrus.InfoLevel)
|
logrus.SetLevel(logrus.InfoLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
|
|
||||||
func TestEnable(t *testing.T) {
|
func TestEnable(t *testing.T) {
|
||||||
defer func() {
|
defer func() {
|
||||||
os.Setenv("DEBUG", "")
|
|
||||||
logrus.SetLevel(logrus.InfoLevel)
|
logrus.SetLevel(logrus.InfoLevel)
|
||||||
}()
|
}()
|
||||||
|
t.Setenv("DEBUG", "")
|
||||||
Enable()
|
Enable()
|
||||||
if os.Getenv("DEBUG") != "1" {
|
if os.Getenv("DEBUG") != "1" {
|
||||||
t.Fatalf("expected DEBUG=1, got %s\n", os.Getenv("DEBUG"))
|
t.Fatalf("expected DEBUG=1, got %s\n", os.Getenv("DEBUG"))
|
||||||
@ -22,6 +22,7 @@ func TestEnable(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDisable(t *testing.T) {
|
func TestDisable(t *testing.T) {
|
||||||
|
t.Setenv("DEBUG", "1")
|
||||||
Disable()
|
Disable()
|
||||||
if os.Getenv("DEBUG") != "" {
|
if os.Getenv("DEBUG") != "" {
|
||||||
t.Fatalf("expected DEBUG=\"\", got %s\n", os.Getenv("DEBUG"))
|
t.Fatalf("expected DEBUG=\"\", got %s\n", os.Getenv("DEBUG"))
|
||||||
@ -32,6 +33,7 @@ func TestDisable(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEnabled(t *testing.T) {
|
func TestEnabled(t *testing.T) {
|
||||||
|
t.Setenv("DEBUG", "")
|
||||||
Enable()
|
Enable()
|
||||||
if !IsEnabled() {
|
if !IsEnabled() {
|
||||||
t.Fatal("expected debug enabled, got false")
|
t.Fatal("expected debug enabled, got false")
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
ARG GO_VERSION=1.23.6
|
ARG GO_VERSION=1.23.6
|
||||||
ARG ALPINE_VERSION=3.21
|
ARG ALPINE_VERSION=3.21
|
||||||
ARG GOLANGCI_LINT_VERSION=v1.63.4
|
ARG GOLANGCI_LINT_VERSION=v1.64.5
|
||||||
|
|
||||||
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint
|
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user