Cleanup the structure of the cli package.

Move all flags into cli/flags
Move usage help into cli/usage.go

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin
2016-04-21 17:51:28 -04:00
parent 861815a325
commit 33c9edaf6c
8 changed files with 39 additions and 47 deletions

View File

@@ -3,7 +3,6 @@ package main
import (
"path/filepath"
"github.com/docker/docker/cli"
cliflags "github.com/docker/docker/cli/flags"
"github.com/docker/docker/cliconfig"
flag "github.com/docker/docker/pkg/mflag"
@@ -12,7 +11,7 @@ import (
var (
commonFlags = cliflags.InitCommonFlags()
clientFlags = &cli.ClientFlags{FlagSet: new(flag.FlagSet), Common: commonFlags}
clientFlags = &cliflags.ClientFlags{FlagSet: new(flag.FlagSet), Common: commonFlags}
)
func init() {

View File

@@ -23,7 +23,6 @@ import (
systemrouter "github.com/docker/docker/api/server/router/system"
"github.com/docker/docker/api/server/router/volume"
"github.com/docker/docker/builder/dockerfile"
"github.com/docker/docker/cli"
cliflags "github.com/docker/docker/cli/flags"
"github.com/docker/docker/cliconfig"
"github.com/docker/docker/daemon"
@@ -51,7 +50,7 @@ const (
// DaemonCli represents the daemon CLI.
type DaemonCli struct {
*daemon.Config
commonFlags *cli.CommonFlags
commonFlags *cliflags.CommonFlags
configFile *string
}
@@ -345,7 +344,7 @@ func shutdownDaemon(d *daemon.Daemon, timeout time.Duration) {
}
}
func loadDaemonCliConfig(config *daemon.Config, flags *flag.FlagSet, commonConfig *cli.CommonFlags, configFile string) (*daemon.Config, error) {
func loadDaemonCliConfig(config *daemon.Config, flags *flag.FlagSet, commonConfig *cliflags.CommonFlags, configFile string) (*daemon.Config, error) {
config.Debug = commonConfig.Debug
config.Hosts = commonConfig.Hosts
config.LogLevel = commonConfig.LogLevel

View File

@@ -7,7 +7,7 @@ import (
"testing"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/cli"
cliflags "github.com/docker/docker/cli/flags"
"github.com/docker/docker/daemon"
"github.com/docker/docker/opts"
"github.com/docker/docker/pkg/mflag"
@@ -16,7 +16,7 @@ import (
func TestLoadDaemonCliConfigWithoutOverriding(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{
common := &cliflags.CommonFlags{
Debug: true,
}
@@ -35,7 +35,7 @@ func TestLoadDaemonCliConfigWithoutOverriding(t *testing.T) {
func TestLoadDaemonCliConfigWithTLS(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{
common := &cliflags.CommonFlags{
TLS: true,
TLSOptions: &tlsconfig.Options{
CAFile: "/tmp/ca.pem",
@@ -57,7 +57,7 @@ func TestLoadDaemonCliConfigWithTLS(t *testing.T) {
func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{}
common := &cliflags.CommonFlags{}
f, err := ioutil.TempFile("", "docker-config-")
if err != nil {
t.Fatal(err)
@@ -93,7 +93,7 @@ func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{
common := &cliflags.CommonFlags{
TLSOptions: &tlsconfig.Options{
CAFile: "/tmp/ca.pem",
},
@@ -126,7 +126,7 @@ func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{
common := &cliflags.CommonFlags{
TLSOptions: &tlsconfig.Options{
CAFile: "/tmp/ca.pem",
},
@@ -159,7 +159,7 @@ func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{
common := &cliflags.CommonFlags{
TLSOptions: &tlsconfig.Options{
CAFile: "/tmp/ca.pem",
},
@@ -191,7 +191,7 @@ func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{}
common := &cliflags.CommonFlags{}
f, err := ioutil.TempFile("", "docker-config-")
if err != nil {
@@ -223,7 +223,7 @@ func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{}
common := &cliflags.CommonFlags{}
flags := mflag.NewFlagSet("test", mflag.ContinueOnError)
flags.String([]string{"-tlscacert"}, "", "")
@@ -256,7 +256,7 @@ func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{}
common := &cliflags.CommonFlags{}
flags := mflag.NewFlagSet("test", mflag.ContinueOnError)
c.ServiceOptions.InstallCliFlags(flags, absentFromHelp)

View File

@@ -6,7 +6,7 @@ import (
"io/ioutil"
"testing"
"github.com/docker/docker/cli"
cliflags "github.com/docker/docker/cli/flags"
"github.com/docker/docker/daemon"
"github.com/docker/docker/opts"
"github.com/docker/docker/pkg/mflag"
@@ -14,7 +14,7 @@ import (
func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{
common := &cliflags.CommonFlags{
Debug: true,
LogLevel: "info",
}
@@ -61,7 +61,7 @@ func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
func TestLoadDaemonConfigWithNetwork(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{}
common := &cliflags.CommonFlags{}
flags := mflag.NewFlagSet("test", mflag.ContinueOnError)
flags.String([]string{"-bip"}, "", "")
flags.String([]string{"-ip"}, "", "")
@@ -92,7 +92,7 @@ func TestLoadDaemonConfigWithNetwork(t *testing.T) {
func TestLoadDaemonConfigWithMapOptions(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{}
common := &cliflags.CommonFlags{}
flags := mflag.NewFlagSet("test", mflag.ContinueOnError)
flags.Var(opts.NewNamedMapOpts("cluster-store-opts", c.ClusterOpts, nil), []string{"-cluster-store-opt"}, "")
@@ -136,7 +136,7 @@ func TestLoadDaemonConfigWithMapOptions(t *testing.T) {
func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{}
common := &cliflags.CommonFlags{}
flags := mflag.NewFlagSet("test", mflag.ContinueOnError)
flags.BoolVar(&c.EnableUserlandProxy, []string{"-userland-proxy"}, true, "")
@@ -181,7 +181,7 @@ func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) {
func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{}
common := &cliflags.CommonFlags{}
flags := mflag.NewFlagSet("test", mflag.ContinueOnError)
flags.BoolVar(&c.EnableUserlandProxy, []string{"-userland-proxy"}, true, "")