Fix tests and windows service.

Support args to RunCommand
Fix docker help text test.
Fix for ipv6 tests.
Fix TLSverify option.
Fix TestDaemonDiscoveryBackendConfigReload
Use tempfile for another test.
Restore missing flag.
Fix tests for removal of shlex.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2016-08-03 12:20:46 -04:00
parent 3b178887a7
commit 9af25060cd
2 changed files with 18 additions and 6 deletions

View File

@ -4,9 +4,10 @@ package main
import (
"fmt"
"github.com/spf13/cobra"
"runtime"
"strings"
"github.com/spf13/cobra"
)
func newDaemonCommand() *cobra.Command {

View File

@ -19,13 +19,15 @@ import (
func newDockerCommand(dockerCli *client.DockerCli) *cobra.Command {
opts := cliflags.NewClientOptions()
var flags *pflag.FlagSet
cmd := &cobra.Command{
Use: "docker [OPTIONS] COMMAND [arg...]",
Short: "A self-sufficient runtime for containers.",
SilenceUsage: true,
SilenceErrors: true,
TraverseChildren: true,
Args: cli.NoArgs,
Args: noArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if opts.Version {
showVersion()
@ -35,13 +37,15 @@ func newDockerCommand(dockerCli *client.DockerCli) *cobra.Command {
return nil
},
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
dockerPreRun(cmd.Flags(), opts)
// flags must be the top-level command flags, not cmd.Flags()
opts.Common.SetDefaultOptions(flags)
dockerPreRun(opts)
return dockerCli.Initialize(opts)
},
}
cli.SetupRootCommand(cmd)
flags := cmd.Flags()
flags = cmd.Flags()
flags.BoolVarP(&opts.Version, "version", "v", false, "Print version information and quit")
flags.StringVar(&opts.ConfigDir, "config", cliconfig.ConfigDir(), "Location of client config files")
opts.Common.InstallFlags(flags)
@ -53,6 +57,14 @@ func newDockerCommand(dockerCli *client.DockerCli) *cobra.Command {
return cmd
}
func noArgs(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return nil
}
return fmt.Errorf(
"docker: '%s' is not a docker command.\nSee 'docker --help'%s", args[0], ".")
}
func main() {
// Set terminal emulation based on platform as required.
stdin, stdout, stderr := term.StdStreams()
@ -86,8 +98,7 @@ func showVersion() {
}
}
func dockerPreRun(flags *pflag.FlagSet, opts *cliflags.ClientOptions) {
opts.Common.SetDefaultOptions(flags)
func dockerPreRun(opts *cliflags.ClientOptions) {
cliflags.SetDaemonLogLevel(opts.Common.LogLevel)
if opts.ConfigDir != "" {