From c0d004f7cf11d7340b3b522380d9cdbf86437617 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 11 Oct 2017 12:18:27 -0400 Subject: [PATCH] Update gometalinter and enable the new WarnUnmatchedDirective to warn if a nolint is unnecessary. remove some unnecessary nolint Signed-off-by: Daniel Nephin --- cli/command/config/cmd.go | 3 +-- cli/command/container/cmd.go | 3 +-- cli/command/container/commit.go | 4 ++-- cli/command/container/cp.go | 10 +++++----- cli/command/container/diff.go | 4 ++-- cli/command/container/export.go | 4 ++-- cli/command/container/inspect.go | 4 ++-- cli/command/container/kill.go | 4 ++-- cli/command/container/list.go | 6 +++--- cli/command/container/logs.go | 4 ++-- cli/command/container/pause.go | 4 ++-- cli/command/container/port.go | 4 ++-- cli/command/container/rename.go | 4 ++-- cli/command/container/restart.go | 4 ++-- cli/command/container/rm.go | 4 ++-- cli/command/container/run.go | 6 +++--- cli/command/container/start.go | 6 +++--- cli/command/container/stats.go | 4 ++-- cli/command/container/stop.go | 4 ++-- cli/command/container/top.go | 4 ++-- cli/command/container/unpause.go | 4 ++-- cli/command/container/update.go | 4 ++-- cli/command/container/utils.go | 4 ++-- cli/command/container/wait.go | 4 ++-- cli/command/plugin/cmd.go | 3 +-- cli/command/plugin/create.go | 4 ++-- cli/command/plugin/disable.go | 4 ++-- cli/command/plugin/enable.go | 4 ++-- cli/command/plugin/inspect.go | 4 ++-- cli/command/plugin/install.go | 8 ++++---- cli/command/plugin/list.go | 4 ++-- cli/command/plugin/remove.go | 4 ++-- cli/command/plugin/set.go | 2 +- cli/command/plugin/upgrade.go | 4 ++-- cli/command/secret/cmd.go | 3 +-- cli/command/service/cmd.go | 3 +-- cli/command/service/logs.go | 4 ++-- cli/command/service/opts.go | 2 +- cli/command/stack/cmd.go | 3 +-- cli/command/swarm/cmd.go | 1 - cli/command/system/cmd.go | 3 +-- cli/command/system/df.go | 4 ++-- cli/command/system/events.go | 4 ++-- cli/command/system/info.go | 6 +++--- dockerfiles/Dockerfile.lint | 2 +- gometalinter.json | 1 + 46 files changed, 88 insertions(+), 95 deletions(-) diff --git a/cli/command/config/cmd.go b/cli/command/config/cmd.go index 0adadadfac..19120348bb 100644 --- a/cli/command/config/cmd.go +++ b/cli/command/config/cmd.go @@ -8,8 +8,7 @@ import ( ) // NewConfigCommand returns a cobra command for `config` subcommands -// nolint: interfacer -func NewConfigCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewConfigCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "config", Short: "Manage Docker configs", diff --git a/cli/command/container/cmd.go b/cli/command/container/cmd.go index 82500be02e..dcf8116ef1 100644 --- a/cli/command/container/cmd.go +++ b/cli/command/container/cmd.go @@ -7,8 +7,7 @@ import ( ) // NewContainerCommand returns a cobra command for `container` subcommands -// nolint: interfacer -func NewContainerCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewContainerCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "container", Short: "Manage containers", diff --git a/cli/command/container/commit.go b/cli/command/container/commit.go index 689918e083..6fc5277645 100644 --- a/cli/command/container/commit.go +++ b/cli/command/container/commit.go @@ -22,7 +22,7 @@ type commitOptions struct { } // NewCommitCommand creates a new cobra.Command for `docker commit` -func NewCommitCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewCommitCommand(dockerCli command.Cli) *cobra.Command { var options commitOptions cmd := &cobra.Command{ @@ -51,7 +51,7 @@ func NewCommitCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runCommit(dockerCli *command.DockerCli, options *commitOptions) error { +func runCommit(dockerCli command.Cli, options *commitOptions) error { ctx := context.Background() name := options.container diff --git a/cli/command/container/cp.go b/cli/command/container/cp.go index 2f054b12e2..32427cc329 100644 --- a/cli/command/container/cp.go +++ b/cli/command/container/cp.go @@ -36,7 +36,7 @@ type cpConfig struct { } // NewCopyCommand creates a new `docker cp` command -func NewCopyCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewCopyCommand(dockerCli command.Cli) *cobra.Command { var opts copyOptions cmd := &cobra.Command{ @@ -72,7 +72,7 @@ func NewCopyCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runCopy(dockerCli *command.DockerCli, opts copyOptions) error { +func runCopy(dockerCli command.Cli, opts copyOptions) error { srcContainer, srcPath := splitCpArg(opts.source) dstContainer, dstPath := splitCpArg(opts.destination) @@ -104,7 +104,7 @@ func runCopy(dockerCli *command.DockerCli, opts copyOptions) error { } } -func statContainerPath(ctx context.Context, dockerCli *command.DockerCli, containerName, path string) (types.ContainerPathStat, error) { +func statContainerPath(ctx context.Context, dockerCli command.Cli, containerName, path string) (types.ContainerPathStat, error) { return dockerCli.Client().ContainerStatPath(ctx, containerName, path) } @@ -116,7 +116,7 @@ func resolveLocalPath(localPath string) (absPath string, err error) { return archive.PreserveTrailingDotOrSeparator(absPath, localPath, filepath.Separator), nil } -func copyFromContainer(ctx context.Context, dockerCli *command.DockerCli, srcContainer, srcPath, dstPath string, cpParam *cpConfig) (err error) { +func copyFromContainer(ctx context.Context, dockerCli command.Cli, srcContainer, srcPath, dstPath string, cpParam *cpConfig) (err error) { if dstPath != "-" { // Get an absolute destination path. dstPath, err = resolveLocalPath(dstPath) @@ -177,7 +177,7 @@ func copyFromContainer(ctx context.Context, dockerCli *command.DockerCli, srcCon return archive.CopyTo(preArchive, srcInfo, dstPath) } -func copyToContainer(ctx context.Context, dockerCli *command.DockerCli, srcPath, dstContainer, dstPath string, cpParam *cpConfig, copyUIDGID bool) (err error) { +func copyToContainer(ctx context.Context, dockerCli command.Cli, srcPath, dstContainer, dstPath string, cpParam *cpConfig, copyUIDGID bool) (err error) { if srcPath != "-" { // Get an absolute source path. srcPath, err = resolveLocalPath(srcPath) diff --git a/cli/command/container/diff.go b/cli/command/container/diff.go index 5f646aa962..04b4a8c431 100644 --- a/cli/command/container/diff.go +++ b/cli/command/container/diff.go @@ -14,7 +14,7 @@ type diffOptions struct { } // NewDiffCommand creates a new cobra.Command for `docker diff` -func NewDiffCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewDiffCommand(dockerCli command.Cli) *cobra.Command { var opts diffOptions return &cobra.Command{ @@ -28,7 +28,7 @@ func NewDiffCommand(dockerCli *command.DockerCli) *cobra.Command { } } -func runDiff(dockerCli *command.DockerCli, opts *diffOptions) error { +func runDiff(dockerCli command.Cli, opts *diffOptions) error { if opts.container == "" { return errors.New("Container name cannot be empty") } diff --git a/cli/command/container/export.go b/cli/command/container/export.go index 700f557624..dc2d586def 100644 --- a/cli/command/container/export.go +++ b/cli/command/container/export.go @@ -16,7 +16,7 @@ type exportOptions struct { } // NewExportCommand creates a new `docker export` command -func NewExportCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewExportCommand(dockerCli command.Cli) *cobra.Command { var opts exportOptions cmd := &cobra.Command{ @@ -36,7 +36,7 @@ func NewExportCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runExport(dockerCli *command.DockerCli, opts exportOptions) error { +func runExport(dockerCli command.Cli, opts exportOptions) error { if opts.output == "" && dockerCli.Out().IsTerminal() { return errors.New("cowardly refusing to save to a terminal. Use the -o flag or redirect") } diff --git a/cli/command/container/inspect.go b/cli/command/container/inspect.go index 7e0e71034f..feaf2d13d7 100644 --- a/cli/command/container/inspect.go +++ b/cli/command/container/inspect.go @@ -15,7 +15,7 @@ type inspectOptions struct { } // newInspectCommand creates a new cobra.Command for `docker container inspect` -func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { +func newInspectCommand(dockerCli command.Cli) *cobra.Command { var opts inspectOptions cmd := &cobra.Command{ @@ -35,7 +35,7 @@ func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { +func runInspect(dockerCli command.Cli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() diff --git a/cli/command/container/kill.go b/cli/command/container/kill.go index 650f9577ad..c4625b71b2 100644 --- a/cli/command/container/kill.go +++ b/cli/command/container/kill.go @@ -18,7 +18,7 @@ type killOptions struct { } // NewKillCommand creates a new cobra.Command for `docker kill` -func NewKillCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewKillCommand(dockerCli command.Cli) *cobra.Command { var opts killOptions cmd := &cobra.Command{ @@ -36,7 +36,7 @@ func NewKillCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runKill(dockerCli *command.DockerCli, opts *killOptions) error { +func runKill(dockerCli command.Cli, opts *killOptions) error { var errs []string ctx := context.Background() errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, container string) error { diff --git a/cli/command/container/list.go b/cli/command/container/list.go index ec1ad69e13..bb27c1687c 100644 --- a/cli/command/container/list.go +++ b/cli/command/container/list.go @@ -25,7 +25,7 @@ type psOptions struct { } // NewPsCommand creates a new cobra.Command for `docker ps` -func NewPsCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewPsCommand(dockerCli command.Cli) *cobra.Command { options := psOptions{filter: opts.NewFilterOpt()} cmd := &cobra.Command{ @@ -51,7 +51,7 @@ func NewPsCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func newListCommand(dockerCli *command.DockerCli) *cobra.Command { +func newListCommand(dockerCli command.Cli) *cobra.Command { cmd := *NewPsCommand(dockerCli) cmd.Aliases = []string{"ps", "list"} cmd.Use = "ls [OPTIONS]" @@ -109,7 +109,7 @@ func buildContainerListOptions(opts *psOptions) (*types.ContainerListOptions, er return options, nil } -func runPs(dockerCli *command.DockerCli, options *psOptions) error { +func runPs(dockerCli command.Cli, options *psOptions) error { ctx := context.Background() listOptions, err := buildContainerListOptions(options) diff --git a/cli/command/container/logs.go b/cli/command/container/logs.go index 209e749425..6bf849f212 100644 --- a/cli/command/container/logs.go +++ b/cli/command/container/logs.go @@ -22,7 +22,7 @@ type logsOptions struct { } // NewLogsCommand creates a new cobra.Command for `docker logs` -func NewLogsCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewLogsCommand(dockerCli command.Cli) *cobra.Command { var opts logsOptions cmd := &cobra.Command{ @@ -44,7 +44,7 @@ func NewLogsCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error { +func runLogs(dockerCli command.Cli, opts *logsOptions) error { ctx := context.Background() options := types.ContainerLogsOptions{ diff --git a/cli/command/container/pause.go b/cli/command/container/pause.go index 9dc404d78b..748901ac7d 100644 --- a/cli/command/container/pause.go +++ b/cli/command/container/pause.go @@ -16,7 +16,7 @@ type pauseOptions struct { } // NewPauseCommand creates a new cobra.Command for `docker pause` -func NewPauseCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewPauseCommand(dockerCli command.Cli) *cobra.Command { var opts pauseOptions return &cobra.Command{ @@ -30,7 +30,7 @@ func NewPauseCommand(dockerCli *command.DockerCli) *cobra.Command { } } -func runPause(dockerCli *command.DockerCli, opts *pauseOptions) error { +func runPause(dockerCli command.Cli, opts *pauseOptions) error { ctx := context.Background() var errs []string diff --git a/cli/command/container/port.go b/cli/command/container/port.go index 13a1ae4231..5aafd34977 100644 --- a/cli/command/container/port.go +++ b/cli/command/container/port.go @@ -19,7 +19,7 @@ type portOptions struct { } // NewPortCommand creates a new cobra.Command for `docker port` -func NewPortCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewPortCommand(dockerCli command.Cli) *cobra.Command { var opts portOptions cmd := &cobra.Command{ @@ -37,7 +37,7 @@ func NewPortCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runPort(dockerCli *command.DockerCli, opts *portOptions) error { +func runPort(dockerCli command.Cli, opts *portOptions) error { ctx := context.Background() c, err := dockerCli.Client().ContainerInspect(ctx, opts.container) diff --git a/cli/command/container/rename.go b/cli/command/container/rename.go index ad60bda3b2..b24c6f3fc3 100644 --- a/cli/command/container/rename.go +++ b/cli/command/container/rename.go @@ -17,7 +17,7 @@ type renameOptions struct { } // NewRenameCommand creates a new cobra.Command for `docker rename` -func NewRenameCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewRenameCommand(dockerCli command.Cli) *cobra.Command { var opts renameOptions cmd := &cobra.Command{ @@ -33,7 +33,7 @@ func NewRenameCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runRename(dockerCli *command.DockerCli, opts *renameOptions) error { +func runRename(dockerCli command.Cli, opts *renameOptions) error { ctx := context.Background() oldName := strings.TrimSpace(opts.oldName) diff --git a/cli/command/container/restart.go b/cli/command/container/restart.go index 6e13603667..a05e3b12dd 100644 --- a/cli/command/container/restart.go +++ b/cli/command/container/restart.go @@ -20,7 +20,7 @@ type restartOptions struct { } // NewRestartCommand creates a new cobra.Command for `docker restart` -func NewRestartCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewRestartCommand(dockerCli command.Cli) *cobra.Command { var opts restartOptions cmd := &cobra.Command{ @@ -39,7 +39,7 @@ func NewRestartCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runRestart(dockerCli *command.DockerCli, opts *restartOptions) error { +func runRestart(dockerCli command.Cli, opts *restartOptions) error { ctx := context.Background() var errs []string var timeout *time.Duration diff --git a/cli/command/container/rm.go b/cli/command/container/rm.go index a7106acce1..16db5501e0 100644 --- a/cli/command/container/rm.go +++ b/cli/command/container/rm.go @@ -21,7 +21,7 @@ type rmOptions struct { } // NewRmCommand creates a new cobra.Command for `docker rm` -func NewRmCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewRmCommand(dockerCli command.Cli) *cobra.Command { var opts rmOptions cmd := &cobra.Command{ @@ -41,7 +41,7 @@ func NewRmCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runRm(dockerCli *command.DockerCli, opts *rmOptions) error { +func runRm(dockerCli command.Cli, opts *rmOptions) error { ctx := context.Background() var errs []string diff --git a/cli/command/container/run.go b/cli/command/container/run.go index a8aeae5350..5b3426b7a0 100644 --- a/cli/command/container/run.go +++ b/cli/command/container/run.go @@ -32,7 +32,7 @@ type runOptions struct { } // NewRunCommand create a new `docker run` command -func NewRunCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewRunCommand(dockerCli command.Cli) *cobra.Command { var opts runOptions var copts *containerOptions @@ -96,7 +96,7 @@ func isLocalhost(ip string) bool { return localhostIPRegexp.MatchString(ip) } -func runRun(dockerCli *command.DockerCli, flags *pflag.FlagSet, ropts *runOptions, copts *containerOptions) error { +func runRun(dockerCli command.Cli, flags *pflag.FlagSet, ropts *runOptions, copts *containerOptions) error { proxyConfig := dockerCli.ConfigFile().ParseProxyConfig(dockerCli.Client().DaemonHost(), copts.env.GetAll()) newEnv := []string{} for k, v := range proxyConfig { @@ -117,7 +117,7 @@ func runRun(dockerCli *command.DockerCli, flags *pflag.FlagSet, ropts *runOption } // nolint: gocyclo -func runContainer(dockerCli *command.DockerCli, opts *runOptions, copts *containerOptions, containerConfig *containerConfig) error { +func runContainer(dockerCli command.Cli, opts *runOptions, copts *containerOptions, containerConfig *containerConfig) error { config := containerConfig.Config hostConfig := containerConfig.HostConfig stdout, stderr := dockerCli.Out(), dockerCli.Err() diff --git a/cli/command/container/start.go b/cli/command/container/start.go index 0717fb4a3b..67b3bd509c 100644 --- a/cli/command/container/start.go +++ b/cli/command/container/start.go @@ -27,7 +27,7 @@ type startOptions struct { } // NewStartCommand creates a new cobra.Command for `docker start` -func NewStartCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewStartCommand(dockerCli command.Cli) *cobra.Command { var opts startOptions cmd := &cobra.Command{ @@ -53,7 +53,7 @@ func NewStartCommand(dockerCli *command.DockerCli) *cobra.Command { } // nolint: gocyclo -func runStart(dockerCli *command.DockerCli, opts *startOptions) error { +func runStart(dockerCli command.Cli, opts *startOptions) error { ctx, cancelFun := context.WithCancel(context.Background()) if opts.attach || opts.openStdin { @@ -181,7 +181,7 @@ func runStart(dockerCli *command.DockerCli, opts *startOptions) error { return nil } -func startContainersWithoutAttachments(ctx context.Context, dockerCli *command.DockerCli, containers []string) error { +func startContainersWithoutAttachments(ctx context.Context, dockerCli command.Cli, containers []string) error { var failedContainers []string for _, container := range containers { if err := dockerCli.Client().ContainerStart(ctx, container, types.ContainerStartOptions{}); err != nil { diff --git a/cli/command/container/stats.go b/cli/command/container/stats.go index be4adc05c8..d57e15de72 100644 --- a/cli/command/container/stats.go +++ b/cli/command/container/stats.go @@ -27,7 +27,7 @@ type statsOptions struct { } // NewStatsCommand creates a new cobra.Command for `docker stats` -func NewStatsCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewStatsCommand(dockerCli command.Cli) *cobra.Command { var opts statsOptions cmd := &cobra.Command{ @@ -51,7 +51,7 @@ func NewStatsCommand(dockerCli *command.DockerCli) *cobra.Command { // runStats displays a live stream of resource usage statistics for one or more containers. // This shows real-time information on CPU usage, memory usage, and network I/O. // nolint: gocyclo -func runStats(dockerCli *command.DockerCli, opts *statsOptions) error { +func runStats(dockerCli command.Cli, opts *statsOptions) error { showAll := len(opts.containers) == 0 closeChan := make(chan error) diff --git a/cli/command/container/stop.go b/cli/command/container/stop.go index 59d6d0b703..10ffabf07c 100644 --- a/cli/command/container/stop.go +++ b/cli/command/container/stop.go @@ -20,7 +20,7 @@ type stopOptions struct { } // NewStopCommand creates a new cobra.Command for `docker stop` -func NewStopCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewStopCommand(dockerCli command.Cli) *cobra.Command { var opts stopOptions cmd := &cobra.Command{ @@ -39,7 +39,7 @@ func NewStopCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runStop(dockerCli *command.DockerCli, opts *stopOptions) error { +func runStop(dockerCli command.Cli, opts *stopOptions) error { ctx := context.Background() var timeout *time.Duration diff --git a/cli/command/container/top.go b/cli/command/container/top.go index 428ee27ffb..86155da7eb 100644 --- a/cli/command/container/top.go +++ b/cli/command/container/top.go @@ -18,7 +18,7 @@ type topOptions struct { } // NewTopCommand creates a new cobra.Command for `docker top` -func NewTopCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewTopCommand(dockerCli command.Cli) *cobra.Command { var opts topOptions cmd := &cobra.Command{ @@ -38,7 +38,7 @@ func NewTopCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runTop(dockerCli *command.DockerCli, opts *topOptions) error { +func runTop(dockerCli command.Cli, opts *topOptions) error { ctx := context.Background() procList, err := dockerCli.Client().ContainerTop(ctx, opts.container, opts.args) diff --git a/cli/command/container/unpause.go b/cli/command/container/unpause.go index b6d5e231b8..daaa0b707d 100644 --- a/cli/command/container/unpause.go +++ b/cli/command/container/unpause.go @@ -16,7 +16,7 @@ type unpauseOptions struct { } // NewUnpauseCommand creates a new cobra.Command for `docker unpause` -func NewUnpauseCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewUnpauseCommand(dockerCli command.Cli) *cobra.Command { var opts unpauseOptions cmd := &cobra.Command{ @@ -31,7 +31,7 @@ func NewUnpauseCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runUnpause(dockerCli *command.DockerCli, opts *unpauseOptions) error { +func runUnpause(dockerCli command.Cli, opts *unpauseOptions) error { ctx := context.Background() var errs []string diff --git a/cli/command/container/update.go b/cli/command/container/update.go index 9cb74aeb76..b91d77dcbc 100644 --- a/cli/command/container/update.go +++ b/cli/command/container/update.go @@ -35,7 +35,7 @@ type updateOptions struct { } // NewUpdateCommand creates a new cobra.Command for `docker update` -func NewUpdateCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewUpdateCommand(dockerCli command.Cli) *cobra.Command { var options updateOptions cmd := &cobra.Command{ @@ -72,7 +72,7 @@ func NewUpdateCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runUpdate(dockerCli *command.DockerCli, options *updateOptions) error { +func runUpdate(dockerCli command.Cli, options *updateOptions) error { var err error if options.nFlag == 0 { diff --git a/cli/command/container/utils.go b/cli/command/container/utils.go index 024e6ed6d2..3652d672d9 100644 --- a/cli/command/container/utils.go +++ b/cli/command/container/utils.go @@ -13,7 +13,7 @@ import ( "golang.org/x/net/context" ) -func waitExitOrRemoved(ctx context.Context, dockerCli *command.DockerCli, containerID string, waitRemove bool) <-chan int { +func waitExitOrRemoved(ctx context.Context, dockerCli command.Cli, containerID string, waitRemove bool) <-chan int { if len(containerID) == 0 { // containerID can never be empty panic("Internal Error: waitExitOrRemoved needs a containerID as parameter") @@ -47,7 +47,7 @@ func waitExitOrRemoved(ctx context.Context, dockerCli *command.DockerCli, contai return statusC } -func legacyWaitExitOrRemoved(ctx context.Context, dockerCli *command.DockerCli, containerID string, waitRemove bool) <-chan int { +func legacyWaitExitOrRemoved(ctx context.Context, dockerCli command.Cli, containerID string, waitRemove bool) <-chan int { var removeErr error statusChan := make(chan int) exitCode := 125 diff --git a/cli/command/container/wait.go b/cli/command/container/wait.go index f582469c3e..18c7a2523c 100644 --- a/cli/command/container/wait.go +++ b/cli/command/container/wait.go @@ -16,7 +16,7 @@ type waitOptions struct { } // NewWaitCommand creates a new cobra.Command for `docker wait` -func NewWaitCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewWaitCommand(dockerCli command.Cli) *cobra.Command { var opts waitOptions cmd := &cobra.Command{ @@ -32,7 +32,7 @@ func NewWaitCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runWait(dockerCli *command.DockerCli, opts *waitOptions) error { +func runWait(dockerCli command.Cli, opts *waitOptions) error { ctx := context.Background() var errs []string diff --git a/cli/command/plugin/cmd.go b/cli/command/plugin/cmd.go index c30f97fd1d..2e79ab1d49 100644 --- a/cli/command/plugin/cmd.go +++ b/cli/command/plugin/cmd.go @@ -7,8 +7,7 @@ import ( ) // NewPluginCommand returns a cobra command for `plugin` subcommands -// nolint: interfacer -func NewPluginCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewPluginCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "plugin", Short: "Manage plugins", diff --git a/cli/command/plugin/create.go b/cli/command/plugin/create.go index 56baa4ebe9..fd22feef20 100644 --- a/cli/command/plugin/create.go +++ b/cli/command/plugin/create.go @@ -63,7 +63,7 @@ type pluginCreateOptions struct { compress bool } -func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command { +func newCreateCommand(dockerCli command.Cli) *cobra.Command { options := pluginCreateOptions{} cmd := &cobra.Command{ @@ -84,7 +84,7 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runCreate(dockerCli *command.DockerCli, options pluginCreateOptions) error { +func runCreate(dockerCli command.Cli, options pluginCreateOptions) error { var ( createCtx io.ReadCloser err error diff --git a/cli/command/plugin/disable.go b/cli/command/plugin/disable.go index 1ab33ccf82..b3f255e787 100644 --- a/cli/command/plugin/disable.go +++ b/cli/command/plugin/disable.go @@ -10,7 +10,7 @@ import ( "golang.org/x/net/context" ) -func newDisableCommand(dockerCli *command.DockerCli) *cobra.Command { +func newDisableCommand(dockerCli command.Cli) *cobra.Command { var force bool cmd := &cobra.Command{ @@ -27,7 +27,7 @@ func newDisableCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runDisable(dockerCli *command.DockerCli, name string, force bool) error { +func runDisable(dockerCli command.Cli, name string, force bool) error { if err := dockerCli.Client().PluginDisable(context.Background(), name, types.PluginDisableOptions{Force: force}); err != nil { return err } diff --git a/cli/command/plugin/enable.go b/cli/command/plugin/enable.go index 53a7acd0c2..33567643bf 100644 --- a/cli/command/plugin/enable.go +++ b/cli/command/plugin/enable.go @@ -16,7 +16,7 @@ type enableOpts struct { name string } -func newEnableCommand(dockerCli *command.DockerCli) *cobra.Command { +func newEnableCommand(dockerCli command.Cli) *cobra.Command { var opts enableOpts cmd := &cobra.Command{ @@ -34,7 +34,7 @@ func newEnableCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runEnable(dockerCli *command.DockerCli, opts *enableOpts) error { +func runEnable(dockerCli command.Cli, opts *enableOpts) error { name := opts.name if opts.timeout < 0 { return errors.Errorf("negative timeout %d is invalid", opts.timeout) diff --git a/cli/command/plugin/inspect.go b/cli/command/plugin/inspect.go index 00ae300d57..66736ea873 100644 --- a/cli/command/plugin/inspect.go +++ b/cli/command/plugin/inspect.go @@ -13,7 +13,7 @@ type inspectOptions struct { format string } -func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { +func newInspectCommand(dockerCli command.Cli) *cobra.Command { var opts inspectOptions cmd := &cobra.Command{ @@ -31,7 +31,7 @@ func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { +func runInspect(dockerCli command.Cli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() getRef := func(ref string) (interface{}, []byte, error) { diff --git a/cli/command/plugin/install.go b/cli/command/plugin/install.go index c4c978b31f..f7537670eb 100644 --- a/cli/command/plugin/install.go +++ b/cli/command/plugin/install.go @@ -31,7 +31,7 @@ func loadPullFlags(opts *pluginOptions, flags *pflag.FlagSet) { command.AddTrustVerificationFlags(flags) } -func newInstallCommand(dockerCli *command.DockerCli) *cobra.Command { +func newInstallCommand(dockerCli command.Cli) *cobra.Command { var options pluginOptions cmd := &cobra.Command{ Use: "install [OPTIONS] PLUGIN [KEY=VALUE...]", @@ -73,7 +73,7 @@ func newRegistryService() (registry.Service, error) { return pluginRegistryService{Service: svc}, nil } -func buildPullConfig(ctx context.Context, dockerCli *command.DockerCli, opts pluginOptions, cmdName string) (types.PluginInstallOptions, error) { +func buildPullConfig(ctx context.Context, dockerCli command.Cli, opts pluginOptions, cmdName string) (types.PluginInstallOptions, error) { // Names with both tag and digest will be treated by the daemon // as a pull by digest with a local name for the tag // (if no local name is provided). @@ -130,7 +130,7 @@ func buildPullConfig(ctx context.Context, dockerCli *command.DockerCli, opts plu return options, nil } -func runInstall(dockerCli *command.DockerCli, opts pluginOptions) error { +func runInstall(dockerCli command.Cli, opts pluginOptions) error { var localName string if opts.localName != "" { aref, err := reference.ParseNormalizedNamed(opts.localName) @@ -163,7 +163,7 @@ func runInstall(dockerCli *command.DockerCli, opts pluginOptions) error { return nil } -func acceptPrivileges(dockerCli *command.DockerCli, name string) func(privileges types.PluginPrivileges) (bool, error) { +func acceptPrivileges(dockerCli command.Cli, name string) func(privileges types.PluginPrivileges) (bool, error) { return func(privileges types.PluginPrivileges) (bool, error) { fmt.Fprintf(dockerCli.Out(), "Plugin %q is requesting the following privileges:\n", name) for _, privilege := range privileges { diff --git a/cli/command/plugin/list.go b/cli/command/plugin/list.go index c4bbeb5b46..3ec6acf272 100644 --- a/cli/command/plugin/list.go +++ b/cli/command/plugin/list.go @@ -16,7 +16,7 @@ type listOptions struct { filter opts.FilterOpt } -func newListCommand(dockerCli *command.DockerCli) *cobra.Command { +func newListCommand(dockerCli command.Cli) *cobra.Command { options := listOptions{filter: opts.NewFilterOpt()} cmd := &cobra.Command{ @@ -39,7 +39,7 @@ func newListCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runList(dockerCli *command.DockerCli, options listOptions) error { +func runList(dockerCli command.Cli, options listOptions) error { plugins, err := dockerCli.Client().PluginList(context.Background(), options.filter.Value()) if err != nil { return err diff --git a/cli/command/plugin/remove.go b/cli/command/plugin/remove.go index 32211147e7..3513004211 100644 --- a/cli/command/plugin/remove.go +++ b/cli/command/plugin/remove.go @@ -16,7 +16,7 @@ type rmOptions struct { plugins []string } -func newRemoveCommand(dockerCli *command.DockerCli) *cobra.Command { +func newRemoveCommand(dockerCli command.Cli) *cobra.Command { var opts rmOptions cmd := &cobra.Command{ @@ -35,7 +35,7 @@ func newRemoveCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runRemove(dockerCli *command.DockerCli, opts *rmOptions) error { +func runRemove(dockerCli command.Cli, opts *rmOptions) error { ctx := context.Background() var errs cli.Errors diff --git a/cli/command/plugin/set.go b/cli/command/plugin/set.go index 7a69995cdb..79c5feb66f 100644 --- a/cli/command/plugin/set.go +++ b/cli/command/plugin/set.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" ) -func newSetCommand(dockerCli *command.DockerCli) *cobra.Command { +func newSetCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "set PLUGIN KEY=VALUE [KEY=VALUE...]", Short: "Change settings for a plugin", diff --git a/cli/command/plugin/upgrade.go b/cli/command/plugin/upgrade.go index f71306c70e..f1a67edc40 100644 --- a/cli/command/plugin/upgrade.go +++ b/cli/command/plugin/upgrade.go @@ -13,7 +13,7 @@ import ( "github.com/spf13/cobra" ) -func newUpgradeCommand(dockerCli *command.DockerCli) *cobra.Command { +func newUpgradeCommand(dockerCli command.Cli) *cobra.Command { var options pluginOptions cmd := &cobra.Command{ Use: "upgrade [OPTIONS] PLUGIN [REMOTE]", @@ -35,7 +35,7 @@ func newUpgradeCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runUpgrade(dockerCli *command.DockerCli, opts pluginOptions) error { +func runUpgrade(dockerCli command.Cli, opts pluginOptions) error { ctx := context.Background() p, _, err := dockerCli.Client().PluginInspectWithRaw(ctx, opts.localName) if err != nil { diff --git a/cli/command/secret/cmd.go b/cli/command/secret/cmd.go index 55ab054d1b..f50f9818c3 100644 --- a/cli/command/secret/cmd.go +++ b/cli/command/secret/cmd.go @@ -8,8 +8,7 @@ import ( ) // NewSecretCommand returns a cobra command for `secret` subcommands -// nolint: interfacer -func NewSecretCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewSecretCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "secret", Short: "Manage Docker secrets", diff --git a/cli/command/service/cmd.go b/cli/command/service/cmd.go index 0f69f28cdc..1c33440591 100644 --- a/cli/command/service/cmd.go +++ b/cli/command/service/cmd.go @@ -8,8 +8,7 @@ import ( ) // NewServiceCommand returns a cobra command for `service` subcommands -// nolint: interfacer -func NewServiceCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewServiceCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "service", Short: "Manage services", diff --git a/cli/command/service/logs.go b/cli/command/service/logs.go index e619d74e16..13f150b750 100644 --- a/cli/command/service/logs.go +++ b/cli/command/service/logs.go @@ -37,7 +37,7 @@ type logsOptions struct { target string } -func newLogsCommand(dockerCli *command.DockerCli) *cobra.Command { +func newLogsCommand(dockerCli command.Cli) *cobra.Command { var opts logsOptions cmd := &cobra.Command{ @@ -68,7 +68,7 @@ func newLogsCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error { +func runLogs(dockerCli command.Cli, opts *logsOptions) error { ctx := context.Background() options := types.ContainerLogsOptions{ diff --git a/cli/command/service/opts.go b/cli/command/service/opts.go index 37369f595b..24f9da3776 100644 --- a/cli/command/service/opts.go +++ b/cli/command/service/opts.go @@ -354,7 +354,7 @@ func convertNetworks(ctx context.Context, apiClient client.NetworkAPIClient, net if err != nil { return nil, err } - netAttach = append(netAttach, swarm.NetworkAttachmentConfig{ // nolint: gosimple + netAttach = append(netAttach, swarm.NetworkAttachmentConfig{ Target: net.Target, Aliases: net.Aliases, DriverOpts: net.DriverOpts, diff --git a/cli/command/stack/cmd.go b/cli/command/stack/cmd.go index 37d99a902a..736f997101 100644 --- a/cli/command/stack/cmd.go +++ b/cli/command/stack/cmd.go @@ -7,8 +7,7 @@ import ( ) // NewStackCommand returns a cobra command for `stack` subcommands -// nolint: interfacer -func NewStackCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewStackCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "stack", Short: "Manage Docker stacks", diff --git a/cli/command/swarm/cmd.go b/cli/command/swarm/cmd.go index bea8190a2c..425b83939e 100644 --- a/cli/command/swarm/cmd.go +++ b/cli/command/swarm/cmd.go @@ -8,7 +8,6 @@ import ( ) // NewSwarmCommand returns a cobra command for `swarm` subcommands -// nolint: interfacer func NewSwarmCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "swarm", diff --git a/cli/command/system/cmd.go b/cli/command/system/cmd.go index 60979e7224..7b9d6819c3 100644 --- a/cli/command/system/cmd.go +++ b/cli/command/system/cmd.go @@ -7,8 +7,7 @@ import ( ) // NewSystemCommand returns a cobra command for `system` subcommands -// nolint: interfacer -func NewSystemCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewSystemCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "system", Short: "Manage Docker", diff --git a/cli/command/system/df.go b/cli/command/system/df.go index 0677801bc3..5dde8e4c12 100644 --- a/cli/command/system/df.go +++ b/cli/command/system/df.go @@ -16,7 +16,7 @@ type diskUsageOptions struct { } // newDiskUsageCommand creates a new cobra.Command for `docker df` -func newDiskUsageCommand(dockerCli *command.DockerCli) *cobra.Command { +func newDiskUsageCommand(dockerCli command.Cli) *cobra.Command { var opts diskUsageOptions cmd := &cobra.Command{ @@ -37,7 +37,7 @@ func newDiskUsageCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runDiskUsage(dockerCli *command.DockerCli, opts diskUsageOptions) error { +func runDiskUsage(dockerCli command.Cli, opts diskUsageOptions) error { if opts.verbose && len(opts.format) != 0 { return errors.New("the verbose and the format options conflict") } diff --git a/cli/command/system/events.go b/cli/command/system/events.go index 6eac8f3434..8977e56372 100644 --- a/cli/command/system/events.go +++ b/cli/command/system/events.go @@ -27,7 +27,7 @@ type eventsOptions struct { } // NewEventsCommand creates a new cobra.Command for `docker events` -func NewEventsCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewEventsCommand(dockerCli command.Cli) *cobra.Command { options := eventsOptions{filter: opts.NewFilterOpt()} cmd := &cobra.Command{ @@ -48,7 +48,7 @@ func NewEventsCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runEvents(dockerCli *command.DockerCli, options *eventsOptions) error { +func runEvents(dockerCli command.Cli, options *eventsOptions) error { tmpl, err := makeTemplate(options.format) if err != nil { return cli.StatusError{ diff --git a/cli/command/system/info.go b/cli/command/system/info.go index 9d366466a6..022bd881a0 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -22,7 +22,7 @@ type infoOptions struct { } // NewInfoCommand creates a new cobra.Command for `docker info` -func NewInfoCommand(dockerCli *command.DockerCli) *cobra.Command { +func NewInfoCommand(dockerCli command.Cli) *cobra.Command { var opts infoOptions cmd := &cobra.Command{ @@ -41,7 +41,7 @@ func NewInfoCommand(dockerCli *command.DockerCli) *cobra.Command { return cmd } -func runInfo(dockerCli *command.DockerCli, opts *infoOptions) error { +func runInfo(dockerCli command.Cli, opts *infoOptions) error { ctx := context.Background() info, err := dockerCli.Client().Info(ctx) if err != nil { @@ -357,7 +357,7 @@ func getBackingFs(info types.Info) string { return "" } -func formatInfo(dockerCli *command.DockerCli, info types.Info, format string) error { +func formatInfo(dockerCli command.Cli, info types.Info, format string) error { tmpl, err := templates.Parse(format) if err != nil { return cli.StatusError{StatusCode: 64, diff --git a/dockerfiles/Dockerfile.lint b/dockerfiles/Dockerfile.lint index 75ca90c494..49940f2819 100644 --- a/dockerfiles/Dockerfile.lint +++ b/dockerfiles/Dockerfile.lint @@ -2,7 +2,7 @@ FROM golang:1.8.4-alpine RUN apk add -U git -ARG GOMETALINTER_SHA=8eca55135021737bbc65ed68b548b3336853274c +ARG GOMETALINTER_SHA=7f9672e7ea538b8682e83395d50b12f09bb17b91 RUN go get -d github.com/alecthomas/gometalinter && \ cd /go/src/github.com/alecthomas/gometalinter && \ git checkout -q "$GOMETALINTER_SHA" && \ diff --git a/gometalinter.json b/gometalinter.json index 79fa8d01b6..3daa216901 100644 --- a/gometalinter.json +++ b/gometalinter.json @@ -13,6 +13,7 @@ "Pattern": "^(?P.*?\\.go):(?P\\d+)\\s*(?P.*)$" } }, + "WarnUnmatchedDirective": true, "DisableAll": true, "Enable": [