diff --git a/Dockerfile b/Dockerfile index 81a0986dff..892fcabb3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -202,7 +202,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ PREFIX=/build /install.sh containerd FROM base AS golangci_lint -ARG GOLANGCI_LINT_VERSION=v1.44.0 +ARG GOLANGCI_LINT_VERSION=v1.46.2 RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ GOBIN=/build/ GO111MODULE=on go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}" \ diff --git a/client/request.go b/client/request.go index 086db59d01..c799095c12 100644 --- a/client/request.go +++ b/client/request.go @@ -141,7 +141,7 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp } if cli.scheme == "https" && strings.Contains(err.Error(), "bad certificate") { - return serverResp, errors.Wrap(err, "The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings") + return serverResp, errors.Wrap(err, "the server probably has client authentication (--tlsverify) enabled; check your TLS client certification settings") } // Don't decorate context sentinel errors; users may be comparing to @@ -153,7 +153,7 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp if nErr, ok := err.(*url.Error); ok { if nErr, ok := nErr.Err.(*net.OpError); ok { if os.IsPermission(nErr.Err) { - return serverResp, errors.Wrapf(err, "Got permission denied while trying to connect to the Docker daemon socket at %v", cli.host) + return serverResp, errors.Wrapf(err, "permission denied while trying to connect to the Docker daemon socket at %v", cli.host) } } } @@ -180,10 +180,10 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp if strings.Contains(err.Error(), `open //./pipe/docker_engine`) { // Checks if client is running with elevated privileges if f, elevatedErr := os.Open("\\\\.\\PHYSICALDRIVE0"); elevatedErr == nil { - err = errors.Wrap(err, "In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.") + err = errors.Wrap(err, "in the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect") } else { f.Close() - err = errors.Wrap(err, "This error may indicate that the docker daemon is not running.") + err = errors.Wrap(err, "this error may indicate that the docker daemon is not running") } } diff --git a/daemon/network.go b/daemon/network.go index fc84eaa164..438d13d71a 100644 --- a/daemon/network.go +++ b/daemon/network.go @@ -356,7 +356,7 @@ func (daemon *Daemon) createNetwork(create types.NetworkCreateRequest, id string if agent && driver == "overlay" { nodeIP, exists := daemon.GetAttachmentStore().GetIPForNetwork(id) if !exists { - return nil, fmt.Errorf("Failed to find a load balancer IP to use for network: %v", id) + return nil, fmt.Errorf("failed to find a load balancer IP to use for network: %v", id) } nwOptions = append(nwOptions, libnetwork.NetworkOptionLBEndpoint(nodeIP)) @@ -365,7 +365,7 @@ func (daemon *Daemon) createNetwork(create types.NetworkCreateRequest, id string n, err := c.NewNetwork(driver, create.Name, id, nwOptions...) if err != nil { if _, ok := err.(libnetwork.ErrDataStoreNotInitialized); ok { - //nolint: golint + //nolint: revive return nil, errors.New("This node is not a swarm manager. Use \"docker swarm init\" or \"docker swarm join\" to connect this node to swarm and try again.") } return nil, err diff --git a/distribution/pull_v2_test.go b/distribution/pull_v2_test.go index a4824dff08..76aeac2e40 100644 --- a/distribution/pull_v2_test.go +++ b/distribution/pull_v2_test.go @@ -3,7 +3,6 @@ package distribution // import "github.com/docker/docker/distribution" import ( "context" "encoding/json" - "fmt" "net/http" "net/http/httptest" "net/url" @@ -210,7 +209,7 @@ func TestFormatPlatform(t *testing.T) { } matches, _ := regexp.MatchString("windows.* [0-9]", result) if !matches { - t.Fatal(fmt.Sprintf("expected formatPlatform to show windows platform with a version, but got '%s'", result)) + t.Fatalf("expected formatPlatform to show windows platform with a version, but got '%s'", result) } } } diff --git a/hack/validate/golangci-lint.yml b/hack/validate/golangci-lint.yml index 0eb7e26c3b..1b8d385eab 100644 --- a/hack/validate/golangci-lint.yml +++ b/hack/validate/golangci-lint.yml @@ -3,12 +3,12 @@ linters: - deadcode - depguard - goimports - - golint - gosec - gosimple - govet - ineffassign - misspell + - revive - staticcheck - structcheck - typecheck @@ -49,16 +49,12 @@ issues: # ID's. # # These exclusion patterns are copied from the default excluses at: - # https://github.com/golangci/golangci-lint/blob/v1.44.0/pkg/config/issues.go#L10-L104 + # https://github.com/golangci/golangci-lint/blob/v1.46.2/pkg/config/issues.go#L10-L104 # EXC0001 - text: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked" linters: - errcheck - # EXC0003 - - text: "func name will be used as test\\.Test.* by other packages, and that stutters; consider calling this" - linters: - - golint # EXC0006 - text: "Use of unsafe calls should be audited" linters: @@ -102,9 +98,9 @@ issues: - text: "type name will be used as (container|volume)\\.(Container|Volume).* by other packages, and that stutters; consider calling this" path: "api/types/(volume|container)/" linters: - - golint + - revive # FIXME temporarily suppress these. See #39924 - - text: "SA1019: .*\\.Xattrs is deprecated: Use PAXRecords instead" + - text: "SA1019: .*\\.Xattrs has been deprecated since Go 1.10: Use PAXRecords instead" linters: - staticcheck # FIXME temporarily suppress these. See #39926 diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 7f18a1d451..85c096bd77 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -5946,10 +5946,6 @@ func (s *DockerCLIBuildSuite) TestBuildMultiStageResetScratch(c *testing.T) { } func (s *DockerCLIBuildSuite) TestBuildIntermediateTarget(c *testing.T) { - //todo: need to be removed after 18.06 release - if strings.Contains(testEnv.DaemonInfo.ServerVersion, "18.05.0") { - c.Skip(fmt.Sprintf("Bug fixed in 18.06 or higher.Skipping it for %s", testEnv.DaemonInfo.ServerVersion)) - } dockerfile := ` FROM busybox AS build-env CMD ["/dev"] diff --git a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go index a51f2d0419..bdfbcd039f 100644 --- a/integration-cli/docker_cli_daemon_test.go +++ b/integration-cli/docker_cli_daemon_test.go @@ -237,7 +237,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *testing.T) var newBasesizeBytes int64 = 53687091200 // 50GB in bytes if newBasesizeBytes < oldBasesizeBytes { - c.Skip(fmt.Sprintf("New base device size (%v) must be greater than (%s)", units.HumanSize(float64(newBasesizeBytes)), units.HumanSize(float64(oldBasesizeBytes)))) + c.Skipf("New base device size (%v) must be greater than (%s)", units.HumanSize(float64(newBasesizeBytes)), units.HumanSize(float64(oldBasesizeBytes))) } err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes)) diff --git a/integration/internal/network/network.go b/integration/internal/network/network.go index 04f29c7bb2..5a682ce84d 100644 --- a/integration/internal/network/network.go +++ b/integration/internal/network/network.go @@ -26,7 +26,7 @@ func Create(ctx context.Context, client client.APIClient, name string, ops ...fu } // CreateNoError creates a network with the specified options and verifies there were no errors -func CreateNoError(ctx context.Context, t *testing.T, client client.APIClient, name string, ops ...func(*types.NetworkCreate)) string { //nolint: golint +func CreateNoError(ctx context.Context, t *testing.T, client client.APIClient, name string, ops ...func(*types.NetworkCreate)) string { t.Helper() name, err := createNetwork(ctx, client, name, ops...) diff --git a/libnetwork/firewall_linux.go b/libnetwork/firewall_linux.go index 590e61f2af..a990ec8e91 100644 --- a/libnetwork/firewall_linux.go +++ b/libnetwork/firewall_linux.go @@ -7,9 +7,7 @@ import ( const userChain = "DOCKER-USER" -var ( - ctrl *controller = nil -) +var ctrl *controller func setupArrangeUserFilterRule(c *controller) { ctrl = c