mirror of https://github.com/docker/cli.git
Remove deprecated "daemon" subcommand
The `docker daemon` subcommand was only present for backward compatibility, but deprecated in v1.13, and scheduled for removal in v17.12 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
365c525fab
commit
c6a3199236
|
@ -1,29 +0,0 @@
|
||||||
// +build !daemon
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func newDaemonCommand() *cobra.Command {
|
|
||||||
return &cobra.Command{
|
|
||||||
Use: "daemon",
|
|
||||||
Hidden: true,
|
|
||||||
Args: cobra.ArbitraryArgs,
|
|
||||||
DisableFlagParsing: true,
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
return runDaemon()
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func runDaemon() error {
|
|
||||||
return fmt.Errorf(
|
|
||||||
"`docker daemon` is not supported on %s. Please run `dockerd` directly",
|
|
||||||
strings.Title(runtime.GOOS))
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
// +build !daemon
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestDaemonCommand(t *testing.T) {
|
|
||||||
cmd := newDaemonCommand()
|
|
||||||
cmd.SetArgs([]string{"--version"})
|
|
||||||
err := cmd.Execute()
|
|
||||||
|
|
||||||
assert.EqualError(t, err, "Please run `dockerd`")
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
// +build daemon
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func stubRun(cmd *cobra.Command, args []string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDaemonCommandHelp(t *testing.T) {
|
|
||||||
cmd := newDaemonCommand()
|
|
||||||
cmd.RunE = stubRun
|
|
||||||
cmd.SetArgs([]string{"--help"})
|
|
||||||
cmd.SetOutput(ioutil.Discard)
|
|
||||||
err := cmd.Execute()
|
|
||||||
assert.NoError(t, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDaemonCommand(t *testing.T) {
|
|
||||||
cmd := newDaemonCommand()
|
|
||||||
cmd.RunE = stubRun
|
|
||||||
cmd.SetArgs([]string{"--containerd", "/foo"})
|
|
||||||
cmd.SetOutput(ioutil.Discard)
|
|
||||||
err := cmd.Execute()
|
|
||||||
assert.NoError(t, err)
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
// +build daemon
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
const daemonBinary = "dockerd"
|
|
||||||
|
|
||||||
func newDaemonCommand() *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "daemon",
|
|
||||||
Hidden: true,
|
|
||||||
Args: cobra.ArbitraryArgs,
|
|
||||||
DisableFlagParsing: true,
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
return runDaemon()
|
|
||||||
},
|
|
||||||
Deprecated: "and will be removed in Docker 17.12. Please run `dockerd` directly.",
|
|
||||||
}
|
|
||||||
cmd.SetHelpFunc(helpFunc)
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
// CmdDaemon execs dockerd with the same flags
|
|
||||||
func runDaemon() error {
|
|
||||||
// Use os.Args[1:] so that "global" args are passed to dockerd
|
|
||||||
return execDaemon(stripDaemonArg(os.Args[1:]))
|
|
||||||
}
|
|
||||||
|
|
||||||
func execDaemon(args []string) error {
|
|
||||||
binaryPath, err := findDaemonBinary()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return syscall.Exec(
|
|
||||||
binaryPath,
|
|
||||||
append([]string{daemonBinary}, args...),
|
|
||||||
os.Environ())
|
|
||||||
}
|
|
||||||
|
|
||||||
func helpFunc(cmd *cobra.Command, args []string) {
|
|
||||||
if err := execDaemon([]string{"--help"}); err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// findDaemonBinary looks for the path to the dockerd binary starting with
|
|
||||||
// the directory of the current executable (if one exists) and followed by $PATH
|
|
||||||
func findDaemonBinary() (string, error) {
|
|
||||||
execDirname := filepath.Dir(os.Args[0])
|
|
||||||
if execDirname != "" {
|
|
||||||
binaryPath := filepath.Join(execDirname, daemonBinary)
|
|
||||||
if _, err := os.Stat(binaryPath); err == nil {
|
|
||||||
return binaryPath, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exec.LookPath(daemonBinary)
|
|
||||||
}
|
|
||||||
|
|
||||||
// stripDaemonArg removes the `daemon` argument from the list
|
|
||||||
func stripDaemonArg(args []string) []string {
|
|
||||||
for i, arg := range args {
|
|
||||||
if arg == "daemon" {
|
|
||||||
return append(args[:i], args[i+1:]...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return args
|
|
||||||
}
|
|
|
@ -39,10 +39,6 @@ func newDockerCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
return command.ShowHelp(dockerCli.Err())(cmd, args)
|
return command.ShowHelp(dockerCli.Err())(cmd, args)
|
||||||
},
|
},
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
// daemon command is special, we redirect directly to another binary
|
|
||||||
if cmd.Name() == "daemon" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
// flags must be the top-level command flags, not cmd.Flags()
|
// flags must be the top-level command flags, not cmd.Flags()
|
||||||
opts.Common.SetDefaultOptions(flags)
|
opts.Common.SetDefaultOptions(flags)
|
||||||
dockerPreRun(opts)
|
dockerPreRun(opts)
|
||||||
|
@ -64,7 +60,6 @@ func newDockerCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
setHelpFunc(dockerCli, cmd, flags, opts)
|
setHelpFunc(dockerCli, cmd, flags, opts)
|
||||||
|
|
||||||
cmd.SetOutput(dockerCli.Out())
|
cmd.SetOutput(dockerCli.Out())
|
||||||
cmd.AddCommand(newDaemonCommand())
|
|
||||||
commands.AddCommands(cmd, dockerCli)
|
commands.AddCommands(cmd, dockerCli)
|
||||||
|
|
||||||
setValidateArgs(dockerCli, cmd, flags, opts)
|
setValidateArgs(dockerCli, cmd, flags, opts)
|
||||||
|
|
|
@ -81,7 +81,7 @@ The `filter` param to filter the list of image by reference (name or name:tag) i
|
||||||
### `docker daemon` subcommand
|
### `docker daemon` subcommand
|
||||||
**Deprecated In Release: [v1.13.0](https://github.com/docker/docker/releases/tag/v1.13.0)**
|
**Deprecated In Release: [v1.13.0](https://github.com/docker/docker/releases/tag/v1.13.0)**
|
||||||
|
|
||||||
**Target For Removal In Release: v17.12**
|
**Removed In Release: v17.12**
|
||||||
|
|
||||||
The daemon is moved to a separate binary (`dockerd`), and should be used instead.
|
The daemon is moved to a separate binary (`dockerd`), and should be used instead.
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ Registry credentials are managed by **docker-login(1)**.
|
||||||
|
|
||||||
Docker uses the `https://` protocol to communicate with a registry, unless the
|
Docker uses the `https://` protocol to communicate with a registry, unless the
|
||||||
registry is allowed to be accessed over an insecure connection. Refer to the
|
registry is allowed to be accessed over an insecure connection. Refer to the
|
||||||
[insecure registries](https://docs.docker.com/engine/reference/commandline/daemon/#insecure-registries)
|
[insecure registries](https://docs.docker.com/engine/reference/commandline/dockerd/#insecure-registries)
|
||||||
section in the online documentation for more information.
|
section in the online documentation for more information.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eu -o pipefail
|
set -eu -o pipefail
|
||||||
|
|
||||||
go test -tags daemon -v "$@"
|
go test -v "$@"
|
||||||
|
|
Loading…
Reference in New Issue