Various code-cleanup

remove unnescessary import aliases, brackets, and so on.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2018-05-19 13:38:54 +02:00
parent 0846a02d54
commit f23c00d870
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
112 changed files with 168 additions and 182 deletions

View file

@ -3,9 +3,9 @@ package api // import "github.com/docker/docker/api"
// Common constants for daemon and client.
const (
// DefaultVersion of Current REST API
DefaultVersion string = "1.37"
DefaultVersion = "1.37"
// NoBaseImageSpecifier is the symbol used by the FROM
// command to specify that no base image is to be used.
NoBaseImageSpecifier string = "scratch"
NoBaseImageSpecifier = "scratch"
)

View file

@ -3,4 +3,4 @@
package api // import "github.com/docker/docker/api"
// MinVersion represents Minimum REST API version supported
const MinVersion string = "1.12"
const MinVersion = "1.12"

View file

@ -23,7 +23,7 @@ import (
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
"github.com/docker/docker/pkg/system"
units "github.com/docker/go-units"
"github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

View file

@ -1,13 +1,12 @@
package server // import "github.com/docker/docker/api/server"
import (
"context"
"net/http"
"net/http/httptest"
"strings"
"testing"
"context"
"github.com/docker/docker/api"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/server/middleware"

View file

@ -7,7 +7,7 @@ import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
units "github.com/docker/go-units"
"github.com/docker/go-units"
)
// CheckpointCreateOptions holds parameters to create a checkpoint from a container

View file

@ -19,7 +19,7 @@ import (
const (
// DefaultDockerfileName is the Default filename with Docker commands, read by docker build
DefaultDockerfileName string = "Dockerfile"
DefaultDockerfileName = "Dockerfile"
)
// Source defines a location that can be used as a source for the ADD/COPY

View file

@ -69,7 +69,7 @@ func (b *BuildArgs) MergeReferencedArgs(other *BuildArgs) {
// WarnOnUnusedBuildArgs checks if there are any leftover build-args that were
// passed but not consumed during build. Print a warning, if there are any.
func (b *BuildArgs) WarnOnUnusedBuildArgs(out io.Writer) {
leftoverArgs := []string{}
var leftoverArgs []string
for arg := range b.argsFromOptions {
_, isReferenced := b.referencedArgs[arg]
_, isBuiltin := builtinAllowedBuildArgs[arg]

View file

@ -387,7 +387,7 @@ func BuildFromConfig(config *container.Config, changes []string, os string) (*co
b.Stderr = ioutil.Discard
b.disableCommit = true
commands := []instructions.Command{}
var commands []instructions.Command
for _, n := range dockerfile.AST.Children {
cmd, err := instructions.ParseCommand(n)
if err != nil {

View file

@ -2,7 +2,6 @@ package instructions // import "github.com/docker/docker/builder/dockerfile/inst
import (
"errors"
"strings"
"github.com/docker/docker/api/types/container"

View file

@ -10,7 +10,7 @@ type testCase struct {
}
func initTestCases() []testCase {
testCases := []testCase{}
var testCases []testCase
testCases = append(testCases, testCase{
name: "empty args",

View file

@ -262,8 +262,7 @@ func Parse(rwc io.Reader) (*Result, error) {
}
if hasEmptyContinuationLine {
warning := "[WARNING]: Empty continuation line found in:\n " + line
warnings = append(warnings, warning)
warnings = append(warnings, "[WARNING]: Empty continuation line found in:\n "+line)
}
child, err := newNodeFromLine(line, d)

View file

@ -71,8 +71,8 @@ func TestShellParser4Words(t *testing.T) {
}
defer file.Close()
var envs []string
shlex := NewLex('\\')
envs := []string{}
scanner := bufio.NewScanner(file)
lineNum := 0
for scanner.Scan() {

View file

@ -6,7 +6,7 @@ import (
"github.com/docker/docker/pkg/containerfs"
iradix "github.com/hashicorp/go-immutable-radix"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil"
)

View file

@ -51,7 +51,7 @@ func hasManagementSubCommands(cmd *cobra.Command) bool {
}
func operationSubCommands(cmd *cobra.Command) []*cobra.Command {
cmds := []*cobra.Command{}
var cmds []*cobra.Command
for _, sub := range cmd.Commands() {
if sub.IsAvailableCommand() && !sub.HasSubCommands() {
cmds = append(cmds, sub)
@ -69,7 +69,7 @@ func wrappedFlagUsages(cmd *cobra.Command) string {
}
func managementSubCommands(cmd *cobra.Command) []*cobra.Command {
cmds := []*cobra.Command{}
var cmds []*cobra.Command
for _, sub := range cmd.Commands() {
if sub.IsAvailableCommand() && sub.HasSubCommands() {
cmds = append(cmds, sub)

View file

@ -2,6 +2,7 @@ package client // import "github.com/docker/docker/client"
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
@ -11,8 +12,6 @@ import (
"testing"
"time"
"context"
"github.com/docker/docker/api/types/container"
)

View file

@ -2,7 +2,6 @@ package client // import "github.com/docker/docker/client"
import (
"fmt"
"net/http"
"github.com/docker/docker/api/types/versions"

View file

@ -7,9 +7,8 @@ import (
"io/ioutil"
"net/http"
"reflect"
"testing"
"strings"
"testing"
)
func TestImageSaveError(t *testing.T) {

View file

@ -1,9 +1,8 @@
package client // import "github.com/docker/docker/client"
import (
"net/url"
"context"
"net/url"
"github.com/docker/docker/api/types"
)

View file

@ -2,14 +2,13 @@ package client // import "github.com/docker/docker/client"
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"net/http"
"strings"
"testing"
"context"
"github.com/docker/docker/api/types"
)

View file

@ -2,14 +2,13 @@ package client // import "github.com/docker/docker/client"
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"net/http"
"strings"
"testing"
"context"
"github.com/docker/docker/api/types"
)

View file

@ -61,7 +61,7 @@ func TestSetHostHeader(t *testing.T) {
}
return &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(([]byte("")))),
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))),
}, nil
}),

View file

@ -9,7 +9,7 @@ import (
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
)

View file

@ -5,7 +5,7 @@ package main
import (
"github.com/docker/docker/daemon/config"
"github.com/docker/docker/opts"
units "github.com/docker/go-units"
"github.com/docker/go-units"
"github.com/spf13/pflag"
)

View file

@ -4,7 +4,7 @@ import (
"net"
"net/http"
metrics "github.com/docker/go-metrics"
"github.com/docker/go-metrics"
"github.com/sirupsen/logrus"
)

View file

@ -340,7 +340,7 @@ func (v *memdbView) transform(container *Container) *Snapshot {
}
if len(container.Args) > 0 {
args := []string{}
var args []string
for _, arg := range container.Args {
if strings.Contains(arg, " ") {
args = append(args, fmt.Sprintf("'%s'", arg))

View file

@ -5,7 +5,7 @@ import (
"fmt"
"strings"
container "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/container"
mounttypes "github.com/docker/docker/api/types/mount"
types "github.com/docker/docker/api/types/swarm"
swarmapi "github.com/docker/swarmkit/api"

View file

@ -3,7 +3,7 @@ package container // import "github.com/docker/docker/daemon/cluster/executor/co
import (
"testing"
container "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/container"
swarmapi "github.com/docker/swarmkit/api"
"github.com/gotestyourself/gotestyourself/assert"
)

View file

@ -7,7 +7,7 @@ import (
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/opts"
units "github.com/docker/go-units"
"github.com/docker/go-units"
)
const (

View file

@ -6,7 +6,7 @@ import (
"testing"
"github.com/docker/docker/opts"
units "github.com/docker/go-units"
"github.com/docker/go-units"
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
"github.com/gotestyourself/gotestyourself/fs"

View file

@ -43,7 +43,7 @@ import (
lntypes "github.com/docker/libnetwork/types"
"github.com/opencontainers/runc/libcontainer/cgroups"
rsystem "github.com/opencontainers/runc/libcontainer/system"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@ -67,8 +67,8 @@ const (
// It's not kernel limit, we want this 4M limit to supply a reasonable functional container
linuxMinMemory = 4194304
// constants for remapped root settings
defaultIDSpecifier string = "default"
defaultRemappedID string = "dockremap"
defaultIDSpecifier = "default"
defaultRemappedID = "dockremap"
// constant for cgroup drivers
cgroupFsDriver = "cgroupfs"

View file

@ -16,7 +16,7 @@ import (
"github.com/docker/docker/pkg/pools"
"github.com/docker/docker/pkg/signal"
"github.com/docker/docker/pkg/term"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

View file

@ -15,7 +15,7 @@ func loadIds(root string) ([]string, error) {
if err != nil {
return nil, err
}
out := []string{}
var out []string
for _, d := range dirs {
if !d.IsDir() {
out = append(out, d.Name())
@ -36,7 +36,7 @@ func getParentIDs(root, id string) ([]string, error) {
}
defer f.Close()
out := []string{}
var out []string
s := bufio.NewScanner(f)
for s.Scan() {

View file

@ -27,7 +27,7 @@ import (
"github.com/docker/docker/pkg/mount"
"github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/parsers/kernel"
units "github.com/docker/go-units"
"github.com/docker/go-units"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@ -50,8 +50,8 @@ var (
lvmSetupConfigForce bool
)
const deviceSetMetaFile string = "deviceset-metadata"
const transactionMetaFile string = "transaction-metadata"
const deviceSetMetaFile = "deviceset-metadata"
const transactionMetaFile = "transaction-metadata"
type transaction struct {
OpenTransactionID uint64 `json:"open_transaction_id"`

View file

@ -15,7 +15,7 @@ import (
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/locker"
"github.com/docker/docker/pkg/mount"
units "github.com/docker/go-units"
"github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"

View file

@ -15,7 +15,7 @@ import (
"github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/daemon/graphdriver/quota"
"github.com/docker/docker/pkg/stringid"
units "github.com/docker/go-units"
"github.com/docker/go-units"
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
"golang.org/x/sys/unix"

View file

@ -148,7 +148,7 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64
}
defer drv.Put(layer)
changes := []archive.Change{}
var changes []archive.Change
for i := 0; i < count; i += 100 {
archiveRoot := fmt.Sprintf("/directory-%d", i)
if err := root.MkdirAll(root.Join(root.Path(), archiveRoot), 0755); err != nil {

View file

@ -10,7 +10,7 @@ import (
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/system"
units "github.com/docker/go-units"
"github.com/docker/go-units"
"github.com/opencontainers/selinux/go-selinux/label"
)

View file

@ -17,7 +17,7 @@ import (
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/mount"
"github.com/docker/docker/pkg/parsers"
zfs "github.com/mistifyio/go-zfs"
"github.com/mistifyio/go-zfs"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"

View file

@ -18,7 +18,7 @@ import (
type conflictType int
const (
conflictDependentChild conflictType = (1 << iota)
conflictDependentChild conflictType = 1 << iota
conflictRunningContainer
conflictActiveReference
conflictStoppedContainer
@ -126,7 +126,7 @@ func (i *ImageService) ImageDelete(imageRef string, force, prune bool) ([]types.
}
if !foundRepoTagRef {
// Remove canonical references from same repository
remainingRefs := []reference.Named{}
var remainingRefs []reference.Named
for _, repoRef := range repoRefs {
if _, repoRefIsCanonical := repoRef.(reference.Canonical); repoRefIsCanonical && parsedRef.Name() == repoRef.Name() {
if _, err := i.removeImageRef(repoRef); err != nil {

View file

@ -13,7 +13,7 @@ import (
"github.com/docker/docker/errdefs"
"github.com/docker/docker/image"
"github.com/docker/docker/layer"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/go-digest"
"github.com/sirupsen/logrus"
)

View file

@ -3,7 +3,7 @@ package images // import "github.com/docker/docker/daemon/images"
import (
"fmt"
metrics "github.com/docker/go-metrics"
"github.com/docker/go-metrics"
)
type invalidFilter struct {

View file

@ -37,7 +37,7 @@ func (a *pluginAdapter) Log(msg *Message) error {
a.buf.Line = msg.Line
a.buf.TimeNano = msg.Timestamp.UnixNano()
a.buf.Partial = (msg.PLogMetaData != nil)
a.buf.Partial = msg.PLogMetaData != nil
a.buf.Source = msg.Source
err := a.enc.Encode(&a.buf)

View file

@ -1139,8 +1139,8 @@ func TestCollectBatchWithDuplicateTimestamps(t *testing.T) {
close(d)
go stream.collectBatch(d)
var expectedEvents []*cloudwatchlogs.InputLogEvent
times := maximumLogEventsPerPut
expectedEvents := []*cloudwatchlogs.InputLogEvent{}
timestamp := time.Now()
for i := 0; i < times; i++ {
line := fmt.Sprintf("%d", i)

View file

@ -7,7 +7,7 @@ import (
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/pkg/plugingetter"
units "github.com/docker/go-units"
"github.com/docker/go-units"
"github.com/pkg/errors"
)

View file

@ -1,13 +1,12 @@
package gcplogs // import "github.com/docker/docker/daemon/logger/gcplogs"
import (
"context"
"fmt"
"sync"
"sync/atomic"
"time"
"context"
"github.com/docker/docker/daemon/logger"
"cloud.google.com/go/compute/metadata"

View file

@ -13,7 +13,7 @@ import (
"github.com/docker/docker/daemon/logger"
"github.com/docker/docker/daemon/logger/jsonfilelog/jsonlog"
"github.com/docker/docker/daemon/logger/loggerutils"
units "github.com/docker/go-units"
"github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

View file

@ -205,7 +205,7 @@ func TestMultiReadSeekerCurAfterSet(t *testing.T) {
}
func TestMultiReadSeekerSmallReads(t *testing.T) {
readers := []io.ReadSeeker{}
var readers []io.ReadSeeker
for i := 0; i < 10; i++ {
integer := make([]byte, 4)
binary.BigEndian.PutUint32(integer, uint32(i))

View file

@ -4,7 +4,7 @@ import (
"sync"
"github.com/docker/docker/pkg/plugingetter"
metrics "github.com/docker/go-metrics"
"github.com/docker/go-metrics"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"

View file

@ -10,8 +10,8 @@ import (
"github.com/docker/docker/pkg/plugingetter"
"github.com/docker/docker/pkg/plugins"
"github.com/docker/docker/plugin"
metrics "github.com/docker/go-metrics"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/docker/go-metrics"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"

View file

@ -23,7 +23,7 @@ import (
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/devices"
"github.com/opencontainers/runc/libcontainer/user"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"

View file

@ -89,7 +89,7 @@ func TestDaemonReloadAllowNondistributableArtifacts(t *testing.T) {
t.Fatal(err)
}
actual := []string{}
var actual []string
serviceConfig := daemon.RegistryService.ServiceConfig()
for _, value := range serviceConfig.AllowNondistributableArtifactsCIDRs {
actual = append(actual, value.String())

View file

@ -5,7 +5,7 @@ import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/libcontainerd"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-spec/specs-go"
)
func toContainerdResources(resources container.Resources) *libcontainerd.Resources {

View file

@ -48,7 +48,7 @@ func TestContinueOnError_NonMirrorEndpoint(t *testing.T) {
}
func TestContinueOnError_MirrorEndpoint(t *testing.T) {
errs := []error{}
var errs []error
errs = append(errs, alwaysContinue...)
errs = append(errs, continueFromMirrorEndpoint...)
for _, err := range errs {

View file

@ -30,7 +30,7 @@ import (
"github.com/docker/docker/pkg/system"
refstore "github.com/docker/docker/reference"
"github.com/docker/docker/registry"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

View file

@ -24,7 +24,7 @@ import (
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/registry"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/go-digest"
"github.com/sirupsen/logrus"
)

View file

@ -6,12 +6,12 @@ package dockerversion // import "github.com/docker/docker/dockerversion"
// Default build-time variable for library-import.
// This file is overridden on build with build-time informations.
const (
GitCommit string = "library-import"
Version string = "library-import"
BuildTime string = "library-import"
IAmStatic string = "library-import"
ContainerdCommitID string = "library-import"
RuncCommitID string = "library-import"
InitCommitID string = "library-import"
PlatformName string = ""
GitCommit = "library-import"
Version = "library-import"
BuildTime = "library-import"
IAmStatic = "library-import"
ContainerdCommitID = "library-import"
RuncCommitID = "library-import"
InitCommitID = "library-import"
PlatformName = ""
)

View file

@ -8,7 +8,7 @@ import (
)
func generateInput(inputLen int) []string {
input := []string{}
var input []string
for i := 0; i < inputLen; i++ {
input = append(input, fmt.Sprintf("s%d", i))
}
@ -21,7 +21,7 @@ func testChunkStrings(t *testing.T, inputLen, numChunks int) {
input := generateInput(inputLen)
result := chunkStrings(input, numChunks)
t.Logf("result has %d chunks", len(result))
inputReconstructedFromResult := []string{}
var inputReconstructedFromResult []string
for i, chunk := range result {
t.Logf("chunk %d has %d elements", i, len(chunk))
inputReconstructedFromResult = append(inputReconstructedFromResult, chunk...)

View file

@ -23,7 +23,7 @@ import (
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/pkg/symlink"
"github.com/docker/docker/pkg/system"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/go-digest"
"github.com/sirupsen/logrus"
)

View file

@ -543,7 +543,7 @@ type buildLine struct {
}
func getImageIDsFromBuild(c *check.C, output []byte) []string {
ids := []string{}
var ids []string
for _, line := range bytes.Split(output, []byte("\n")) {
if len(line) == 0 {
continue

View file

@ -289,7 +289,7 @@ func isNetworkAvailable(c *check.C, name string) bool {
defer resp.Body.Close()
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK)
nJSON := []types.NetworkResource{}
var nJSON []types.NetworkResource
err = json.NewDecoder(body).Decode(&nJSON)
c.Assert(err, checker.IsNil)
@ -315,7 +315,7 @@ func getNetworkIDByName(c *check.C, name string) string {
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK)
c.Assert(err, checker.IsNil)
nJSON := []types.NetworkResource{}
var nJSON []types.NetworkResource
err = json.NewDecoder(body).Decode(&nJSON)
c.Assert(err, checker.IsNil)
var res string

View file

@ -27,7 +27,7 @@ import (
"github.com/docker/docker/pkg/archive"
"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/go-digest"
)
func (s *DockerSuite) TestBuildJSONEmptyRun(c *check.C) {
@ -195,7 +195,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementEnv(c *check.C) {
RUN [ "$foo5" = 'abc\def' ]
`))
envResult := []string{}
var envResult []string
inspectFieldAndUnmarshall(c, name, "Config.Env", &envResult)
found := false
envCount := 0
@ -4979,7 +4979,7 @@ func (s *DockerSuite) TestBuildLabelMultiple(c *check.C) {
"foo": "bar",
"123": "456",
}
labelArgs := []string{}
var labelArgs []string
for k, v := range testLabels {
labelArgs = append(labelArgs, "--label", k+"="+v)
}

View file

@ -19,7 +19,7 @@ import (
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/fakecontext"
units "github.com/docker/go-units"
"github.com/docker/go-units"
"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

View file

@ -26,13 +26,13 @@ func (s *DockerSuite) TestCreateArgs(c *check.C) {
out, _ = dockerCmd(c, "inspect", cleanedContainerID)
containers := []struct {
var containers []struct {
ID string
Created time.Time
Path string
Args []string
Image string
}{}
}
err := json.Unmarshal([]byte(out), &containers)
c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
@ -87,11 +87,11 @@ func (s *DockerSuite) TestCreateHostConfig(c *check.C) {
out, _ = dockerCmd(c, "inspect", cleanedContainerID)
containers := []struct {
var containers []struct {
HostConfig *struct {
PublishAllPorts bool
}
}{}
}
err := json.Unmarshal([]byte(out), &containers)
c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
@ -109,11 +109,11 @@ func (s *DockerSuite) TestCreateWithPortRange(c *check.C) {
out, _ = dockerCmd(c, "inspect", cleanedContainerID)
containers := []struct {
var containers []struct {
HostConfig *struct {
PortBindings map[nat.Port][]nat.PortBinding
}
}{}
}
err := json.Unmarshal([]byte(out), &containers)
c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
c.Assert(containers, checker.HasLen, 1)
@ -138,11 +138,11 @@ func (s *DockerSuite) TestCreateWithLargePortRange(c *check.C) {
out, _ = dockerCmd(c, "inspect", cleanedContainerID)
containers := []struct {
var containers []struct {
HostConfig *struct {
PortBindings map[nat.Port][]nat.PortBinding
}
}{}
}
err := json.Unmarshal([]byte(out), &containers)
c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))

View file

@ -6,6 +6,8 @@ import (
"bufio"
"bytes"
"context"
"crypto/tls"
"crypto/x509"
"encoding/json"
"fmt"
"io"
@ -21,9 +23,6 @@ import (
"sync"
"time"
"crypto/tls"
"crypto/x509"
"github.com/cloudflare/cfssl/helpers"
"github.com/docker/docker/api"
"github.com/docker/docker/api/types"
@ -36,7 +35,7 @@ import (
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/opts"
"github.com/docker/docker/pkg/mount"
units "github.com/docker/go-units"
"github.com/docker/go-units"
"github.com/docker/libnetwork/iptables"
"github.com/docker/libtrust"
"github.com/go-check/check"
@ -1828,8 +1827,8 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) {
func (s *DockerDaemonSuite) TestDaemonRestartContainerLinksRestart(c *check.C) {
s.d.StartWithBusybox(c)
parent1Args := []string{}
parent2Args := []string{}
var parent1Args []string
var parent2Args []string
wg := sync.WaitGroup{}
maxChildren := 10
chErr := make(chan error, maxChildren)

View file

@ -262,7 +262,7 @@ func (s *DockerSuite) TestExecCgroup(c *check.C) {
var wg sync.WaitGroup
var mu sync.Mutex
execCgroups := []sort.StringSlice{}
var execCgroups []sort.StringSlice
errChan := make(chan error)
// exec a few times concurrently to get consistent failure
for i := 0; i < 5; i++ {

View file

@ -273,7 +273,7 @@ func assertNwList(c *check.C, out string, expectNws []string) {
func getNwResource(c *check.C, name string) *types.NetworkResource {
out, _ := dockerCmd(c, "network", "inspect", name)
nr := []types.NetworkResource{}
var nr []types.NetworkResource
err := json.Unmarshal([]byte(out), &nr)
c.Assert(err, check.IsNil)
return &nr[0]
@ -426,7 +426,7 @@ func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *check.C) {
func (s *DockerSuite) TestDockerNetworkInspect(c *check.C) {
out, _ := dockerCmd(c, "network", "inspect", "host")
networkResources := []types.NetworkResource{}
var networkResources []types.NetworkResource
err := json.Unmarshal([]byte(out), &networkResources)
c.Assert(err, check.IsNil)
c.Assert(networkResources, checker.HasLen, 1)
@ -450,7 +450,7 @@ func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *check.C) {
result := dockerCmdWithResult("network", "inspect", "host", "none")
result.Assert(c, icmd.Success)
networkResources := []types.NetworkResource{}
var networkResources []types.NetworkResource
err := json.Unmarshal([]byte(result.Stdout()), &networkResources)
c.Assert(err, check.IsNil)
c.Assert(networkResources, checker.HasLen, 2)
@ -466,7 +466,7 @@ func (s *DockerSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *c
Out: "host",
})
networkResources := []types.NetworkResource{}
var networkResources []types.NetworkResource
err := json.Unmarshal([]byte(result.Stdout()), &networkResources)
c.Assert(err, check.IsNil)
c.Assert(networkResources, checker.HasLen, 1)
@ -512,7 +512,7 @@ func (s *DockerSuite) TestDockerInspectNetworkWithContainerName(c *check.C) {
}()
out, _ = dockerCmd(c, "network", "inspect", "brNetForInspect")
networkResources := []types.NetworkResource{}
var networkResources []types.NetworkResource
err := json.Unmarshal([]byte(out), &networkResources)
c.Assert(err, check.IsNil)
c.Assert(networkResources, checker.HasLen, 1)
@ -526,7 +526,7 @@ func (s *DockerSuite) TestDockerInspectNetworkWithContainerName(c *check.C) {
// check whether network inspect works properly
out, _ = dockerCmd(c, "network", "inspect", "brNetForInspect")
newNetRes := []types.NetworkResource{}
var newNetRes []types.NetworkResource
err = json.Unmarshal([]byte(out), &newNetRes)
c.Assert(err, check.IsNil)
c.Assert(newNetRes, checker.HasLen, 1)

View file

@ -172,7 +172,7 @@ func (s *DockerSuite) TestPsListContainersSize(c *check.C) {
idIndex := strings.Index(lines[0], "CONTAINER ID")
foundID := lines[1][idIndex : idIndex+12]
c.Assert(foundID, checker.Equals, id[:12], check.Commentf("Expected id %s, got %s", id[:12], foundID))
expectedSize := fmt.Sprintf("%dB", (2 + baseBytes))
expectedSize := fmt.Sprintf("%dB", 2+baseBytes)
foundSize := lines[1][sizeIndex:]
c.Assert(foundSize, checker.Contains, expectedSize, check.Commentf("Expected size %q, got %q", expectedSize, foundSize))
}
@ -377,7 +377,7 @@ func (s *DockerSuite) TestPsListContainersFilterAncestorImage(c *check.C) {
}
func checkPsAncestorFilterOutput(c *check.C, out string, filterName string, expectedIDs []string) {
actualIDs := []string{}
var actualIDs []string
if out != "" {
actualIDs = strings.Split(out[:len(out)-1], "\n")
}

View file

@ -27,7 +27,7 @@ import (
func testPullImageWithAliases(c *check.C) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
repos := []string{}
var repos []string
for _, tag := range []string{"recent", "fresh"} {
repos = append(repos, fmt.Sprintf("%v:%v", repoName, tag))
}
@ -63,7 +63,7 @@ func (s *DockerSchema1RegistrySuite) TestPullImageWithAliases(c *check.C) {
func testConcurrentPullWholeRepo(c *check.C) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
repos := []string{}
var repos []string
for _, tag := range []string{"recent", "fresh", "todays"} {
repo := fmt.Sprintf("%v:%v", repoName, tag)
buildImageSuccessfully(c, repo, build.WithDockerfile(fmt.Sprintf(`
@ -151,7 +151,7 @@ func (s *DockerSchema1RegistrySuite) testConcurrentFailingPull(c *check.C) {
func testConcurrentPullMultipleTags(c *check.C) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
repos := []string{}
var repos []string
for _, tag := range []string{"recent", "fresh", "todays"} {
repo := fmt.Sprintf("%v:%v", repoName, tag)
buildImageSuccessfully(c, repo, build.WithDockerfile(fmt.Sprintf(`

View file

@ -155,7 +155,7 @@ func (s *DockerSchema1RegistrySuite) TestPushEmptyLayer(c *check.C) {
func testConcurrentPush(c *check.C) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
repos := []string{}
var repos []string
for _, tag := range []string{"push1", "push2", "push3"} {
repo := fmt.Sprintf("%v:%v", repoName, tag)
buildImageSuccessfully(c, repo, build.WithDockerfile(fmt.Sprintf(`

View file

@ -19,7 +19,7 @@ import (
"github.com/docker/docker/integration-cli/cli/build"
"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/go-digest"
)
// save a repo using gz compression and try to load it using stdout
@ -100,10 +100,10 @@ func (s *DockerSuite) TestSaveCheckTimes(c *check.C) {
testRequires(c, DaemonIsLinux)
repoName := "busybox:latest"
out, _ := dockerCmd(c, "inspect", repoName)
data := []struct {
var data []struct {
ID string
Created time.Time
}{}
}
err := json.Unmarshal([]byte(out), &data)
c.Assert(err, checker.IsNil, check.Commentf("failed to marshal from %q: err %v", repoName, err))
c.Assert(len(data), checker.Not(checker.Equals), 0, check.Commentf("failed to marshal the data from %q", repoName))

View file

@ -16,7 +16,7 @@ import (
func (s *DockerSuite) TestClientSetsTLSServerName(c *check.C) {
c.Skip("Flakey test")
// there may be more than one hit to the server for each registry request
serverNameReceived := []string{}
var serverNameReceived []string
var serverName string
virtualHostServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

View file

@ -2,7 +2,6 @@ package environment // import "github.com/docker/docker/integration-cli/environm
import (
"os"
"os/exec"
"github.com/docker/docker/internal/test/environment"

View file

@ -119,7 +119,7 @@ type elementListOptions struct {
}
func existingElements(c *check.C, opts elementListOptions) []string {
args := []string{}
var args []string
switch opts.element {
case "container":
args = append(args, "ps", "-a")
@ -136,7 +136,7 @@ func existingElements(c *check.C, opts elementListOptions) []string {
args = append(args, "--format", opts.format)
}
out, _ := dockerCmd(c, args...)
lines := []string{}
var lines []string
for _, l := range strings.Split(out, "\n") {
if l != "" {
lines = append(lines, l)

View file

@ -443,7 +443,7 @@ type buildLine struct {
}
func getImageIDsFromBuild(output []byte) ([]string, error) {
ids := []string{}
var ids []string
for _, line := range bytes.Split(output, []byte("\n")) {
if len(line) == 0 {
continue

View file

@ -46,7 +46,7 @@ func TestConfigList(t *testing.T) {
config1ID := createConfig(ctx, t, client, testName1, []byte("TESTINGDATA1"), map[string]string{"type": "production"})
names := func(entries []swarmtypes.Config) []string {
values := []string{}
var values []string
for _, entry := range entries {
values = append(values, entry.Spec.Name)
}

View file

@ -51,7 +51,7 @@ func TestPause(t *testing.T) {
}
func TestPauseFailsOnWindowsServerContainers(t *testing.T) {
skip.If(t, (testEnv.DaemonInfo.OSType != "windows" || testEnv.DaemonInfo.Isolation != "process"))
skip.If(t, testEnv.DaemonInfo.OSType != "windows" || testEnv.DaemonInfo.Isolation != "process")
defer setupTest(t)()
client := request.NewAPIClient(t)
@ -85,7 +85,7 @@ func TestPauseStopPausedContainer(t *testing.T) {
}
func getEventActions(t *testing.T, messages <-chan events.Message, errs <-chan error) []string {
actions := []string{}
var actions []string
for {
select {
case err := <-errs:

View file

@ -22,7 +22,7 @@ func TestPsFilter(t *testing.T) {
next := container.Create(t, ctx, client)
containerIDs := func(containers []types.Container) []string {
entries := []string{}
var entries []string
for _, container := range containers {
entries = append(entries, container.ID)
}

View file

@ -173,8 +173,8 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
out1, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
assert.Check(t, (out1.IPAM.Config[0].Subnet != networkip))
assert.Check(t, (out1.IPAM.Config[0].Subnet != networkip2))
assert.Check(t, out1.IPAM.Config[0].Subnet != networkip)
assert.Check(t, out1.IPAM.Config[0].Subnet != networkip2)
delInterface(t, defaultNetworkBridge)
}

View file

@ -63,7 +63,7 @@ func TestSecretList(t *testing.T) {
secret1ID := createSecret(ctx, t, client, testName1, []byte("TESTINGDATA1"), map[string]string{"type": "production"})
names := func(entries []swarmtypes.Secret) []string {
values := []string{}
var values []string
for _, entry := range entries {
values = append(values, entry.Spec.Name)
}

View file

@ -77,7 +77,7 @@ func getExistingContainers(t assert.TestingT, testEnv *Execution) []string {
})
assert.NilError(t, err, "failed to list containers")
containers := []string{}
var containers []string
for _, container := range containerList {
containers = append(containers, container.ID)
}
@ -121,7 +121,7 @@ func getExistingImages(t assert.TestingT, testEnv *Execution) []string {
})
assert.NilError(t, err, "failed to list images")
images := []string{}
var images []string
for _, image := range imageList {
images = append(images, tagsFromImageSummary(image)...)
}
@ -129,7 +129,7 @@ func getExistingImages(t assert.TestingT, testEnv *Execution) []string {
}
func tagsFromImageSummary(image types.ImageSummary) []string {
result := []string{}
var result []string
for _, tag := range image.RepoTags {
if tag != "<none>:<none>" {
result = append(result, tag)
@ -172,7 +172,7 @@ func getExistingNetworks(t assert.TestingT, testEnv *Execution) []string {
networkList, err := client.NetworkList(context.Background(), types.NetworkListOptions{})
assert.NilError(t, err, "failed to list networks")
networks := []string{}
var networks []string
for _, network := range networkList {
networks = append(networks, network.ID)
}
@ -211,7 +211,7 @@ func getExistingPlugins(t assert.TestingT, testEnv *Execution) []string {
}
assert.NilError(t, err, "failed to list plugins")
plugins := []string{}
var plugins []string
for _, plugin := range pluginList {
plugins = append(plugins, plugin.Name)
}
@ -246,7 +246,7 @@ func getExistingVolumes(t assert.TestingT, testEnv *Execution) []string {
volumeList, err := client.VolumeList(context.Background(), filters.Args{})
assert.NilError(t, err, "failed to list volumes")
volumes := []string{}
var volumes []string
for _, volume := range volumeList.Volumes {
volumes = append(volumes, volume.Name)
}

View file

@ -10,7 +10,7 @@ import (
"github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/docker/docker/pkg/idtools"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
)

View file

@ -4,7 +4,7 @@ import (
"time"
"github.com/containerd/cgroups"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-spec/specs-go"
)
// Summary is not used on linux

View file

@ -1,6 +1,7 @@
package v1 // import "github.com/docker/docker/migrate/v1"
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
@ -11,8 +12,6 @@ import (
"sync"
"time"
"encoding/json"
"github.com/docker/distribution/reference"
"github.com/docker/docker/distribution/metadata"
"github.com/docker/docker/image"

View file

@ -8,7 +8,7 @@ import (
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/devices"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-spec/specs-go"
)
// Device transforms a libcontainer configs.Device to a specs.LinuxDevice object.

View file

@ -1,6 +1,6 @@
package oci // import "github.com/docker/docker/oci"
import specs "github.com/opencontainers/runtime-spec/specs-go"
import "github.com/opencontainers/runtime-spec/specs-go"
// RemoveNamespace removes the `nsType` namespace from OCI spec `s`
func RemoveNamespace(s *specs.Spec, nsType specs.LinuxNamespaceType) {

View file

@ -65,7 +65,7 @@ func (p *PoolsOpt) Type() string {
// String returns a string repr of this option
func (p *PoolsOpt) String() string {
pools := []string{}
var pools []string
for _, pool := range p.values {
repr := fmt.Sprintf("%s %d", pool.Base, pool.Size)
pools = append(pools, repr)

View file

@ -7,7 +7,7 @@ import (
"regexp"
"strings"
units "github.com/docker/go-units"
"github.com/docker/go-units"
)
var (
@ -52,7 +52,7 @@ func (opts *ListOpts) Set(value string) error {
}
value = v
}
(*opts.values) = append((*opts.values), value)
*opts.values = append(*opts.values, value)
return nil
}
@ -60,7 +60,7 @@ func (opts *ListOpts) Set(value string) error {
func (opts *ListOpts) Delete(key string) {
for i, k := range *opts.values {
if k == key {
(*opts.values) = append((*opts.values)[:i], (*opts.values)[i+1:]...)
*opts.values = append((*opts.values)[:i], (*opts.values)[i+1:]...)
return
}
}
@ -78,7 +78,7 @@ func (opts *ListOpts) GetMap() map[string]struct{} {
// GetAll returns the values of slice.
func (opts *ListOpts) GetAll() []string {
return (*opts.values)
return *opts.values
}
// GetAllOrEmpty returns the values of the slice
@ -103,7 +103,7 @@ func (opts *ListOpts) Get(key string) bool {
// Len returns the amount of element in the slice.
func (opts *ListOpts) Len() int {
return len((*opts.values))
return len(*opts.values)
}
// Type returns a string name for this Option type

View file

@ -112,7 +112,7 @@ func (th tarHeaders) Less(i, j int) bool { return th[i].Name < th[j].Name }
func walkHeaders(r io.Reader) ([]tar.Header, error) {
t := tar.NewReader(r)
headers := []tar.Header{}
var headers []tar.Header
for {
hdr, err := t.Next()
if err != nil {

View file

@ -9,7 +9,7 @@ func timeToTimespec(time time.Time) (ts syscall.Timespec) {
if time.IsZero() {
// Return UTIME_OMIT special value
ts.Sec = 0
ts.Nsec = ((1 << 30) - 2)
ts.Nsec = (1 << 30) - 2
return
}
return syscall.NsecToTimespec(time.UnixNano())

View file

@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"strings"
"testing"
)

View file

@ -216,7 +216,7 @@ func dmGetNextTargetFct(task *cdmTask, next unsafe.Pointer, start, length *uint6
}
func dmUdevSetSyncSupportFct(syncWithUdev int) {
(C.dm_udev_set_sync_support(C.int(syncWithUdev)))
C.dm_udev_set_sync_support(C.int(syncWithUdev))
}
func dmUdevGetSyncSupportFct() int {

View file

@ -30,8 +30,8 @@ func (e ranges) Swap(i, j int) { e[i], e[j] = e[j], e[i] }
func (e ranges) Less(i, j int) bool { return e[i].Start < e[j].Start }
const (
subuidFileName string = "/etc/subuid"
subgidFileName string = "/etc/subgid"
subuidFileName = "/etc/subuid"
subgidFileName = "/etc/subgid"
)
// MkdirAllAndChown creates a directory (include any along the path) and then modifies

View file

@ -8,9 +8,9 @@ import (
"strings"
"time"
gotty "github.com/Nvveen/Gotty"
"github.com/Nvveen/Gotty"
"github.com/docker/docker/pkg/term"
units "github.com/docker/go-units"
"github.com/docker/go-units"
)
// RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to

View file

@ -20,7 +20,7 @@ func TestSendToOneSub(t *testing.T) {
func TestSendToMultipleSubs(t *testing.T) {
p := NewPublisher(100*time.Millisecond, 10)
subs := []chan interface{}{}
var subs []chan interface{}
subs = append(subs, p.Subscribe(), p.Subscribe(), p.Subscribe())
p.Publish("hi")
@ -52,7 +52,7 @@ func TestEvictOneSub(t *testing.T) {
func TestClosePublisher(t *testing.T) {
p := NewPublisher(100*time.Millisecond, 10)
subs := []chan interface{}{}
var subs []chan interface{}
subs = append(subs, p.Subscribe(), p.Subscribe(), p.Subscribe())
p.Close()
@ -99,7 +99,7 @@ func newTestSubscriber(p *Publisher) *testSubscriber {
// for testing with -race
func TestPubSubRace(t *testing.T) {
p := NewPublisher(0, 1024)
var subs [](*testSubscriber)
var subs []*testSubscriber
for j := 0; j < 50; j++ {
subs = append(subs, newTestSubscriber(p))
}
@ -120,7 +120,7 @@ func BenchmarkPubSub(b *testing.B) {
for i := 0; i < b.N; i++ {
b.StopTimer()
p := NewPublisher(0, 1024)
var subs [](*testSubscriber)
var subs []*testSubscriber
for j := 0; j < 50; j++ {
subs = append(subs, newTestSubscriber(p))
}

View file

@ -13,7 +13,7 @@ import (
// CatchAll catches all signals and relays them to the specified channel.
func CatchAll(sigc chan os.Signal) {
handledSigs := []os.Signal{}
var handledSigs []os.Signal
for _, s := range SignalMap {
handledSigs = append(handledSigs, s)
}

View file

@ -9,7 +9,7 @@ import (
"os"
"sync"
ansiterm "github.com/Azure/go-ansiterm"
"github.com/Azure/go-ansiterm"
"github.com/sirupsen/logrus"
)

View file

@ -10,7 +10,7 @@ import (
// Test the behavior of TruncIndex, an index for querying IDs from a non-conflicting prefix.
func TestTruncIndex(t *testing.T) {
ids := []string{}
var ids []string
index := NewTruncIndex(ids)
// Get on an empty index
if _, err := index.Get("foobar"); err == nil {

View file

@ -33,7 +33,7 @@ import (
"github.com/docker/docker/pkg/system"
"github.com/docker/docker/plugin/v2"
refstore "github.com/docker/docker/reference"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

View file

@ -5,7 +5,7 @@ import (
"github.com/docker/docker/pkg/plugins"
"github.com/docker/docker/plugin/v2"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-spec/specs-go"
)
// Store manages the plugin inventory in memory and on-disk

View file

@ -10,7 +10,7 @@ import (
"github.com/docker/docker/libcontainerd"
"github.com/gotestyourself/gotestyourself/assert"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
)

Some files were not shown because too many files have changed in this diff Show more