Remove old cli framework.
Also consolidate the leftover packages under cli. Remove pkg/mflag. Make manpage generation work with new cobra layout. Remove remaining mflag and fix tests after rebase with master. Signed-off-by: Daniel Nephin <dnephin@docker.com> Upstream-commit: 14712f9ff0d20a3b64a60103608b8cc998909242 Component: engine
This commit is contained in:
@ -130,7 +130,7 @@ func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
|
||||
func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
|
||||
content := `{
|
||||
"registry-mirrors": ["https://mirrors.docker.com"],
|
||||
"insecure-registries": ["https://insecure.docker.com"],
|
||||
"insecure-registries": ["https://insecure.docker.com"]
|
||||
}`
|
||||
tempFile := tempfile.NewTempFile(t, "config", content)
|
||||
defer tempFile.Remove()
|
||||
|
||||
@ -3,8 +3,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/daemon"
|
||||
@ -102,30 +100,13 @@ func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithLegacyRegistryOptions(t *testing.T) {
|
||||
c := &daemon.Config{}
|
||||
common := &cliflags.CommonFlags{}
|
||||
flags := mflag.NewFlagSet("test", mflag.ContinueOnError)
|
||||
c.ServiceOptions.InstallCliFlags(flags, absentFromHelp)
|
||||
content := `{"disable-legacy-registry": true}`
|
||||
tempFile := tempfile.NewTempFile(t, "config", content)
|
||||
defer tempFile.Remove()
|
||||
|
||||
f, err := ioutil.TempFile("", "docker-config-")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
configFile := f.Name()
|
||||
defer os.Remove(configFile)
|
||||
|
||||
f.Write([]byte(`{"disable-legacy-registry": true}`))
|
||||
f.Close()
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(c, flags, common, configFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if loadedConfig == nil {
|
||||
t.Fatal("expected configuration, got nil")
|
||||
}
|
||||
|
||||
if !loadedConfig.V2Only {
|
||||
t.Fatal("expected disable-legacy-registry to be true, got false")
|
||||
}
|
||||
opts := defaultOptions(tempFile.Name())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
assert.NilError(t, err)
|
||||
assert.NotNil(t, loadedConfig)
|
||||
assert.Equal(t, loadedConfig.V2Only, true)
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/cli"
|
||||
"github.com/docker/docker/cli/cobraadaptor"
|
||||
cliflags "github.com/docker/docker/cli/flags"
|
||||
"github.com/docker/docker/daemon"
|
||||
"github.com/docker/docker/dockerversion"
|
||||
@ -41,7 +40,7 @@ func newDaemonCommand() *cobra.Command {
|
||||
return runDaemon(opts)
|
||||
},
|
||||
}
|
||||
cobraadaptor.SetupRootCommand(cmd)
|
||||
cli.SetupRootCommand(cmd)
|
||||
|
||||
flags := cmd.Flags()
|
||||
flags.BoolVarP(&opts.version, "version", "v", false, "Print version information and quit")
|
||||
|
||||
Reference in New Issue
Block a user