diff --git a/api/client/client.go b/api/client/client.go deleted file mode 100644 index 4cfce5f684..0000000000 --- a/api/client/client.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package client provides a command-line interface for Docker. -// -// Run "docker help SUBCOMMAND" or "docker SUBCOMMAND --help" to see more information on any Docker subcommand, including the full list of options supported for the subcommand. -// See https://docs.docker.com/installation/ for instructions on installing Docker. -package client diff --git a/api/client/bundlefile/bundlefile.go b/cli/command/bundlefile/bundlefile.go similarity index 100% rename from api/client/bundlefile/bundlefile.go rename to cli/command/bundlefile/bundlefile.go diff --git a/api/client/bundlefile/bundlefile_test.go b/cli/command/bundlefile/bundlefile_test.go similarity index 100% rename from api/client/bundlefile/bundlefile_test.go rename to cli/command/bundlefile/bundlefile_test.go diff --git a/api/client/cli.go b/cli/command/cli.go similarity index 99% rename from api/client/cli.go rename to cli/command/cli.go index e25ea95d6f..6194c7fe93 100644 --- a/api/client/cli.go +++ b/cli/command/cli.go @@ -1,4 +1,4 @@ -package client +package command import ( "errors" diff --git a/api/client/command/commands.go b/cli/command/commands/commands.go similarity index 75% rename from api/client/command/commands.go rename to cli/command/commands/commands.go index 4cd4a98467..3eb1828d57 100644 --- a/api/client/command/commands.go +++ b/cli/command/commands/commands.go @@ -1,23 +1,23 @@ -package command +package commands import ( - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/container" - "github.com/docker/docker/api/client/image" - "github.com/docker/docker/api/client/network" - "github.com/docker/docker/api/client/node" - "github.com/docker/docker/api/client/plugin" - "github.com/docker/docker/api/client/registry" - "github.com/docker/docker/api/client/service" - "github.com/docker/docker/api/client/stack" - "github.com/docker/docker/api/client/swarm" - "github.com/docker/docker/api/client/system" - "github.com/docker/docker/api/client/volume" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/container" + "github.com/docker/docker/cli/command/image" + "github.com/docker/docker/cli/command/network" + "github.com/docker/docker/cli/command/node" + "github.com/docker/docker/cli/command/plugin" + "github.com/docker/docker/cli/command/registry" + "github.com/docker/docker/cli/command/service" + "github.com/docker/docker/cli/command/stack" + "github.com/docker/docker/cli/command/swarm" + "github.com/docker/docker/cli/command/system" + "github.com/docker/docker/cli/command/volume" "github.com/spf13/cobra" ) // AddCommands adds all the commands from api/client to the root command -func AddCommands(cmd *cobra.Command, dockerCli *client.DockerCli) { +func AddCommands(cmd *cobra.Command, dockerCli *command.DockerCli) { cmd.AddCommand( node.NewNodeCommand(dockerCli), service.NewServiceCommand(dockerCli), diff --git a/api/client/container/attach.go b/cli/command/container/attach.go similarity index 95% rename from api/client/container/attach.go rename to cli/command/container/attach.go index b0be3df90a..a1fe58dea7 100644 --- a/api/client/container/attach.go +++ b/cli/command/container/attach.go @@ -8,9 +8,9 @@ import ( "golang.org/x/net/context" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/signal" "github.com/spf13/cobra" ) @@ -24,7 +24,7 @@ type attachOptions struct { } // NewAttachCommand creates a new cobra.Command for `docker attach` -func NewAttachCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewAttachCommand(dockerCli *command.DockerCli) *cobra.Command { var opts attachOptions cmd := &cobra.Command{ @@ -44,7 +44,7 @@ func NewAttachCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runAttach(dockerCli *client.DockerCli, opts *attachOptions) error { +func runAttach(dockerCli *command.DockerCli, opts *attachOptions) error { ctx := context.Background() client := dockerCli.Client() diff --git a/api/client/container/commit.go b/cli/command/container/commit.go similarity index 90% rename from api/client/container/commit.go rename to cli/command/container/commit.go index 1fad18cac9..cf8d0102a6 100644 --- a/api/client/container/commit.go +++ b/cli/command/container/commit.go @@ -5,9 +5,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" dockeropts "github.com/docker/docker/opts" "github.com/spf13/cobra" ) @@ -23,7 +23,7 @@ type commitOptions struct { } // NewCommitCommand creates a new cobra.Command for `docker commit` -func NewCommitCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewCommitCommand(dockerCli *command.DockerCli) *cobra.Command { var opts commitOptions cmd := &cobra.Command{ @@ -52,7 +52,7 @@ func NewCommitCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runCommit(dockerCli *client.DockerCli, opts *commitOptions) error { +func runCommit(dockerCli *command.DockerCli, opts *commitOptions) error { ctx := context.Background() name := opts.container diff --git a/api/client/container/cp.go b/cli/command/container/cp.go similarity index 93% rename from api/client/container/cp.go rename to cli/command/container/cp.go index 653b828f16..17ab2accf9 100644 --- a/api/client/container/cp.go +++ b/cli/command/container/cp.go @@ -9,9 +9,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/system" "github.com/spf13/cobra" @@ -36,7 +36,7 @@ type cpConfig struct { } // NewCopyCommand creates a new `docker cp` command -func NewCopyCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewCopyCommand(dockerCli *command.DockerCli) *cobra.Command { var opts copyOptions cmd := &cobra.Command{ @@ -71,7 +71,7 @@ func NewCopyCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runCopy(dockerCli *client.DockerCli, opts copyOptions) error { +func runCopy(dockerCli *command.DockerCli, opts copyOptions) error { srcContainer, srcPath := splitCpArg(opts.source) dstContainer, dstPath := splitCpArg(opts.destination) @@ -103,7 +103,7 @@ func runCopy(dockerCli *client.DockerCli, opts copyOptions) error { } } -func statContainerPath(ctx context.Context, dockerCli *client.DockerCli, containerName, path string) (types.ContainerPathStat, error) { +func statContainerPath(ctx context.Context, dockerCli *command.DockerCli, containerName, path string) (types.ContainerPathStat, error) { return dockerCli.Client().ContainerStatPath(ctx, containerName, path) } @@ -115,7 +115,7 @@ func resolveLocalPath(localPath string) (absPath string, err error) { return archive.PreserveTrailingDotOrSeparator(absPath, localPath), nil } -func copyFromContainer(ctx context.Context, dockerCli *client.DockerCli, srcContainer, srcPath, dstPath string, cpParam *cpConfig) (err error) { +func copyFromContainer(ctx context.Context, dockerCli *command.DockerCli, srcContainer, srcPath, dstPath string, cpParam *cpConfig) (err error) { if dstPath != "-" { // Get an absolute destination path. dstPath, err = resolveLocalPath(dstPath) @@ -176,7 +176,7 @@ func copyFromContainer(ctx context.Context, dockerCli *client.DockerCli, srcCont return archive.CopyTo(preArchive, srcInfo, dstPath) } -func copyToContainer(ctx context.Context, dockerCli *client.DockerCli, srcPath, dstContainer, dstPath string, cpParam *cpConfig) (err error) { +func copyToContainer(ctx context.Context, dockerCli *command.DockerCli, srcPath, dstContainer, dstPath string, cpParam *cpConfig) (err error) { if srcPath != "-" { // Get an absolute source path. srcPath, err = resolveLocalPath(srcPath) diff --git a/api/client/container/create.go b/cli/command/container/create.go similarity index 87% rename from api/client/container/create.go rename to cli/command/container/create.go index d9eca183d1..95e8d95ed9 100644 --- a/api/client/container/create.go +++ b/cli/command/container/create.go @@ -7,8 +7,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/jsonmessage" // FIXME migrate to docker/distribution/reference "github.com/docker/docker/api/types" @@ -27,7 +27,7 @@ type createOptions struct { } // NewCreateCommand creates a new cobra.Command for `docker create` -func NewCreateCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewCreateCommand(dockerCli *command.DockerCli) *cobra.Command { var opts createOptions var copts *runconfigopts.ContainerOptions @@ -53,12 +53,12 @@ func NewCreateCommand(dockerCli *client.DockerCli) *cobra.Command { // with hostname flags.Bool("help", false, "Print usage") - client.AddTrustedFlags(flags, true) + command.AddTrustedFlags(flags, true) copts = runconfigopts.AddFlags(flags) return cmd } -func runCreate(dockerCli *client.DockerCli, flags *pflag.FlagSet, opts *createOptions, copts *runconfigopts.ContainerOptions) error { +func runCreate(dockerCli *command.DockerCli, flags *pflag.FlagSet, opts *createOptions, copts *runconfigopts.ContainerOptions) error { config, hostConfig, networkingConfig, err := runconfigopts.Parse(flags, copts) if err != nil { reportError(dockerCli.Err(), "create", err.Error(), true) @@ -72,7 +72,7 @@ func runCreate(dockerCli *client.DockerCli, flags *pflag.FlagSet, opts *createOp return nil } -func pullImage(ctx context.Context, dockerCli *client.DockerCli, image string, out io.Writer) error { +func pullImage(ctx context.Context, dockerCli *command.DockerCli, image string, out io.Writer) error { ref, err := reference.ParseNamed(image) if err != nil { return err @@ -85,7 +85,7 @@ func pullImage(ctx context.Context, dockerCli *client.DockerCli, image string, o } authConfig := dockerCli.ResolveAuthConfig(ctx, repoInfo.Index) - encodedAuth, err := client.EncodeAuthToBase64(authConfig) + encodedAuth, err := command.EncodeAuthToBase64(authConfig) if err != nil { return err } @@ -147,7 +147,7 @@ func newCIDFile(path string) (*cidFile, error) { return &cidFile{path: path, file: f}, nil } -func createContainer(ctx context.Context, dockerCli *client.DockerCli, config *container.Config, hostConfig *container.HostConfig, networkingConfig *networktypes.NetworkingConfig, cidfile, name string) (*types.ContainerCreateResponse, error) { +func createContainer(ctx context.Context, dockerCli *command.DockerCli, config *container.Config, hostConfig *container.HostConfig, networkingConfig *networktypes.NetworkingConfig, cidfile, name string) (*types.ContainerCreateResponse, error) { stderr := dockerCli.Err() var containerIDFile *cidFile @@ -167,7 +167,7 @@ func createContainer(ctx context.Context, dockerCli *client.DockerCli, config *c if ref != nil { ref = reference.WithDefaultTag(ref) - if ref, ok := ref.(reference.NamedTagged); ok && client.IsTrusted() { + if ref, ok := ref.(reference.NamedTagged); ok && command.IsTrusted() { var err error trustedRef, err = dockerCli.TrustedReference(ctx, ref) if err != nil { diff --git a/api/client/container/diff.go b/cli/command/container/diff.go similarity index 85% rename from api/client/container/diff.go rename to cli/command/container/diff.go index 88b2e4e1cd..12d6591014 100644 --- a/api/client/container/diff.go +++ b/cli/command/container/diff.go @@ -5,8 +5,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/archive" "github.com/spf13/cobra" ) @@ -16,7 +16,7 @@ type diffOptions struct { } // NewDiffCommand creates a new cobra.Command for `docker diff` -func NewDiffCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewDiffCommand(dockerCli *command.DockerCli) *cobra.Command { var opts diffOptions return &cobra.Command{ @@ -30,7 +30,7 @@ func NewDiffCommand(dockerCli *client.DockerCli) *cobra.Command { } } -func runDiff(dockerCli *client.DockerCli, opts *diffOptions) error { +func runDiff(dockerCli *command.DockerCli, opts *diffOptions) error { if opts.container == "" { return fmt.Errorf("Container name cannot be empty") } diff --git a/api/client/container/exec.go b/cli/command/container/exec.go similarity index 95% rename from api/client/container/exec.go rename to cli/command/container/exec.go index 2913e63723..1682a7ca64 100644 --- a/api/client/container/exec.go +++ b/cli/command/container/exec.go @@ -7,9 +7,9 @@ import ( "golang.org/x/net/context" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" apiclient "github.com/docker/docker/client" "github.com/docker/docker/pkg/promise" "github.com/spf13/cobra" @@ -25,7 +25,7 @@ type execOptions struct { } // NewExecCommand creats a new cobra.Command for `docker exec` -func NewExecCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewExecCommand(dockerCli *command.DockerCli) *cobra.Command { var opts execOptions cmd := &cobra.Command{ @@ -52,7 +52,7 @@ func NewExecCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runExec(dockerCli *client.DockerCli, opts *execOptions, container string, execCmd []string) error { +func runExec(dockerCli *command.DockerCli, opts *execOptions, container string, execCmd []string) error { execConfig, err := parseExec(opts, container, execCmd) // just in case the ParseExec does not exit if container == "" || err != nil { diff --git a/api/client/container/exec_test.go b/cli/command/container/exec_test.go similarity index 100% rename from api/client/container/exec_test.go rename to cli/command/container/exec_test.go diff --git a/api/client/container/export.go b/cli/command/container/export.go similarity index 82% rename from api/client/container/export.go rename to cli/command/container/export.go index c2fb176789..8fa2e5d77e 100644 --- a/api/client/container/export.go +++ b/cli/command/container/export.go @@ -6,8 +6,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -17,7 +17,7 @@ type exportOptions struct { } // NewExportCommand creates a new `docker export` command -func NewExportCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewExportCommand(dockerCli *command.DockerCli) *cobra.Command { var opts exportOptions cmd := &cobra.Command{ @@ -37,7 +37,7 @@ func NewExportCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runExport(dockerCli *client.DockerCli, opts exportOptions) error { +func runExport(dockerCli *command.DockerCli, 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.") } @@ -55,5 +55,5 @@ func runExport(dockerCli *client.DockerCli, opts exportOptions) error { return err } - return client.CopyToFile(opts.output, responseBody) + return command.CopyToFile(opts.output, responseBody) } diff --git a/api/client/container/hijack.go b/cli/command/container/hijack.go similarity index 96% rename from api/client/container/hijack.go rename to cli/command/container/hijack.go index 5a1b4119d5..855a152904 100644 --- a/api/client/container/hijack.go +++ b/cli/command/container/hijack.go @@ -6,15 +6,15 @@ import ( "sync" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/client" + "github.com/docker/docker/cli/command" "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/stdcopy" "golang.org/x/net/context" ) type streams interface { - In() *client.InStream - Out() *client.OutStream + In() *command.InStream + Out() *command.OutStream } // holdHijackedConnection handles copying input to and output from streams to the diff --git a/api/client/container/kill.go b/cli/command/container/kill.go similarity index 85% rename from api/client/container/kill.go rename to cli/command/container/kill.go index b5de545d39..8d9af6f7a6 100644 --- a/api/client/container/kill.go +++ b/cli/command/container/kill.go @@ -6,8 +6,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -18,7 +18,7 @@ type killOptions struct { } // NewKillCommand creates a new cobra.Command for `docker kill` -func NewKillCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewKillCommand(dockerCli *command.DockerCli) *cobra.Command { var opts killOptions cmd := &cobra.Command{ @@ -36,7 +36,7 @@ func NewKillCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runKill(dockerCli *client.DockerCli, opts *killOptions) error { +func runKill(dockerCli *command.DockerCli, opts *killOptions) error { var errs []string ctx := context.Background() for _, name := range opts.containers { diff --git a/api/client/container/logs.go b/cli/command/container/logs.go similarity index 92% rename from api/client/container/logs.go rename to cli/command/container/logs.go index a7b6241c4b..3a37cedf43 100644 --- a/api/client/container/logs.go +++ b/cli/command/container/logs.go @@ -6,9 +6,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/stdcopy" "github.com/spf13/cobra" ) @@ -29,7 +29,7 @@ type logsOptions struct { } // NewLogsCommand creates a new cobra.Command for `docker logs` -func NewLogsCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewLogsCommand(dockerCli *command.DockerCli) *cobra.Command { var opts logsOptions cmd := &cobra.Command{ @@ -51,7 +51,7 @@ func NewLogsCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runLogs(dockerCli *client.DockerCli, opts *logsOptions) error { +func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error { ctx := context.Background() c, err := dockerCli.Client().ContainerInspect(ctx, opts.container) diff --git a/api/client/container/pause.go b/cli/command/container/pause.go similarity index 83% rename from api/client/container/pause.go rename to cli/command/container/pause.go index 46315ee2c1..0cc5b351ba 100644 --- a/api/client/container/pause.go +++ b/cli/command/container/pause.go @@ -6,8 +6,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -16,7 +16,7 @@ type pauseOptions struct { } // NewPauseCommand creates a new cobra.Command for `docker pause` -func NewPauseCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewPauseCommand(dockerCli *command.DockerCli) *cobra.Command { var opts pauseOptions return &cobra.Command{ @@ -30,7 +30,7 @@ func NewPauseCommand(dockerCli *client.DockerCli) *cobra.Command { } } -func runPause(dockerCli *client.DockerCli, opts *pauseOptions) error { +func runPause(dockerCli *command.DockerCli, opts *pauseOptions) error { ctx := context.Background() var errs []string diff --git a/api/client/container/port.go b/cli/command/container/port.go similarity index 90% rename from api/client/container/port.go rename to cli/command/container/port.go index fe3317a697..ea15290145 100644 --- a/api/client/container/port.go +++ b/cli/command/container/port.go @@ -6,8 +6,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/go-connections/nat" "github.com/spf13/cobra" ) @@ -19,7 +19,7 @@ type portOptions struct { } // NewPortCommand creates a new cobra.Command for `docker port` -func NewPortCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewPortCommand(dockerCli *command.DockerCli) *cobra.Command { var opts portOptions cmd := &cobra.Command{ @@ -37,7 +37,7 @@ func NewPortCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runPort(dockerCli *client.DockerCli, opts *portOptions) error { +func runPort(dockerCli *command.DockerCli, opts *portOptions) error { ctx := context.Background() c, err := dockerCli.Client().ContainerInspect(ctx, opts.container) diff --git a/api/client/container/ps.go b/cli/command/container/ps.go similarity index 93% rename from api/client/container/ps.go rename to cli/command/container/ps.go index 700ba365b6..d7ae675f5b 100644 --- a/api/client/container/ps.go +++ b/cli/command/container/ps.go @@ -3,11 +3,11 @@ package container import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/formatter" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/formatter" "io/ioutil" @@ -27,7 +27,7 @@ type psOptions struct { } // NewPsCommand creates a new cobra.Command for `docker ps` -func NewPsCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewPsCommand(dockerCli *command.DockerCli) *cobra.Command { var opts psOptions cmd := &cobra.Command{ @@ -103,7 +103,7 @@ func buildContainerListOptions(opts *psOptions) (*types.ContainerListOptions, er return options, nil } -func runPs(dockerCli *client.DockerCli, opts *psOptions) error { +func runPs(dockerCli *command.DockerCli, opts *psOptions) error { ctx := context.Background() listOptions, err := buildContainerListOptions(opts) diff --git a/api/client/container/ps_test.go b/cli/command/container/ps_test.go similarity index 100% rename from api/client/container/ps_test.go rename to cli/command/container/ps_test.go diff --git a/api/client/container/rename.go b/cli/command/container/rename.go similarity index 84% rename from api/client/container/rename.go rename to cli/command/container/rename.go index e63b96fab6..346fb7b3b9 100644 --- a/api/client/container/rename.go +++ b/cli/command/container/rename.go @@ -6,8 +6,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -17,7 +17,7 @@ type renameOptions struct { } // NewRenameCommand creates a new cobra.Command for `docker rename` -func NewRenameCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewRenameCommand(dockerCli *command.DockerCli) *cobra.Command { var opts renameOptions cmd := &cobra.Command{ @@ -33,7 +33,7 @@ func NewRenameCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runRename(dockerCli *client.DockerCli, opts *renameOptions) error { +func runRename(dockerCli *command.DockerCli, opts *renameOptions) error { ctx := context.Background() oldName := strings.TrimSpace(opts.oldName) diff --git a/api/client/container/restart.go b/cli/command/container/restart.go similarity index 86% rename from api/client/container/restart.go rename to cli/command/container/restart.go index f9b775ce15..e370ef4010 100644 --- a/api/client/container/restart.go +++ b/cli/command/container/restart.go @@ -7,8 +7,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -19,7 +19,7 @@ type restartOptions struct { } // NewRestartCommand creates a new cobra.Command for `docker restart` -func NewRestartCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewRestartCommand(dockerCli *command.DockerCli) *cobra.Command { var opts restartOptions cmd := &cobra.Command{ @@ -37,7 +37,7 @@ func NewRestartCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runRestart(dockerCli *client.DockerCli, opts *restartOptions) error { +func runRestart(dockerCli *command.DockerCli, opts *restartOptions) error { ctx := context.Background() var errs []string for _, name := range opts.containers { diff --git a/api/client/container/rm.go b/cli/command/container/rm.go similarity index 84% rename from api/client/container/rm.go rename to cli/command/container/rm.go index e45994f9ef..622a69b510 100644 --- a/api/client/container/rm.go +++ b/cli/command/container/rm.go @@ -6,9 +6,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -21,7 +21,7 @@ type rmOptions struct { } // NewRmCommand creates a new cobra.Command for `docker rm` -func NewRmCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewRmCommand(dockerCli *command.DockerCli) *cobra.Command { var opts rmOptions cmd := &cobra.Command{ @@ -41,7 +41,7 @@ func NewRmCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runRm(dockerCli *client.DockerCli, opts *rmOptions) error { +func runRm(dockerCli *command.DockerCli, opts *rmOptions) error { ctx := context.Background() var errs []string @@ -63,7 +63,7 @@ func runRm(dockerCli *client.DockerCli, opts *rmOptions) error { return nil } -func removeContainer(dockerCli *client.DockerCli, ctx context.Context, container string, removeVolumes, removeLinks, force bool) error { +func removeContainer(dockerCli *command.DockerCli, ctx context.Context, container string, removeVolumes, removeLinks, force bool) error { options := types.ContainerRemoveOptions{ RemoveVolumes: removeVolumes, RemoveLinks: removeLinks, diff --git a/api/client/container/run.go b/cli/command/container/run.go similarity index 96% rename from api/client/container/run.go rename to cli/command/container/run.go index af1a898234..d36ab610cf 100644 --- a/api/client/container/run.go +++ b/cli/command/container/run.go @@ -12,9 +12,9 @@ import ( "golang.org/x/net/context" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" opttypes "github.com/docker/docker/opts" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/signal" @@ -32,7 +32,7 @@ type runOptions struct { } // NewRunCommand create a new `docker run` command -func NewRunCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewRunCommand(dockerCli *command.DockerCli) *cobra.Command { var opts runOptions var copts *runconfigopts.ContainerOptions @@ -62,12 +62,12 @@ func NewRunCommand(dockerCli *client.DockerCli) *cobra.Command { // with hostname flags.Bool("help", false, "Print usage") - client.AddTrustedFlags(flags, true) + command.AddTrustedFlags(flags, true) copts = runconfigopts.AddFlags(flags) return cmd } -func runRun(dockerCli *client.DockerCli, flags *pflag.FlagSet, opts *runOptions, copts *runconfigopts.ContainerOptions) error { +func runRun(dockerCli *command.DockerCli, flags *pflag.FlagSet, opts *runOptions, copts *runconfigopts.ContainerOptions) error { stdout, stderr, stdin := dockerCli.Out(), dockerCli.Err(), dockerCli.In() client := dockerCli.Client() // TODO: pass this as an argument diff --git a/api/client/container/start.go b/cli/command/container/start.go similarity index 93% rename from api/client/container/start.go rename to cli/command/container/start.go index c3b4a3167b..e72369177a 100644 --- a/api/client/container/start.go +++ b/cli/command/container/start.go @@ -8,9 +8,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/signal" "github.com/spf13/cobra" @@ -25,7 +25,7 @@ type startOptions struct { } // NewStartCommand creates a new cobra.Command for `docker start` -func NewStartCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewStartCommand(dockerCli *command.DockerCli) *cobra.Command { var opts startOptions cmd := &cobra.Command{ @@ -45,7 +45,7 @@ func NewStartCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runStart(dockerCli *client.DockerCli, opts *startOptions) error { +func runStart(dockerCli *command.DockerCli, opts *startOptions) error { ctx, cancelFun := context.WithCancel(context.Background()) if opts.attach || opts.openStdin { @@ -143,7 +143,7 @@ func runStart(dockerCli *client.DockerCli, opts *startOptions) error { return nil } -func startContainersWithoutAttachments(dockerCli *client.DockerCli, ctx context.Context, containers []string) error { +func startContainersWithoutAttachments(dockerCli *command.DockerCli, ctx context.Context, containers []string) error { var failedContainers []string for _, container := range containers { if err := dockerCli.Client().ContainerStart(ctx, container, types.ContainerStartOptions{}); err != nil { diff --git a/api/client/container/stats.go b/cli/command/container/stats.go similarity index 96% rename from api/client/container/stats.go rename to cli/command/container/stats.go index 093b81fcad..ffd3fcae9f 100644 --- a/api/client/container/stats.go +++ b/cli/command/container/stats.go @@ -11,12 +11,12 @@ import ( "golang.org/x/net/context" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/system" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/system" "github.com/spf13/cobra" ) @@ -28,7 +28,7 @@ type statsOptions struct { } // NewStatsCommand creates a new cobra.Command for `docker stats` -func NewStatsCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewStatsCommand(dockerCli *command.DockerCli) *cobra.Command { var opts statsOptions cmd := &cobra.Command{ @@ -49,7 +49,7 @@ func NewStatsCommand(dockerCli *client.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. -func runStats(dockerCli *client.DockerCli, opts *statsOptions) error { +func runStats(dockerCli *command.DockerCli, opts *statsOptions) error { showAll := len(opts.containers) == 0 closeChan := make(chan error) diff --git a/api/client/container/stats_helpers.go b/cli/command/container/stats_helpers.go similarity index 100% rename from api/client/container/stats_helpers.go rename to cli/command/container/stats_helpers.go diff --git a/api/client/container/stats_unit_test.go b/cli/command/container/stats_unit_test.go similarity index 100% rename from api/client/container/stats_unit_test.go rename to cli/command/container/stats_unit_test.go diff --git a/api/client/container/stop.go b/cli/command/container/stop.go similarity index 86% rename from api/client/container/stop.go rename to cli/command/container/stop.go index 5e8a23f09a..dddb7efa22 100644 --- a/api/client/container/stop.go +++ b/cli/command/container/stop.go @@ -7,8 +7,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -19,7 +19,7 @@ type stopOptions struct { } // NewStopCommand creates a new cobra.Command for `docker stop` -func NewStopCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewStopCommand(dockerCli *command.DockerCli) *cobra.Command { var opts stopOptions cmd := &cobra.Command{ @@ -37,7 +37,7 @@ func NewStopCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runStop(dockerCli *client.DockerCli, opts *stopOptions) error { +func runStop(dockerCli *command.DockerCli, opts *stopOptions) error { ctx := context.Background() var errs []string diff --git a/api/client/container/top.go b/cli/command/container/top.go similarity index 85% rename from api/client/container/top.go rename to cli/command/container/top.go index 3ade5fbd6d..160153ba7f 100644 --- a/api/client/container/top.go +++ b/cli/command/container/top.go @@ -7,8 +7,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -19,7 +19,7 @@ type topOptions struct { } // NewTopCommand creates a new cobra.Command for `docker top` -func NewTopCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewTopCommand(dockerCli *command.DockerCli) *cobra.Command { var opts topOptions cmd := &cobra.Command{ @@ -39,7 +39,7 @@ func NewTopCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runTop(dockerCli *client.DockerCli, opts *topOptions) error { +func runTop(dockerCli *command.DockerCli, opts *topOptions) error { ctx := context.Background() procList, err := dockerCli.Client().ContainerTop(ctx, opts.container, opts.args) diff --git a/api/client/container/tty.go b/cli/command/container/tty.go similarity index 82% rename from api/client/container/tty.go rename to cli/command/container/tty.go index 7af732750b..5360c6b040 100644 --- a/api/client/container/tty.go +++ b/cli/command/container/tty.go @@ -8,15 +8,15 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/client" + "github.com/docker/docker/cli/command" "github.com/docker/docker/api/types" - apiclient "github.com/docker/docker/client" + "github.com/docker/docker/client" "github.com/docker/docker/pkg/signal" "golang.org/x/net/context" ) // resizeTtyTo resizes tty to specific height and width -func resizeTtyTo(ctx context.Context, client apiclient.ContainerAPIClient, id string, height, width int, isExec bool) { +func resizeTtyTo(ctx context.Context, client client.ContainerAPIClient, id string, height, width int, isExec bool) { if height == 0 && width == 0 { return } @@ -39,7 +39,7 @@ func resizeTtyTo(ctx context.Context, client apiclient.ContainerAPIClient, id st } // MonitorTtySize updates the container tty size when the terminal tty changes size -func MonitorTtySize(ctx context.Context, cli *client.DockerCli, id string, isExec bool) error { +func MonitorTtySize(ctx context.Context, cli *command.DockerCli, id string, isExec bool) error { resizeTty := func() { height, width := cli.Out().GetTtySize() resizeTtyTo(ctx, cli.Client(), id, height, width, isExec) @@ -74,7 +74,7 @@ func MonitorTtySize(ctx context.Context, cli *client.DockerCli, id string, isExe } // ForwardAllSignals forwards signals to the container -func ForwardAllSignals(ctx context.Context, cli *client.DockerCli, cid string) chan os.Signal { +func ForwardAllSignals(ctx context.Context, cli *command.DockerCli, cid string) chan os.Signal { sigc := make(chan os.Signal, 128) signal.CatchAll(sigc) go func() { diff --git a/api/client/container/unpause.go b/cli/command/container/unpause.go similarity index 83% rename from api/client/container/unpause.go rename to cli/command/container/unpause.go index 8ce7c3f711..c3635db555 100644 --- a/api/client/container/unpause.go +++ b/cli/command/container/unpause.go @@ -6,8 +6,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -16,7 +16,7 @@ type unpauseOptions struct { } // NewUnpauseCommand creates a new cobra.Command for `docker unpause` -func NewUnpauseCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewUnpauseCommand(dockerCli *command.DockerCli) *cobra.Command { var opts unpauseOptions cmd := &cobra.Command{ @@ -31,7 +31,7 @@ func NewUnpauseCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runUnpause(dockerCli *client.DockerCli, opts *unpauseOptions) error { +func runUnpause(dockerCli *command.DockerCli, opts *unpauseOptions) error { ctx := context.Background() var errs []string diff --git a/api/client/container/update.go b/cli/command/container/update.go similarity index 95% rename from api/client/container/update.go rename to cli/command/container/update.go index ee3426db2c..b5770c8997 100644 --- a/api/client/container/update.go +++ b/cli/command/container/update.go @@ -6,9 +6,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/docker/go-units" "github.com/spf13/cobra" @@ -33,7 +33,7 @@ type updateOptions struct { } // NewUpdateCommand creates a new cobra.Command for `docker update` -func NewUpdateCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewUpdateCommand(dockerCli *command.DockerCli) *cobra.Command { var opts updateOptions cmd := &cobra.Command{ @@ -63,7 +63,7 @@ func NewUpdateCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runUpdate(dockerCli *client.DockerCli, opts *updateOptions) error { +func runUpdate(dockerCli *command.DockerCli, opts *updateOptions) error { var err error if opts.nFlag == 0 { diff --git a/api/client/container/utils.go b/cli/command/container/utils.go similarity index 85% rename from api/client/container/utils.go rename to cli/command/container/utils.go index 38fb0a5a4b..8c993dcce5 100644 --- a/api/client/container/utils.go +++ b/cli/command/container/utils.go @@ -7,15 +7,15 @@ import ( "golang.org/x/net/context" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/system" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/system" clientapi "github.com/docker/docker/client" ) -func waitExitOrRemoved(dockerCli *client.DockerCli, ctx context.Context, containerID string, waitRemove bool) (chan int, error) { +func waitExitOrRemoved(dockerCli *command.DockerCli, ctx context.Context, containerID string, waitRemove bool) (chan int, error) { if len(containerID) == 0 { // containerID can never be empty panic("Internal Error: waitExitOrRemoved needs a containerID as parameter") @@ -79,7 +79,7 @@ func waitExitOrRemoved(dockerCli *client.DockerCli, ctx context.Context, contain // getExitCode performs an inspect on the container. It returns // the running state and the exit code. -func getExitCode(dockerCli *client.DockerCli, ctx context.Context, containerID string) (bool, int, error) { +func getExitCode(dockerCli *command.DockerCli, ctx context.Context, containerID string) (bool, int, error) { c, err := dockerCli.Client().ContainerInspect(ctx, containerID) if err != nil { // If we can't connect, then the daemon probably died. diff --git a/api/client/container/wait.go b/cli/command/container/wait.go similarity index 84% rename from api/client/container/wait.go rename to cli/command/container/wait.go index fec390b8b7..19ccf7ac25 100644 --- a/api/client/container/wait.go +++ b/cli/command/container/wait.go @@ -6,8 +6,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -16,7 +16,7 @@ type waitOptions struct { } // NewWaitCommand creates a new cobra.Command for `docker wait` -func NewWaitCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewWaitCommand(dockerCli *command.DockerCli) *cobra.Command { var opts waitOptions cmd := &cobra.Command{ @@ -31,7 +31,7 @@ func NewWaitCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runWait(dockerCli *client.DockerCli, opts *waitOptions) error { +func runWait(dockerCli *command.DockerCli, opts *waitOptions) error { ctx := context.Background() var errs []string diff --git a/api/client/credentials.go b/cli/command/credentials.go similarity index 98% rename from api/client/credentials.go rename to cli/command/credentials.go index b9aa3ebda4..06e9d1de20 100644 --- a/api/client/credentials.go +++ b/cli/command/credentials.go @@ -1,4 +1,4 @@ -package client +package command import ( "github.com/docker/docker/api/types" diff --git a/api/client/formatter/container.go b/cli/command/formatter/container.go similarity index 100% rename from api/client/formatter/container.go rename to cli/command/formatter/container.go diff --git a/api/client/formatter/container_test.go b/cli/command/formatter/container_test.go similarity index 98% rename from api/client/formatter/container_test.go rename to cli/command/formatter/container_test.go index cc7b916242..deaa915a89 100644 --- a/api/client/formatter/container_test.go +++ b/cli/command/formatter/container_test.go @@ -232,19 +232,19 @@ containerID2 ubuntu "" 24 hours ago image: ubuntu command: "" created_at: %s -status: +status: names: foobar_baz -labels: -ports: +labels: +ports: container_id: containerID2 image: ubuntu command: "" created_at: %s -status: +status: names: foobar_bar -labels: -ports: +labels: +ports: `, expectedTime, expectedTime), }, @@ -259,20 +259,20 @@ ports: image: ubuntu command: "" created_at: %s -status: +status: names: foobar_baz -labels: -ports: +labels: +ports: size: 0 B container_id: containerID2 image: ubuntu command: "" created_at: %s -status: +status: names: foobar_bar -labels: -ports: +labels: +ports: size: 0 B `, expectedTime, expectedTime), diff --git a/api/client/formatter/custom.go b/cli/command/formatter/custom.go similarity index 100% rename from api/client/formatter/custom.go rename to cli/command/formatter/custom.go diff --git a/api/client/formatter/custom_test.go b/cli/command/formatter/custom_test.go similarity index 100% rename from api/client/formatter/custom_test.go rename to cli/command/formatter/custom_test.go diff --git a/api/client/formatter/formatter.go b/cli/command/formatter/formatter.go similarity index 100% rename from api/client/formatter/formatter.go rename to cli/command/formatter/formatter.go diff --git a/api/client/formatter/image.go b/cli/command/formatter/image.go similarity index 100% rename from api/client/formatter/image.go rename to cli/command/formatter/image.go diff --git a/api/client/formatter/image_test.go b/cli/command/formatter/image_test.go similarity index 100% rename from api/client/formatter/image_test.go rename to cli/command/formatter/image_test.go diff --git a/api/client/formatter/network.go b/cli/command/formatter/network.go similarity index 100% rename from api/client/formatter/network.go rename to cli/command/formatter/network.go diff --git a/api/client/formatter/network_test.go b/cli/command/formatter/network_test.go similarity index 100% rename from api/client/formatter/network_test.go rename to cli/command/formatter/network_test.go diff --git a/api/client/formatter/volume.go b/cli/command/formatter/volume.go similarity index 100% rename from api/client/formatter/volume.go rename to cli/command/formatter/volume.go diff --git a/api/client/formatter/volume_test.go b/cli/command/formatter/volume_test.go similarity index 100% rename from api/client/formatter/volume_test.go rename to cli/command/formatter/volume_test.go diff --git a/api/client/idresolver/idresolver.go b/cli/command/idresolver/idresolver.go similarity index 100% rename from api/client/idresolver/idresolver.go rename to cli/command/idresolver/idresolver.go diff --git a/api/client/image/build.go b/cli/command/image/build.go similarity index 97% rename from api/client/image/build.go rename to cli/command/image/build.go index 226c43dc06..10ad413f25 100644 --- a/api/client/image/build.go +++ b/cli/command/image/build.go @@ -14,12 +14,12 @@ import ( "golang.org/x/net/context" "github.com/docker/docker/api" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/builder" "github.com/docker/docker/builder/dockerignore" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/fileutils" @@ -58,7 +58,7 @@ type buildOptions struct { } // NewBuildCommand creates a new `docker build` command -func NewBuildCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewBuildCommand(dockerCli *command.DockerCli) *cobra.Command { ulimits := make(map[string]*units.Ulimit) options := buildOptions{ tags: opts.NewListOpts(validateTag), @@ -99,7 +99,7 @@ func NewBuildCommand(dockerCli *client.DockerCli) *cobra.Command { flags.BoolVarP(&options.quiet, "quiet", "q", false, "Suppress the build output and print image ID on success") flags.BoolVar(&options.pull, "pull", false, "Always attempt to pull a newer version of the image") - client.AddTrustedFlags(flags, true) + command.AddTrustedFlags(flags, true) return cmd } @@ -120,7 +120,7 @@ func (out *lastProgressOutput) WriteProgress(prog progress.Progress) error { return out.output.WriteProgress(prog) } -func runBuild(dockerCli *client.DockerCli, options buildOptions) error { +func runBuild(dockerCli *command.DockerCli, options buildOptions) error { var ( buildCtx io.ReadCloser @@ -219,7 +219,7 @@ func runBuild(dockerCli *client.DockerCli, options buildOptions) error { ctx := context.Background() var resolvedTags []*resolvedTag - if client.IsTrusted() { + if command.IsTrusted() { // Wrap the tar archive to replace the Dockerfile entry with the rewritten // Dockerfile which uses trusted pulls. buildCtx = replaceDockerfileTarWrapper(ctx, buildCtx, relDockerfile, dockerCli.TrustedReference, &resolvedTags) @@ -319,7 +319,7 @@ func runBuild(dockerCli *client.DockerCli, options buildOptions) error { fmt.Fprintf(dockerCli.Out(), "%s", buildBuff) } - if client.IsTrusted() { + if command.IsTrusted() { // Since the build was successful, now we must tag any of the resolved // images from the above Dockerfile rewrite. for _, resolved := range resolvedTags { @@ -373,7 +373,7 @@ func rewriteDockerfileFrom(ctx context.Context, dockerfile io.Reader, translator return nil, nil, err } ref = reference.WithDefaultTag(ref) - if ref, ok := ref.(reference.NamedTagged); ok && client.IsTrusted() { + if ref, ok := ref.(reference.NamedTagged); ok && command.IsTrusted() { trustedRef, err := translator(ctx, ref) if err != nil { return nil, nil, err diff --git a/api/client/image/history.go b/cli/command/image/history.go similarity index 92% rename from api/client/image/history.go rename to cli/command/image/history.go index 716c59bf72..a75403a45f 100644 --- a/api/client/image/history.go +++ b/cli/command/image/history.go @@ -9,8 +9,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringutils" "github.com/docker/go-units" @@ -26,7 +26,7 @@ type historyOptions struct { } // NewHistoryCommand creates a new `docker history` command -func NewHistoryCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewHistoryCommand(dockerCli *command.DockerCli) *cobra.Command { var opts historyOptions cmd := &cobra.Command{ @@ -48,7 +48,7 @@ func NewHistoryCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runHistory(dockerCli *client.DockerCli, opts historyOptions) error { +func runHistory(dockerCli *command.DockerCli, opts historyOptions) error { ctx := context.Background() history, err := dockerCli.Client().ImageHistory(ctx, opts.image) diff --git a/api/client/image/images.go b/cli/command/image/images.go similarity index 90% rename from api/client/image/images.go rename to cli/command/image/images.go index 6b864a8acc..f00fecf672 100644 --- a/api/client/image/images.go +++ b/cli/command/image/images.go @@ -3,11 +3,11 @@ package image import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/formatter" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/formatter" "github.com/spf13/cobra" ) @@ -23,7 +23,7 @@ type imagesOptions struct { } // NewImagesCommand creates a new `docker images` command -func NewImagesCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewImagesCommand(dockerCli *command.DockerCli) *cobra.Command { var opts imagesOptions cmd := &cobra.Command{ @@ -50,7 +50,7 @@ func NewImagesCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runImages(dockerCli *client.DockerCli, opts imagesOptions) error { +func runImages(dockerCli *command.DockerCli, opts imagesOptions) error { ctx := context.Background() // Consolidate all filter flags, and sanity check them early. diff --git a/api/client/image/import.go b/cli/command/image/import.go similarity index 91% rename from api/client/image/import.go rename to cli/command/image/import.go index d56a5bb668..60024fb53c 100644 --- a/api/client/image/import.go +++ b/cli/command/image/import.go @@ -6,9 +6,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" dockeropts "github.com/docker/docker/opts" "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/urlutil" @@ -23,7 +23,7 @@ type importOptions struct { } // NewImportCommand creates a new `docker import` command -func NewImportCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewImportCommand(dockerCli *command.DockerCli) *cobra.Command { var opts importOptions cmd := &cobra.Command{ @@ -48,7 +48,7 @@ func NewImportCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runImport(dockerCli *client.DockerCli, opts importOptions) error { +func runImport(dockerCli *command.DockerCli, opts importOptions) error { var ( in io.Reader srcName = opts.source diff --git a/api/client/image/load.go b/cli/command/image/load.go similarity index 88% rename from api/client/image/load.go rename to cli/command/image/load.go index 8905fa2819..56145a8a34 100644 --- a/api/client/image/load.go +++ b/cli/command/image/load.go @@ -6,8 +6,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/jsonmessage" "github.com/spf13/cobra" ) @@ -18,7 +18,7 @@ type loadOptions struct { } // NewLoadCommand creates a new `docker load` command -func NewLoadCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewLoadCommand(dockerCli *command.DockerCli) *cobra.Command { var opts loadOptions cmd := &cobra.Command{ @@ -38,7 +38,7 @@ func NewLoadCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runLoad(dockerCli *client.DockerCli, opts loadOptions) error { +func runLoad(dockerCli *command.DockerCli, opts loadOptions) error { var input io.Reader = dockerCli.In() if opts.input != "" { diff --git a/api/client/image/pull.go b/cli/command/image/pull.go similarity index 88% rename from api/client/image/pull.go rename to cli/command/image/pull.go index 5753c14bae..88ccb47342 100644 --- a/api/client/image/pull.go +++ b/cli/command/image/pull.go @@ -7,8 +7,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/reference" "github.com/docker/docker/registry" "github.com/spf13/cobra" @@ -20,7 +20,7 @@ type pullOptions struct { } // NewPullCommand creates a new `docker pull` command -func NewPullCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewPullCommand(dockerCli *command.DockerCli) *cobra.Command { var opts pullOptions cmd := &cobra.Command{ @@ -36,12 +36,12 @@ func NewPullCommand(dockerCli *client.DockerCli) *cobra.Command { flags := cmd.Flags() flags.BoolVarP(&opts.all, "all-tags", "a", false, "Download all tagged images in the repository") - client.AddTrustedFlags(flags, true) + command.AddTrustedFlags(flags, true) return cmd } -func runPull(dockerCli *client.DockerCli, opts pullOptions) error { +func runPull(dockerCli *command.DockerCli, opts pullOptions) error { distributionRef, err := reference.ParseNamed(opts.remote) if err != nil { return err @@ -76,7 +76,7 @@ func runPull(dockerCli *client.DockerCli, opts pullOptions) error { authConfig := dockerCli.ResolveAuthConfig(ctx, repoInfo.Index) requestPrivilege := dockerCli.RegistryAuthenticationPrivilegedFunc(repoInfo.Index, "pull") - if client.IsTrusted() && !registryRef.HasDigest() { + if command.IsTrusted() && !registryRef.HasDigest() { // Check if tag is digest err = dockerCli.TrustedPull(ctx, repoInfo, registryRef, authConfig, requestPrivilege) } else { diff --git a/api/client/image/push.go b/cli/command/image/push.go similarity index 85% rename from api/client/image/push.go rename to cli/command/image/push.go index 3eb41cf08d..62b637f6ee 100644 --- a/api/client/image/push.go +++ b/cli/command/image/push.go @@ -3,8 +3,8 @@ package image import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/reference" "github.com/docker/docker/registry" @@ -12,7 +12,7 @@ import ( ) // NewPushCommand creates a new `docker push` command -func NewPushCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewPushCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "push [OPTIONS] NAME[:TAG]", Short: "Push an image or a repository to a registry", @@ -24,12 +24,12 @@ func NewPushCommand(dockerCli *client.DockerCli) *cobra.Command { flags := cmd.Flags() - client.AddTrustedFlags(flags, true) + command.AddTrustedFlags(flags, true) return cmd } -func runPush(dockerCli *client.DockerCli, remote string) error { +func runPush(dockerCli *command.DockerCli, remote string) error { ref, err := reference.ParseNamed(remote) if err != nil { return err @@ -47,7 +47,7 @@ func runPush(dockerCli *client.DockerCli, remote string) error { authConfig := dockerCli.ResolveAuthConfig(ctx, repoInfo.Index) requestPrivilege := dockerCli.RegistryAuthenticationPrivilegedFunc(repoInfo.Index, "push") - if client.IsTrusted() { + if command.IsTrusted() { return dockerCli.TrustedPush(ctx, repoInfo, ref, authConfig, requestPrivilege) } diff --git a/api/client/image/remove.go b/cli/command/image/remove.go similarity index 87% rename from api/client/image/remove.go rename to cli/command/image/remove.go index 04826a2d64..51a7b21642 100644 --- a/api/client/image/remove.go +++ b/cli/command/image/remove.go @@ -6,9 +6,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -18,7 +18,7 @@ type removeOptions struct { } // NewRemoveCommand creates a new `docker remove` command -func NewRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewRemoveCommand(dockerCli *command.DockerCli) *cobra.Command { var opts removeOptions cmd := &cobra.Command{ @@ -38,7 +38,7 @@ func NewRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runRemove(dockerCli *client.DockerCli, opts removeOptions, images []string) error { +func runRemove(dockerCli *command.DockerCli, opts removeOptions, images []string) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/image/save.go b/cli/command/image/save.go similarity index 82% rename from api/client/image/save.go rename to cli/command/image/save.go index f7563880b7..bbe82d2a05 100644 --- a/api/client/image/save.go +++ b/cli/command/image/save.go @@ -6,8 +6,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -17,7 +17,7 @@ type saveOptions struct { } // NewSaveCommand creates a new `docker save` command -func NewSaveCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewSaveCommand(dockerCli *command.DockerCli) *cobra.Command { var opts saveOptions cmd := &cobra.Command{ @@ -37,7 +37,7 @@ func NewSaveCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runSave(dockerCli *client.DockerCli, opts saveOptions) error { +func runSave(dockerCli *command.DockerCli, opts saveOptions) error { if opts.output == "" && dockerCli.Out().IsTerminal() { return errors.New("Cowardly refusing to save to a terminal. Use the -o flag or redirect.") } @@ -53,5 +53,5 @@ func runSave(dockerCli *client.DockerCli, opts saveOptions) error { return err } - return client.CopyToFile(opts.output, responseBody) + return command.CopyToFile(opts.output, responseBody) } diff --git a/api/client/image/search.go b/cli/command/image/search.go similarity index 93% rename from api/client/image/search.go rename to cli/command/image/search.go index b4b800ef0f..7c4ad03b96 100644 --- a/api/client/image/search.go +++ b/cli/command/image/search.go @@ -8,11 +8,11 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/stringutils" "github.com/docker/docker/registry" "github.com/spf13/cobra" @@ -30,7 +30,7 @@ type searchOptions struct { } // NewSearchCommand creates a new `docker search` command -func NewSearchCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewSearchCommand(dockerCli *command.DockerCli) *cobra.Command { var opts searchOptions cmd := &cobra.Command{ @@ -58,7 +58,7 @@ func NewSearchCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runSearch(dockerCli *client.DockerCli, opts searchOptions) error { +func runSearch(dockerCli *command.DockerCli, opts searchOptions) error { indexInfo, err := registry.ParseSearchIndexInfo(opts.term) if err != nil { return err @@ -69,7 +69,7 @@ func runSearch(dockerCli *client.DockerCli, opts searchOptions) error { authConfig := dockerCli.ResolveAuthConfig(ctx, indexInfo) requestPrivilege := dockerCli.RegistryAuthenticationPrivilegedFunc(indexInfo, "search") - encodedAuth, err := client.EncodeAuthToBase64(authConfig) + encodedAuth, err := command.EncodeAuthToBase64(authConfig) if err != nil { return err } diff --git a/api/client/image/tag.go b/cli/command/image/tag.go similarity index 80% rename from api/client/image/tag.go rename to cli/command/image/tag.go index 6d77d9d413..b88789b0f8 100644 --- a/api/client/image/tag.go +++ b/cli/command/image/tag.go @@ -3,8 +3,8 @@ package image import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -14,7 +14,7 @@ type tagOptions struct { } // NewTagCommand creates a new `docker tag` command -func NewTagCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewTagCommand(dockerCli *command.DockerCli) *cobra.Command { var opts tagOptions cmd := &cobra.Command{ @@ -34,7 +34,7 @@ func NewTagCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runTag(dockerCli *client.DockerCli, opts tagOptions) error { +func runTag(dockerCli *command.DockerCli, opts tagOptions) error { ctx := context.Background() return dockerCli.Client().ImageTag(ctx, opts.image, opts.name) diff --git a/api/client/in.go b/cli/command/in.go similarity index 99% rename from api/client/in.go rename to cli/command/in.go index f0ce628dec..c3ed70dc12 100644 --- a/api/client/in.go +++ b/cli/command/in.go @@ -1,4 +1,4 @@ -package client +package command import ( "errors" diff --git a/api/client/inspect/inspector.go b/cli/command/inspect/inspector.go similarity index 100% rename from api/client/inspect/inspector.go rename to cli/command/inspect/inspector.go diff --git a/api/client/inspect/inspector_test.go b/cli/command/inspect/inspector_test.go similarity index 100% rename from api/client/inspect/inspector_test.go rename to cli/command/inspect/inspector_test.go diff --git a/api/client/network/cmd.go b/cli/command/network/cmd.go similarity index 84% rename from api/client/network/cmd.go rename to cli/command/network/cmd.go index f616129f15..a7c9b3fce3 100644 --- a/api/client/network/cmd.go +++ b/cli/command/network/cmd.go @@ -5,12 +5,12 @@ import ( "github.com/spf13/cobra" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" ) // NewNetworkCommand returns a cobra command for `network` subcommands -func NewNetworkCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewNetworkCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "network", Short: "Manage Docker networks", diff --git a/api/client/network/connect.go b/cli/command/network/connect.go similarity index 89% rename from api/client/network/connect.go rename to cli/command/network/connect.go index 66f761e80d..c4b676e5f1 100644 --- a/api/client/network/connect.go +++ b/cli/command/network/connect.go @@ -3,9 +3,9 @@ package network import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types/network" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/opts" runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/spf13/cobra" @@ -21,7 +21,7 @@ type connectOptions struct { linklocalips []string } -func newConnectCommand(dockerCli *client.DockerCli) *cobra.Command { +func newConnectCommand(dockerCli *command.DockerCli) *cobra.Command { opts := connectOptions{ links: opts.NewListOpts(runconfigopts.ValidateLink), } @@ -47,7 +47,7 @@ func newConnectCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runConnect(dockerCli *client.DockerCli, opts connectOptions) error { +func runConnect(dockerCli *command.DockerCli, opts connectOptions) error { client := dockerCli.Client() epConfig := &network.EndpointSettings{ diff --git a/api/client/network/create.go b/cli/command/network/create.go similarity index 97% rename from api/client/network/create.go rename to cli/command/network/create.go index 8de2c9cd4c..2ffd80548b 100644 --- a/api/client/network/create.go +++ b/cli/command/network/create.go @@ -7,10 +7,10 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/opts" runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/spf13/cobra" @@ -33,7 +33,7 @@ type createOptions struct { ipamOpt opts.MapOpts } -func newCreateCommand(dockerCli *client.DockerCli) *cobra.Command { +func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command { opts := createOptions{ driverOpts: *opts.NewMapOpts(nil, nil), ipamAux: *opts.NewMapOpts(nil, nil), @@ -69,7 +69,7 @@ func newCreateCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runCreate(dockerCli *client.DockerCli, opts createOptions) error { +func runCreate(dockerCli *command.DockerCli, opts createOptions) error { client := dockerCli.Client() ipamCfg, err := consolidateIpam(opts.ipamSubnet, opts.ipamIPRange, opts.ipamGateway, opts.ipamAux.GetAll()) diff --git a/api/client/network/disconnect.go b/cli/command/network/disconnect.go similarity index 80% rename from api/client/network/disconnect.go rename to cli/command/network/disconnect.go index 7d5111ba67..c9d9c14a13 100644 --- a/api/client/network/disconnect.go +++ b/cli/command/network/disconnect.go @@ -3,8 +3,8 @@ package network import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -14,7 +14,7 @@ type disconnectOptions struct { force bool } -func newDisconnectCommand(dockerCli *client.DockerCli) *cobra.Command { +func newDisconnectCommand(dockerCli *command.DockerCli) *cobra.Command { opts := disconnectOptions{} cmd := &cobra.Command{ @@ -34,7 +34,7 @@ func newDisconnectCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runDisconnect(dockerCli *client.DockerCli, opts disconnectOptions) error { +func runDisconnect(dockerCli *command.DockerCli, opts disconnectOptions) error { client := dockerCli.Client() return client.NetworkDisconnect(context.Background(), opts.network, opts.container, opts.force) diff --git a/api/client/network/inspect.go b/cli/command/network/inspect.go similarity index 79% rename from api/client/network/inspect.go rename to cli/command/network/inspect.go index 3a503e14d4..f1f677db9c 100644 --- a/api/client/network/inspect.go +++ b/cli/command/network/inspect.go @@ -3,9 +3,9 @@ package network import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/inspect" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/inspect" "github.com/spf13/cobra" ) @@ -14,7 +14,7 @@ type inspectOptions struct { names []string } -func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command { +func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { var opts inspectOptions cmd := &cobra.Command{ @@ -32,7 +32,7 @@ func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error { +func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/network/list.go b/cli/command/network/list.go similarity index 90% rename from api/client/network/list.go rename to cli/command/network/list.go index 54ed879e45..19013a3b8e 100644 --- a/api/client/network/list.go +++ b/cli/command/network/list.go @@ -5,11 +5,11 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/formatter" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/formatter" "github.com/spf13/cobra" ) @@ -26,7 +26,7 @@ type listOptions struct { filter []string } -func newListCommand(dockerCli *client.DockerCli) *cobra.Command { +func newListCommand(dockerCli *command.DockerCli) *cobra.Command { var opts listOptions cmd := &cobra.Command{ @@ -48,7 +48,7 @@ func newListCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runList(dockerCli *client.DockerCli, opts listOptions) error { +func runList(dockerCli *command.DockerCli, opts listOptions) error { client := dockerCli.Client() netFilterArgs := filters.NewArgs() diff --git a/api/client/network/remove.go b/cli/command/network/remove.go similarity index 80% rename from api/client/network/remove.go rename to cli/command/network/remove.go index 0313cf0be8..2034b8709e 100644 --- a/api/client/network/remove.go +++ b/cli/command/network/remove.go @@ -5,12 +5,12 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) -func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { +func newRemoveCommand(dockerCli *command.DockerCli) *cobra.Command { return &cobra.Command{ Use: "rm NETWORK [NETWORK...]", Aliases: []string{"remove"}, @@ -22,7 +22,7 @@ func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { } } -func runRemove(dockerCli *client.DockerCli, networks []string) error { +func runRemove(dockerCli *command.DockerCli, networks []string) error { client := dockerCli.Client() ctx := context.Background() status := 0 diff --git a/api/client/node/cmd.go b/cli/command/node/cmd.go similarity index 91% rename from api/client/node/cmd.go rename to cli/command/node/cmd.go index 961460727b..6aa4dfcb18 100644 --- a/api/client/node/cmd.go +++ b/cli/command/node/cmd.go @@ -3,15 +3,15 @@ package node import ( "fmt" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" apiclient "github.com/docker/docker/client" "github.com/spf13/cobra" "golang.org/x/net/context" ) // NewNodeCommand returns a cobra command for `node` subcommands -func NewNodeCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewNodeCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "node", Short: "Manage Docker Swarm nodes", diff --git a/api/client/node/demote.go b/cli/command/node/demote.go similarity index 82% rename from api/client/node/demote.go rename to cli/command/node/demote.go index 900648cfef..33f86c6499 100644 --- a/api/client/node/demote.go +++ b/cli/command/node/demote.go @@ -3,13 +3,13 @@ package node import ( "fmt" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) -func newDemoteCommand(dockerCli *client.DockerCli) *cobra.Command { +func newDemoteCommand(dockerCli *command.DockerCli) *cobra.Command { return &cobra.Command{ Use: "demote NODE [NODE...]", Short: "Demote one or more nodes from manager in the swarm", @@ -20,7 +20,7 @@ func newDemoteCommand(dockerCli *client.DockerCli) *cobra.Command { } } -func runDemote(dockerCli *client.DockerCli, nodes []string) error { +func runDemote(dockerCli *command.DockerCli, nodes []string) error { demote := func(node *swarm.Node) error { if node.Spec.Role == swarm.NodeRoleWorker { fmt.Fprintf(dockerCli.Out(), "Node %s is already a worker.\n", node.ID) diff --git a/api/client/node/inspect.go b/cli/command/node/inspect.go similarity index 84% rename from api/client/node/inspect.go rename to cli/command/node/inspect.go index 2eed901ce2..c73b83a87c 100644 --- a/api/client/node/inspect.go +++ b/cli/command/node/inspect.go @@ -6,10 +6,10 @@ import ( "sort" "strings" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/inspect" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/inspect" "github.com/docker/docker/pkg/ioutils" "github.com/docker/go-units" "github.com/spf13/cobra" @@ -22,7 +22,7 @@ type inspectOptions struct { pretty bool } -func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command { +func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { var opts inspectOptions cmd := &cobra.Command{ @@ -41,7 +41,7 @@ func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error { +func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() getRef := func(ref string) (interface{}, []byte, error) { @@ -90,16 +90,16 @@ func printNode(out io.Writer, node swarm.Node) { } ioutils.FprintfIfNotEmpty(out, "Hostname:\t\t%s\n", node.Description.Hostname) - fmt.Fprintf(out, "Joined at:\t\t%s\n", client.PrettyPrint(node.CreatedAt)) + fmt.Fprintf(out, "Joined at:\t\t%s\n", command.PrettyPrint(node.CreatedAt)) fmt.Fprintln(out, "Status:") - fmt.Fprintf(out, " State:\t\t\t%s\n", client.PrettyPrint(node.Status.State)) - ioutils.FprintfIfNotEmpty(out, " Message:\t\t%s\n", client.PrettyPrint(node.Status.Message)) - fmt.Fprintf(out, " Availability:\t\t%s\n", client.PrettyPrint(node.Spec.Availability)) + fmt.Fprintf(out, " State:\t\t\t%s\n", command.PrettyPrint(node.Status.State)) + ioutils.FprintfIfNotEmpty(out, " Message:\t\t%s\n", command.PrettyPrint(node.Status.Message)) + fmt.Fprintf(out, " Availability:\t\t%s\n", command.PrettyPrint(node.Spec.Availability)) if node.ManagerStatus != nil { fmt.Fprintln(out, "Manager Status:") fmt.Fprintf(out, " Address:\t\t%s\n", node.ManagerStatus.Addr) - fmt.Fprintf(out, " Raft Status:\t\t%s\n", client.PrettyPrint(node.ManagerStatus.Reachability)) + fmt.Fprintf(out, " Raft Status:\t\t%s\n", command.PrettyPrint(node.ManagerStatus.Reachability)) leader := "No" if node.ManagerStatus.Leader { leader = "Yes" diff --git a/api/client/node/list.go b/cli/command/node/list.go similarity index 87% rename from api/client/node/list.go rename to cli/command/node/list.go index 02c1727606..bed4bc4965 100644 --- a/api/client/node/list.go +++ b/cli/command/node/list.go @@ -7,10 +7,10 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/opts" "github.com/spf13/cobra" ) @@ -24,7 +24,7 @@ type listOptions struct { filter opts.FilterOpt } -func newListCommand(dockerCli *client.DockerCli) *cobra.Command { +func newListCommand(dockerCli *command.DockerCli) *cobra.Command { opts := listOptions{filter: opts.NewFilterOpt()} cmd := &cobra.Command{ @@ -43,7 +43,7 @@ func newListCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runList(dockerCli *client.DockerCli, opts listOptions) error { +func runList(dockerCli *command.DockerCli, opts listOptions) error { client := dockerCli.Client() ctx := context.Background() @@ -98,9 +98,9 @@ func printTable(out io.Writer, nodes []swarm.Node, info types.Info) { listItemFmt, ID, name, - client.PrettyPrint(string(node.Status.State)), - client.PrettyPrint(availability), - client.PrettyPrint(reachability)) + command.PrettyPrint(string(node.Status.State)), + command.PrettyPrint(availability), + command.PrettyPrint(reachability)) } } diff --git a/api/client/node/opts.go b/cli/command/node/opts.go similarity index 100% rename from api/client/node/opts.go rename to cli/command/node/opts.go diff --git a/api/client/node/promote.go b/cli/command/node/promote.go similarity index 82% rename from api/client/node/promote.go rename to cli/command/node/promote.go index 19c35e4c64..f47d783f4c 100644 --- a/api/client/node/promote.go +++ b/cli/command/node/promote.go @@ -3,13 +3,13 @@ package node import ( "fmt" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) -func newPromoteCommand(dockerCli *client.DockerCli) *cobra.Command { +func newPromoteCommand(dockerCli *command.DockerCli) *cobra.Command { return &cobra.Command{ Use: "promote NODE [NODE...]", Short: "Promote one or more nodes to manager in the swarm", @@ -20,7 +20,7 @@ func newPromoteCommand(dockerCli *client.DockerCli) *cobra.Command { } } -func runPromote(dockerCli *client.DockerCli, nodes []string) error { +func runPromote(dockerCli *command.DockerCli, nodes []string) error { promote := func(node *swarm.Node) error { if node.Spec.Role == swarm.NodeRoleManager { fmt.Fprintf(dockerCli.Out(), "Node %s is already a manager.\n", node.ID) diff --git a/api/client/node/ps.go b/cli/command/node/ps.go similarity index 84% rename from api/client/node/ps.go rename to cli/command/node/ps.go index 4565ce70d7..84d4b375ac 100644 --- a/api/client/node/ps.go +++ b/cli/command/node/ps.go @@ -1,11 +1,11 @@ package node import ( - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/idresolver" - "github.com/docker/docker/api/client/task" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/idresolver" + "github.com/docker/docker/cli/command/task" "github.com/docker/docker/opts" "github.com/spf13/cobra" "golang.org/x/net/context" @@ -18,7 +18,7 @@ type psOptions struct { filter opts.FilterOpt } -func newPsCommand(dockerCli *client.DockerCli) *cobra.Command { +func newPsCommand(dockerCli *command.DockerCli) *cobra.Command { opts := psOptions{filter: opts.NewFilterOpt()} cmd := &cobra.Command{ @@ -43,7 +43,7 @@ func newPsCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runPs(dockerCli *client.DockerCli, opts psOptions) error { +func runPs(dockerCli *command.DockerCli, opts psOptions) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/node/remove.go b/cli/command/node/remove.go similarity index 82% rename from api/client/node/remove.go rename to cli/command/node/remove.go index 18af6a6154..696cd58716 100644 --- a/api/client/node/remove.go +++ b/cli/command/node/remove.go @@ -5,9 +5,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -15,7 +15,7 @@ type removeOptions struct { force bool } -func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { +func newRemoveCommand(dockerCli *command.DockerCli) *cobra.Command { opts := removeOptions{} cmd := &cobra.Command{ @@ -32,7 +32,7 @@ func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runRemove(dockerCli *client.DockerCli, args []string, opts removeOptions) error { +func runRemove(dockerCli *command.DockerCli, args []string, opts removeOptions) error { client := dockerCli.Client() ctx := context.Background() for _, nodeID := range args { diff --git a/api/client/node/update.go b/cli/command/node/update.go similarity index 89% rename from api/client/node/update.go rename to cli/command/node/update.go index 9032250089..65339e138b 100644 --- a/api/client/node/update.go +++ b/cli/command/node/update.go @@ -4,9 +4,9 @@ import ( "errors" "fmt" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/opts" runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/spf13/cobra" @@ -18,7 +18,7 @@ var ( errNoRoleChange = errors.New("role was already set to the requested value") ) -func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command { +func newUpdateCommand(dockerCli *command.DockerCli) *cobra.Command { nodeOpts := newNodeOptions() cmd := &cobra.Command{ @@ -39,14 +39,14 @@ func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runUpdate(dockerCli *client.DockerCli, flags *pflag.FlagSet, nodeID string) error { +func runUpdate(dockerCli *command.DockerCli, flags *pflag.FlagSet, nodeID string) error { success := func(_ string) { fmt.Fprintln(dockerCli.Out(), nodeID) } return updateNodes(dockerCli, []string{nodeID}, mergeNodeUpdate(flags), success) } -func updateNodes(dockerCli *client.DockerCli, nodes []string, mergeNode func(node *swarm.Node) error, success func(nodeID string)) error { +func updateNodes(dockerCli *command.DockerCli, nodes []string, mergeNode func(node *swarm.Node) error, success func(nodeID string)) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/out.go b/cli/command/out.go similarity index 98% rename from api/client/out.go rename to cli/command/out.go index e8b38e4b3f..09375d07d7 100644 --- a/api/client/out.go +++ b/cli/command/out.go @@ -1,4 +1,4 @@ -package client +package command import ( "io" diff --git a/api/client/plugin/cmd.go b/cli/command/plugin/cmd.go similarity index 56% rename from api/client/plugin/cmd.go rename to cli/command/plugin/cmd.go index f9ecc519f0..67d0d5031c 100644 --- a/api/client/plugin/cmd.go +++ b/cli/command/plugin/cmd.go @@ -3,10 +3,10 @@ package plugin import ( - "github.com/docker/docker/api/client" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) // NewPluginCommand returns a cobra command for `plugin` subcommands -func NewPluginCommand(cmd *cobra.Command, dockerCli *client.DockerCli) { +func NewPluginCommand(cmd *cobra.Command, dockerCli *command.DockerCli) { } diff --git a/api/client/plugin/cmd_experimental.go b/cli/command/plugin/cmd_experimental.go similarity index 100% rename from api/client/plugin/cmd_experimental.go rename to cli/command/plugin/cmd_experimental.go diff --git a/api/client/plugin/disable.go b/cli/command/plugin/disable.go similarity index 100% rename from api/client/plugin/disable.go rename to cli/command/plugin/disable.go diff --git a/api/client/plugin/enable.go b/cli/command/plugin/enable.go similarity index 100% rename from api/client/plugin/enable.go rename to cli/command/plugin/enable.go diff --git a/api/client/plugin/inspect.go b/cli/command/plugin/inspect.go similarity index 100% rename from api/client/plugin/inspect.go rename to cli/command/plugin/inspect.go diff --git a/api/client/plugin/install.go b/cli/command/plugin/install.go similarity index 100% rename from api/client/plugin/install.go rename to cli/command/plugin/install.go diff --git a/api/client/plugin/list.go b/cli/command/plugin/list.go similarity index 100% rename from api/client/plugin/list.go rename to cli/command/plugin/list.go diff --git a/api/client/plugin/push.go b/cli/command/plugin/push.go similarity index 100% rename from api/client/plugin/push.go rename to cli/command/plugin/push.go diff --git a/api/client/plugin/remove.go b/cli/command/plugin/remove.go similarity index 100% rename from api/client/plugin/remove.go rename to cli/command/plugin/remove.go diff --git a/api/client/plugin/set.go b/cli/command/plugin/set.go similarity index 100% rename from api/client/plugin/set.go rename to cli/command/plugin/set.go diff --git a/api/client/registry.go b/cli/command/registry.go similarity index 99% rename from api/client/registry.go rename to cli/command/registry.go index 634a8b1b94..4f72afa4a1 100644 --- a/api/client/registry.go +++ b/cli/command/registry.go @@ -1,4 +1,4 @@ -package client +package command import ( "bufio" diff --git a/api/client/registry/login.go b/cli/command/registry/login.go similarity index 87% rename from api/client/registry/login.go rename to cli/command/registry/login.go index ffcdb96bea..dccf538474 100644 --- a/api/client/registry/login.go +++ b/cli/command/registry/login.go @@ -5,8 +5,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -18,7 +18,7 @@ type loginOptions struct { } // NewLoginCommand creates a new `docker login` command -func NewLoginCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewLoginCommand(dockerCli *command.DockerCli) *cobra.Command { var opts loginOptions cmd := &cobra.Command{ @@ -46,7 +46,7 @@ func NewLoginCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runLogin(dockerCli *client.DockerCli, opts loginOptions) error { +func runLogin(dockerCli *command.DockerCli, opts loginOptions) error { ctx := context.Background() clnt := dockerCli.Client() @@ -74,7 +74,7 @@ func runLogin(dockerCli *client.DockerCli, opts loginOptions) error { authConfig.Password = "" authConfig.IdentityToken = response.IdentityToken } - if err := client.StoreCredentials(dockerCli.ConfigFile(), authConfig); err != nil { + if err := command.StoreCredentials(dockerCli.ConfigFile(), authConfig); err != nil { return fmt.Errorf("Error saving credentials: %v", err) } diff --git a/api/client/registry/logout.go b/cli/command/registry/logout.go similarity index 88% rename from api/client/registry/logout.go rename to cli/command/registry/logout.go index 55e2ecd079..1e0c5170a6 100644 --- a/api/client/registry/logout.go +++ b/cli/command/registry/logout.go @@ -5,14 +5,14 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/registry" "github.com/spf13/cobra" ) // NewLogoutCommand creates a new `docker login` command -func NewLogoutCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewLogoutCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "logout [SERVER]", Short: "Log out from a Docker registry.", @@ -30,7 +30,7 @@ func NewLogoutCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runLogout(dockerCli *client.DockerCli, serverAddress string) error { +func runLogout(dockerCli *command.DockerCli, serverAddress string) error { ctx := context.Background() var isDefaultRegistry bool @@ -68,7 +68,7 @@ func runLogout(dockerCli *client.DockerCli, serverAddress string) error { fmt.Fprintf(dockerCli.Out(), "Removing login credentials for %s\n", hostnameAddress) for _, r := range regsToLogout { - if err := client.EraseCredentials(dockerCli.ConfigFile(), r); err != nil { + if err := command.EraseCredentials(dockerCli.ConfigFile(), r); err != nil { fmt.Fprintf(dockerCli.Err(), "WARNING: could not erase credentials: %v\n", err) } } diff --git a/api/client/service/cmd.go b/cli/command/service/cmd.go similarity index 85% rename from api/client/service/cmd.go rename to cli/command/service/cmd.go index 18a0ff6669..282ce2b4b9 100644 --- a/api/client/service/cmd.go +++ b/cli/command/service/cmd.go @@ -5,12 +5,12 @@ import ( "github.com/spf13/cobra" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" ) // NewServiceCommand returns a cobra command for `service` subcommands -func NewServiceCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewServiceCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "service", Short: "Manage Docker services", diff --git a/api/client/service/create.go b/cli/command/service/create.go similarity index 90% rename from api/client/service/create.go rename to cli/command/service/create.go index 740d6dfdd0..4ec8835b37 100644 --- a/api/client/service/create.go +++ b/cli/command/service/create.go @@ -3,14 +3,14 @@ package service import ( "fmt" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" "golang.org/x/net/context" ) -func newCreateCommand(dockerCli *client.DockerCli) *cobra.Command { +func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command { opts := newServiceOptions() cmd := &cobra.Command{ @@ -41,7 +41,7 @@ func newCreateCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runCreate(dockerCli *client.DockerCli, opts *serviceOptions) error { +func runCreate(dockerCli *command.DockerCli, opts *serviceOptions) error { apiClient := dockerCli.Client() createOpts := types.ServiceCreateOptions{} diff --git a/api/client/service/inspect.go b/cli/command/service/inspect.go similarity index 96% rename from api/client/service/inspect.go rename to cli/command/service/inspect.go index 4a3e709c40..8facb1f28b 100644 --- a/api/client/service/inspect.go +++ b/cli/command/service/inspect.go @@ -8,10 +8,10 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/inspect" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/inspect" apiclient "github.com/docker/docker/client" "github.com/docker/docker/pkg/ioutils" "github.com/docker/go-units" @@ -24,7 +24,7 @@ type inspectOptions struct { pretty bool } -func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command { +func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { var opts inspectOptions cmd := &cobra.Command{ @@ -47,7 +47,7 @@ func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error { +func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/service/inspect_test.go b/cli/command/service/inspect_test.go similarity index 100% rename from api/client/service/inspect_test.go rename to cli/command/service/inspect_test.go diff --git a/api/client/service/list.go b/cli/command/service/list.go similarity index 94% rename from api/client/service/list.go rename to cli/command/service/list.go index 625dfc1df0..681acd3f25 100644 --- a/api/client/service/list.go +++ b/cli/command/service/list.go @@ -6,11 +6,11 @@ import ( "strings" "text/tabwriter" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/stringid" "github.com/spf13/cobra" @@ -26,7 +26,7 @@ type listOptions struct { filter opts.FilterOpt } -func newListCommand(dockerCli *client.DockerCli) *cobra.Command { +func newListCommand(dockerCli *command.DockerCli) *cobra.Command { opts := listOptions{filter: opts.NewFilterOpt()} cmd := &cobra.Command{ @@ -46,7 +46,7 @@ func newListCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runList(dockerCli *client.DockerCli, opts listOptions) error { +func runList(dockerCli *command.DockerCli, opts listOptions) error { ctx := context.Background() client := dockerCli.Client() diff --git a/api/client/service/opts.go b/cli/command/service/opts.go similarity index 100% rename from api/client/service/opts.go rename to cli/command/service/opts.go diff --git a/api/client/service/opts_test.go b/cli/command/service/opts_test.go similarity index 100% rename from api/client/service/opts_test.go rename to cli/command/service/opts_test.go diff --git a/api/client/service/ps.go b/cli/command/service/ps.go similarity index 83% rename from api/client/service/ps.go rename to cli/command/service/ps.go index e9f3f0ba67..23c3679d7a 100644 --- a/api/client/service/ps.go +++ b/cli/command/service/ps.go @@ -1,12 +1,12 @@ package service import ( - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/idresolver" - "github.com/docker/docker/api/client/node" - "github.com/docker/docker/api/client/task" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/idresolver" + "github.com/docker/docker/cli/command/node" + "github.com/docker/docker/cli/command/task" "github.com/docker/docker/opts" "github.com/spf13/cobra" "golang.org/x/net/context" @@ -19,7 +19,7 @@ type psOptions struct { filter opts.FilterOpt } -func newPsCommand(dockerCli *client.DockerCli) *cobra.Command { +func newPsCommand(dockerCli *command.DockerCli) *cobra.Command { opts := psOptions{filter: opts.NewFilterOpt()} cmd := &cobra.Command{ @@ -39,7 +39,7 @@ func newPsCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runPS(dockerCli *client.DockerCli, opts psOptions) error { +func runPS(dockerCli *command.DockerCli, opts psOptions) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/service/remove.go b/cli/command/service/remove.go similarity index 81% rename from api/client/service/remove.go rename to cli/command/service/remove.go index 6236e43dcb..c3fbbabbca 100644 --- a/api/client/service/remove.go +++ b/cli/command/service/remove.go @@ -4,13 +4,13 @@ import ( "fmt" "strings" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" "golang.org/x/net/context" ) -func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { +func newRemoveCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "rm SERVICE [SERVICE...]", @@ -26,7 +26,7 @@ func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runRemove(dockerCli *client.DockerCli, sids []string) error { +func runRemove(dockerCli *command.DockerCli, sids []string) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/service/scale.go b/cli/command/service/scale.go similarity index 88% rename from api/client/service/scale.go rename to cli/command/service/scale.go index edd43123a3..2e2982db43 100644 --- a/api/client/service/scale.go +++ b/cli/command/service/scale.go @@ -7,13 +7,13 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) -func newScaleCommand(dockerCli *client.DockerCli) *cobra.Command { +func newScaleCommand(dockerCli *command.DockerCli) *cobra.Command { return &cobra.Command{ Use: "scale SERVICE=REPLICAS [SERVICE=REPLICAS...]", Short: "Scale one or multiple services", @@ -42,7 +42,7 @@ func scaleArgs(cmd *cobra.Command, args []string) error { return nil } -func runScale(dockerCli *client.DockerCli, args []string) error { +func runScale(dockerCli *command.DockerCli, args []string) error { var errors []string for _, arg := range args { parts := strings.SplitN(arg, "=", 2) @@ -58,7 +58,7 @@ func runScale(dockerCli *client.DockerCli, args []string) error { return fmt.Errorf(strings.Join(errors, "\n")) } -func runServiceScale(dockerCli *client.DockerCli, serviceID string, scale string) error { +func runServiceScale(dockerCli *command.DockerCli, serviceID string, scale string) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/service/update.go b/cli/command/service/update.go similarity index 98% rename from api/client/service/update.go rename to cli/command/service/update.go index 0bc9c25f04..a86f20e585 100644 --- a/api/client/service/update.go +++ b/cli/command/service/update.go @@ -8,11 +8,11 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" mounttypes "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/opts" runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/docker/go-connections/nat" @@ -21,7 +21,7 @@ import ( "github.com/spf13/pflag" ) -func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command { +func newUpdateCommand(dockerCli *command.DockerCli) *cobra.Command { opts := newServiceOptions() cmd := &cobra.Command{ @@ -58,7 +58,7 @@ func newListOptsVar() *opts.ListOpts { return opts.NewListOptsRef(&[]string{}, nil) } -func runUpdate(dockerCli *client.DockerCli, flags *pflag.FlagSet, serviceID string) error { +func runUpdate(dockerCli *command.DockerCli, flags *pflag.FlagSet, serviceID string) error { apiClient := dockerCli.Client() ctx := context.Background() updateOpts := types.ServiceUpdateOptions{} diff --git a/api/client/service/update_test.go b/cli/command/service/update_test.go similarity index 100% rename from api/client/service/update_test.go rename to cli/command/service/update_test.go diff --git a/api/client/stack/cmd.go b/cli/command/stack/cmd.go similarity index 100% rename from api/client/stack/cmd.go rename to cli/command/stack/cmd.go diff --git a/api/client/stack/cmd_stub.go b/cli/command/stack/cmd_stub.go similarity index 54% rename from api/client/stack/cmd_stub.go rename to cli/command/stack/cmd_stub.go index 0efc56300b..51cb2d1bcf 100644 --- a/api/client/stack/cmd_stub.go +++ b/cli/command/stack/cmd_stub.go @@ -3,16 +3,16 @@ package stack import ( - "github.com/docker/docker/api/client" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) // NewStackCommand returns no command -func NewStackCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewStackCommand(dockerCli *command.DockerCli) *cobra.Command { return &cobra.Command{} } // NewTopLevelDeployCommand returns no command -func NewTopLevelDeployCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewTopLevelDeployCommand(dockerCli *command.DockerCli) *cobra.Command { return &cobra.Command{} } diff --git a/api/client/stack/common.go b/cli/command/stack/common.go similarity index 100% rename from api/client/stack/common.go rename to cli/command/stack/common.go diff --git a/api/client/stack/config.go b/cli/command/stack/config.go similarity index 100% rename from api/client/stack/config.go rename to cli/command/stack/config.go diff --git a/api/client/stack/deploy.go b/cli/command/stack/deploy.go similarity index 100% rename from api/client/stack/deploy.go rename to cli/command/stack/deploy.go diff --git a/api/client/stack/opts.go b/cli/command/stack/opts.go similarity index 100% rename from api/client/stack/opts.go rename to cli/command/stack/opts.go diff --git a/api/client/stack/ps.go b/cli/command/stack/ps.go similarity index 100% rename from api/client/stack/ps.go rename to cli/command/stack/ps.go diff --git a/api/client/stack/remove.go b/cli/command/stack/remove.go similarity index 100% rename from api/client/stack/remove.go rename to cli/command/stack/remove.go diff --git a/api/client/stack/services.go b/cli/command/stack/services.go similarity index 100% rename from api/client/stack/services.go rename to cli/command/stack/services.go diff --git a/api/client/swarm/cmd.go b/cli/command/swarm/cmd.go similarity index 83% rename from api/client/swarm/cmd.go rename to cli/command/swarm/cmd.go index 37b035b495..db2b6a2530 100644 --- a/api/client/swarm/cmd.go +++ b/cli/command/swarm/cmd.go @@ -5,12 +5,12 @@ import ( "github.com/spf13/cobra" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" ) // NewSwarmCommand returns a cobra command for `swarm` subcommands -func NewSwarmCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewSwarmCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "swarm", Short: "Manage Docker Swarm", diff --git a/api/client/swarm/init.go b/cli/command/swarm/init.go similarity index 91% rename from api/client/swarm/init.go rename to cli/command/swarm/init.go index cb23fb6824..9a17224bde 100644 --- a/api/client/swarm/init.go +++ b/cli/command/swarm/init.go @@ -7,9 +7,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -29,7 +29,7 @@ type initOptions struct { forceNewCluster bool } -func newInitCommand(dockerCli *client.DockerCli) *cobra.Command { +func newInitCommand(dockerCli *command.DockerCli) *cobra.Command { opts := initOptions{ listenAddr: NewListenAddrOption(), } @@ -51,7 +51,7 @@ func newInitCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runInit(dockerCli *client.DockerCli, flags *pflag.FlagSet, opts initOptions) error { +func runInit(dockerCli *command.DockerCli, flags *pflag.FlagSet, opts initOptions) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/swarm/join.go b/cli/command/swarm/join.go similarity index 90% rename from api/client/swarm/join.go rename to cli/command/swarm/join.go index fc8fb10b6c..72f97c015e 100644 --- a/api/client/swarm/join.go +++ b/cli/command/swarm/join.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" "golang.org/x/net/context" ) @@ -19,7 +19,7 @@ type joinOptions struct { token string } -func newJoinCommand(dockerCli *client.DockerCli) *cobra.Command { +func newJoinCommand(dockerCli *command.DockerCli) *cobra.Command { opts := joinOptions{ listenAddr: NewListenAddrOption(), } @@ -41,7 +41,7 @@ func newJoinCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runJoin(dockerCli *client.DockerCli, opts joinOptions) error { +func runJoin(dockerCli *command.DockerCli, opts joinOptions) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/swarm/join_token.go b/cli/command/swarm/join_token.go similarity index 90% rename from api/client/swarm/join_token.go rename to cli/command/swarm/join_token.go index 803f360fa2..b411202083 100644 --- a/api/client/swarm/join_token.go +++ b/cli/command/swarm/join_token.go @@ -6,13 +6,13 @@ import ( "github.com/spf13/cobra" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "golang.org/x/net/context" ) -func newJoinTokenCommand(dockerCli *client.DockerCli) *cobra.Command { +func newJoinTokenCommand(dockerCli *command.DockerCli) *cobra.Command { var rotate, quiet bool cmd := &cobra.Command{ @@ -79,7 +79,7 @@ func newJoinTokenCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func printJoinCommand(ctx context.Context, dockerCli *client.DockerCli, nodeID string, worker bool, manager bool) error { +func printJoinCommand(ctx context.Context, dockerCli *command.DockerCli, nodeID string, worker bool, manager bool) error { client := dockerCli.Client() swarm, err := client.SwarmInspect(ctx) diff --git a/api/client/swarm/leave.go b/cli/command/swarm/leave.go similarity index 79% rename from api/client/swarm/leave.go rename to cli/command/swarm/leave.go index acaa7c82c1..9224113409 100644 --- a/api/client/swarm/leave.go +++ b/cli/command/swarm/leave.go @@ -5,8 +5,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -14,7 +14,7 @@ type leaveOptions struct { force bool } -func newLeaveCommand(dockerCli *client.DockerCli) *cobra.Command { +func newLeaveCommand(dockerCli *command.DockerCli) *cobra.Command { opts := leaveOptions{} cmd := &cobra.Command{ @@ -31,7 +31,7 @@ func newLeaveCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runLeave(dockerCli *client.DockerCli, opts leaveOptions) error { +func runLeave(dockerCli *command.DockerCli, opts leaveOptions) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/swarm/opts.go b/cli/command/swarm/opts.go similarity index 100% rename from api/client/swarm/opts.go rename to cli/command/swarm/opts.go diff --git a/api/client/swarm/opts_test.go b/cli/command/swarm/opts_test.go similarity index 100% rename from api/client/swarm/opts_test.go rename to cli/command/swarm/opts_test.go diff --git a/api/client/swarm/update.go b/cli/command/swarm/update.go similarity index 88% rename from api/client/swarm/update.go rename to cli/command/swarm/update.go index ce9f34df37..9884b79169 100644 --- a/api/client/swarm/update.go +++ b/cli/command/swarm/update.go @@ -5,14 +5,14 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" "github.com/spf13/pflag" ) -func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command { +func newUpdateCommand(dockerCli *command.DockerCli) *cobra.Command { opts := swarmOptions{} cmd := &cobra.Command{ @@ -28,7 +28,7 @@ func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runUpdate(dockerCli *client.DockerCli, flags *pflag.FlagSet, opts swarmOptions) error { +func runUpdate(dockerCli *command.DockerCli, flags *pflag.FlagSet, opts swarmOptions) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/system/events.go b/cli/command/system/events.go similarity index 94% rename from api/client/system/events.go rename to cli/command/system/events.go index 9258995174..456e81b4ce 100644 --- a/api/client/system/events.go +++ b/cli/command/system/events.go @@ -9,11 +9,11 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" eventtypes "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/jsonlog" "github.com/spf13/cobra" ) @@ -25,7 +25,7 @@ type eventsOptions struct { } // NewEventsCommand creates a new cobra.Command for `docker events` -func NewEventsCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewEventsCommand(dockerCli *command.DockerCli) *cobra.Command { var opts eventsOptions cmd := &cobra.Command{ @@ -45,7 +45,7 @@ func NewEventsCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runEvents(dockerCli *client.DockerCli, opts *eventsOptions) error { +func runEvents(dockerCli *command.DockerCli, opts *eventsOptions) error { eventFilterArgs := filters.NewArgs() // Consolidate all filter flags, and sanity check them early. diff --git a/api/client/system/events_utils.go b/cli/command/system/events_utils.go similarity index 100% rename from api/client/system/events_utils.go rename to cli/command/system/events_utils.go diff --git a/api/client/system/info.go b/cli/command/system/info.go similarity index 96% rename from api/client/system/info.go rename to cli/command/system/info.go index b08d14ce63..259b254bd0 100644 --- a/api/client/system/info.go +++ b/cli/command/system/info.go @@ -7,10 +7,10 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/utils" "github.com/docker/docker/utils/templates" @@ -23,7 +23,7 @@ type infoOptions struct { } // NewInfoCommand creates a new cobra.Command for `docker info` -func NewInfoCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewInfoCommand(dockerCli *command.DockerCli) *cobra.Command { var opts infoOptions cmd := &cobra.Command{ @@ -42,7 +42,7 @@ func NewInfoCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runInfo(dockerCli *client.DockerCli, opts *infoOptions) error { +func runInfo(dockerCli *command.DockerCli, opts *infoOptions) error { ctx := context.Background() info, err := dockerCli.Client().Info(ctx) if err != nil { @@ -54,7 +54,7 @@ func runInfo(dockerCli *client.DockerCli, opts *infoOptions) error { return formatInfo(dockerCli, info, opts.format) } -func prettyPrintInfo(dockerCli *client.DockerCli, info types.Info) error { +func prettyPrintInfo(dockerCli *command.DockerCli, info types.Info) error { fmt.Fprintf(dockerCli.Out(), "Containers: %d\n", info.Containers) fmt.Fprintf(dockerCli.Out(), " Running: %d\n", info.ContainersRunning) fmt.Fprintf(dockerCli.Out(), " Paused: %d\n", info.ContainersPaused) @@ -249,7 +249,7 @@ func prettyPrintInfo(dockerCli *client.DockerCli, info types.Info) error { return nil } -func formatInfo(dockerCli *client.DockerCli, info types.Info, format string) error { +func formatInfo(dockerCli *command.DockerCli, info types.Info, format string) error { tmpl, err := templates.Parse(format) if err != nil { return cli.StatusError{StatusCode: 64, diff --git a/api/client/system/inspect.go b/cli/command/system/inspect.go similarity index 80% rename from api/client/system/inspect.go rename to cli/command/system/inspect.go index cf5b60db99..e4f67cf643 100644 --- a/api/client/system/inspect.go +++ b/cli/command/system/inspect.go @@ -6,9 +6,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/inspect" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/inspect" apiclient "github.com/docker/docker/client" "github.com/spf13/cobra" ) @@ -21,7 +21,7 @@ type inspectOptions struct { } // NewInspectCommand creates a new cobra.Command for `docker inspect` -func NewInspectCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewInspectCommand(dockerCli *command.DockerCli) *cobra.Command { var opts inspectOptions cmd := &cobra.Command{ @@ -42,7 +42,7 @@ func NewInspectCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error { +func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { var elementSearcher inspect.GetRefFunc switch opts.inspectType { case "", "container", "image", "node", "network", "service", "volume", "task": @@ -53,49 +53,49 @@ func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error { return inspect.Inspect(dockerCli.Out(), opts.ids, opts.format, elementSearcher) } -func inspectContainers(ctx context.Context, dockerCli *client.DockerCli, getSize bool) inspect.GetRefFunc { +func inspectContainers(ctx context.Context, dockerCli *command.DockerCli, getSize bool) inspect.GetRefFunc { return func(ref string) (interface{}, []byte, error) { return dockerCli.Client().ContainerInspectWithRaw(ctx, ref, getSize) } } -func inspectImages(ctx context.Context, dockerCli *client.DockerCli) inspect.GetRefFunc { +func inspectImages(ctx context.Context, dockerCli *command.DockerCli) inspect.GetRefFunc { return func(ref string) (interface{}, []byte, error) { return dockerCli.Client().ImageInspectWithRaw(ctx, ref) } } -func inspectNetwork(ctx context.Context, dockerCli *client.DockerCli) inspect.GetRefFunc { +func inspectNetwork(ctx context.Context, dockerCli *command.DockerCli) inspect.GetRefFunc { return func(ref string) (interface{}, []byte, error) { return dockerCli.Client().NetworkInspectWithRaw(ctx, ref) } } -func inspectNode(ctx context.Context, dockerCli *client.DockerCli) inspect.GetRefFunc { +func inspectNode(ctx context.Context, dockerCli *command.DockerCli) inspect.GetRefFunc { return func(ref string) (interface{}, []byte, error) { return dockerCli.Client().NodeInspectWithRaw(ctx, ref) } } -func inspectService(ctx context.Context, dockerCli *client.DockerCli) inspect.GetRefFunc { +func inspectService(ctx context.Context, dockerCli *command.DockerCli) inspect.GetRefFunc { return func(ref string) (interface{}, []byte, error) { return dockerCli.Client().ServiceInspectWithRaw(ctx, ref) } } -func inspectTasks(ctx context.Context, dockerCli *client.DockerCli) inspect.GetRefFunc { +func inspectTasks(ctx context.Context, dockerCli *command.DockerCli) inspect.GetRefFunc { return func(ref string) (interface{}, []byte, error) { return dockerCli.Client().TaskInspectWithRaw(ctx, ref) } } -func inspectVolume(ctx context.Context, dockerCli *client.DockerCli) inspect.GetRefFunc { +func inspectVolume(ctx context.Context, dockerCli *command.DockerCli) inspect.GetRefFunc { return func(ref string) (interface{}, []byte, error) { return dockerCli.Client().VolumeInspectWithRaw(ctx, ref) } } -func inspectAll(ctx context.Context, dockerCli *client.DockerCli, getSize bool, typeConstraint string) inspect.GetRefFunc { +func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool, typeConstraint string) inspect.GetRefFunc { var inspectAutodetect = []struct { ObjectType string IsSizeSupported bool diff --git a/api/client/system/version.go b/cli/command/system/version.go similarity index 93% rename from api/client/system/version.go rename to cli/command/system/version.go index a4cabd6b76..e77719ec3b 100644 --- a/api/client/system/version.go +++ b/cli/command/system/version.go @@ -6,9 +6,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/dockerversion" "github.com/docker/docker/utils" "github.com/docker/docker/utils/templates" @@ -38,7 +38,7 @@ type versionOptions struct { } // NewVersionCommand creates a new cobra.Command for `docker version` -func NewVersionCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewVersionCommand(dockerCli *command.DockerCli) *cobra.Command { var opts versionOptions cmd := &cobra.Command{ @@ -57,7 +57,7 @@ func NewVersionCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runVersion(dockerCli *client.DockerCli, opts *versionOptions) error { +func runVersion(dockerCli *command.DockerCli, opts *versionOptions) error { ctx := context.Background() templateFormat := versionTemplate diff --git a/api/client/task/print.go b/cli/command/task/print.go similarity index 86% rename from api/client/task/print.go rename to cli/command/task/print.go index ef7732ccc6..963aea95ce 100644 --- a/api/client/task/print.go +++ b/cli/command/task/print.go @@ -9,9 +9,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/idresolver" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/idresolver" "github.com/docker/go-units" ) @@ -41,7 +41,7 @@ func (t tasksBySlot) Less(i, j int) bool { } // Print task information in a table format -func Print(dockerCli *client.DockerCli, ctx context.Context, tasks []swarm.Task, resolver *idresolver.IDResolver, noTrunc bool) error { +func Print(dockerCli *command.DockerCli, ctx context.Context, tasks []swarm.Task, resolver *idresolver.IDResolver, noTrunc bool) error { sort.Stable(tasksBySlot(tasks)) writer := tabwriter.NewWriter(dockerCli.Out(), 0, 4, 2, ' ', 0) @@ -89,8 +89,8 @@ func Print(dockerCli *client.DockerCli, ctx context.Context, tasks []swarm.Task, indentedName, task.Spec.ContainerSpec.Image, nodeValue, - client.PrettyPrint(task.DesiredState), - client.PrettyPrint(task.Status.State), + command.PrettyPrint(task.DesiredState), + command.PrettyPrint(task.Status.State), strings.ToLower(units.HumanDuration(time.Since(task.Status.Timestamp))), taskErr, ) diff --git a/api/client/trust.go b/cli/command/trust.go similarity index 99% rename from api/client/trust.go rename to cli/command/trust.go index e86a141ece..329da52515 100644 --- a/api/client/trust.go +++ b/cli/command/trust.go @@ -1,4 +1,4 @@ -package client +package command import ( "encoding/hex" diff --git a/api/client/trust_test.go b/cli/command/trust_test.go similarity index 99% rename from api/client/trust_test.go rename to cli/command/trust_test.go index 86f9e61e4d..534815f379 100644 --- a/api/client/trust_test.go +++ b/cli/command/trust_test.go @@ -1,4 +1,4 @@ -package client +package command import ( "os" diff --git a/api/client/utils.go b/cli/command/utils.go similarity index 98% rename from api/client/utils.go rename to cli/command/utils.go index f76f536853..bceb7b335c 100644 --- a/api/client/utils.go +++ b/cli/command/utils.go @@ -1,4 +1,4 @@ -package client +package command import ( "fmt" diff --git a/api/client/volume/cmd.go b/cli/command/volume/cmd.go similarity index 91% rename from api/client/volume/cmd.go rename to cli/command/volume/cmd.go index 7a18a8b64a..090a006439 100644 --- a/api/client/volume/cmd.go +++ b/cli/command/volume/cmd.go @@ -5,12 +5,12 @@ import ( "github.com/spf13/cobra" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" ) // NewVolumeCommand returns a cobra command for `volume` subcommands -func NewVolumeCommand(dockerCli *client.DockerCli) *cobra.Command { +func NewVolumeCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "volume COMMAND", Short: "Manage Docker volumes", diff --git a/api/client/volume/create.go b/cli/command/volume/create.go similarity index 94% rename from api/client/volume/create.go rename to cli/command/volume/create.go index b40f51ace3..4427ff1ea7 100644 --- a/api/client/volume/create.go +++ b/cli/command/volume/create.go @@ -5,9 +5,9 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/docker/docker/opts" runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/spf13/cobra" @@ -20,7 +20,7 @@ type createOptions struct { labels []string } -func newCreateCommand(dockerCli *client.DockerCli) *cobra.Command { +func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command { opts := createOptions{ driverOpts: *opts.NewMapOpts(nil, nil), } @@ -51,7 +51,7 @@ func newCreateCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runCreate(dockerCli *client.DockerCli, opts createOptions) error { +func runCreate(dockerCli *command.DockerCli, opts createOptions) error { client := dockerCli.Client() volReq := types.VolumeCreateRequest{ diff --git a/api/client/volume/inspect.go b/cli/command/volume/inspect.go similarity index 84% rename from api/client/volume/inspect.go rename to cli/command/volume/inspect.go index 7e310a5783..ab06e03807 100644 --- a/api/client/volume/inspect.go +++ b/cli/command/volume/inspect.go @@ -3,9 +3,9 @@ package volume import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/inspect" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/inspect" "github.com/spf13/cobra" ) @@ -14,7 +14,7 @@ type inspectOptions struct { names []string } -func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command { +func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { var opts inspectOptions cmd := &cobra.Command{ @@ -33,7 +33,7 @@ func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error { +func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() diff --git a/api/client/volume/list.go b/cli/command/volume/list.go similarity index 91% rename from api/client/volume/list.go rename to cli/command/volume/list.go index e6f1fb3ae4..75e77f828f 100644 --- a/api/client/volume/list.go +++ b/cli/command/volume/list.go @@ -5,11 +5,11 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/formatter" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/formatter" "github.com/spf13/cobra" ) @@ -27,7 +27,7 @@ type listOptions struct { filter []string } -func newListCommand(dockerCli *client.DockerCli) *cobra.Command { +func newListCommand(dockerCli *command.DockerCli) *cobra.Command { var opts listOptions cmd := &cobra.Command{ @@ -49,7 +49,7 @@ func newListCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runList(dockerCli *client.DockerCli, opts listOptions) error { +func runList(dockerCli *command.DockerCli, opts listOptions) error { client := dockerCli.Client() volFilterArgs := filters.NewArgs() diff --git a/api/client/volume/remove.go b/cli/command/volume/remove.go similarity index 87% rename from api/client/volume/remove.go rename to cli/command/volume/remove.go index d88b54b1f6..213ad26ab5 100644 --- a/api/client/volume/remove.go +++ b/cli/command/volume/remove.go @@ -5,8 +5,8 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) @@ -16,7 +16,7 @@ type removeOptions struct { volumes []string } -func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { +func newRemoveCommand(dockerCli *command.DockerCli) *cobra.Command { var opts removeOptions cmd := &cobra.Command{ @@ -38,7 +38,7 @@ func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { return cmd } -func runRemove(dockerCli *client.DockerCli, opts *removeOptions) error { +func runRemove(dockerCli *command.DockerCli, opts *removeOptions) error { client := dockerCli.Client() ctx := context.Background() status := 0 diff --git a/cmd/docker/docker.go b/cmd/docker/docker.go index 38907970d3..969cd80876 100644 --- a/cmd/docker/docker.go +++ b/cmd/docker/docker.go @@ -5,9 +5,9 @@ import ( "os" "github.com/Sirupsen/logrus" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/command" "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/commands" cliflags "github.com/docker/docker/cli/flags" "github.com/docker/docker/cliconfig" "github.com/docker/docker/dockerversion" @@ -17,7 +17,7 @@ import ( "github.com/spf13/pflag" ) -func newDockerCommand(dockerCli *client.DockerCli) *cobra.Command { +func newDockerCommand(dockerCli *command.DockerCli) *cobra.Command { opts := cliflags.NewClientOptions() var flags *pflag.FlagSet @@ -52,7 +52,7 @@ func newDockerCommand(dockerCli *client.DockerCli) *cobra.Command { cmd.SetOutput(dockerCli.Out()) cmd.AddCommand(newDaemonCommand()) - command.AddCommands(cmd, dockerCli) + commands.AddCommands(cmd, dockerCli) return cmd } @@ -70,7 +70,7 @@ func main() { stdin, stdout, stderr := term.StdStreams() logrus.SetOutput(stderr) - dockerCli := client.NewDockerCli(stdin, stdout, stderr) + dockerCli := command.NewDockerCli(stdin, stdout, stderr) cmd := newDockerCommand(dockerCli) if err := cmd.Execute(); err != nil { diff --git a/cmd/docker/docker_test.go b/cmd/docker/docker_test.go index 72d2311521..47e24eb0da 100644 --- a/cmd/docker/docker_test.go +++ b/cmd/docker/docker_test.go @@ -7,13 +7,13 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/docker/utils" - "github.com/docker/docker/api/client" + "github.com/docker/docker/cli/command" ) func TestClientDebugEnabled(t *testing.T) { defer utils.DisableDebug() - cmd := newDockerCommand(&client.DockerCli{}) + cmd := newDockerCommand(&command.DockerCli{}) cmd.Flags().Set("debug", "true") if err := cmd.PersistentPreRunE(cmd, []string{}); err != nil { diff --git a/man/generate.go b/man/generate.go index cee5a7fdd2..f21614d94a 100644 --- a/man/generate.go +++ b/man/generate.go @@ -4,8 +4,8 @@ import ( "fmt" "os" - "github.com/docker/docker/api/client" - "github.com/docker/docker/api/client/command" + "github.com/docker/docker/cli/command" + "github.com/docker/docker/cli/command/commands" "github.com/docker/docker/pkg/term" "github.com/spf13/cobra" "github.com/spf13/cobra/doc" @@ -19,9 +19,9 @@ func generateManPages(path string) error { } stdin, stdout, stderr := term.StdStreams() - dockerCli := client.NewDockerCli(stdin, stdout, stderr) + dockerCli := command.NewDockerCli(stdin, stdout, stderr) cmd := &cobra.Command{Use: "docker"} - command.AddCommands(cmd, dockerCli) + commands.AddCommands(cmd, dockerCli) cmd.DisableAutoGenTag = true return doc.GenManTreeFromOpts(cmd, doc.GenManTreeOptions{