Signed-off-by: Victor Vieux <vieux@docker.com>
| ... | ... |
@@ -17,6 +17,7 @@ func NewCheckpointCommand(dockerCli *command.DockerCli) *cobra.Command {
|
| 17 | 17 |
Run: func(cmd *cobra.Command, args []string) {
|
| 18 | 18 |
fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString()) |
| 19 | 19 |
}, |
| 20 |
+ Tags: map[string]string{"experimental": ""},
|
|
| 20 | 21 |
} |
| 21 | 22 |
cmd.AddCommand( |
| 22 | 23 |
newCreateCommand(dockerCli), |
| ... | ... |
@@ -32,27 +32,21 @@ type Streams interface {
|
| 32 | 32 |
// DockerCli represents the docker command line client. |
| 33 | 33 |
// Instances of the client can be returned from NewDockerCli. |
| 34 | 34 |
type DockerCli struct {
|
| 35 |
- configFile *configfile.ConfigFile |
|
| 36 |
- in *InStream |
|
| 37 |
- out *OutStream |
|
| 38 |
- err io.Writer |
|
| 39 |
- keyFile string |
|
| 40 |
- client client.APIClient |
|
| 41 |
- hasExperimental *bool |
|
| 35 |
+ configFile *configfile.ConfigFile |
|
| 36 |
+ in *InStream |
|
| 37 |
+ out *OutStream |
|
| 38 |
+ err io.Writer |
|
| 39 |
+ keyFile string |
|
| 40 |
+ client client.APIClient |
|
| 42 | 41 |
} |
| 43 | 42 |
|
| 44 | 43 |
// HasExperimental returns true if experimental features are accessible |
| 45 | 44 |
func (cli *DockerCli) HasExperimental() bool {
|
| 46 |
- if cli.hasExperimental == nil {
|
|
| 47 |
- if cli.client == nil {
|
|
| 48 |
- return false |
|
| 49 |
- } |
|
| 50 |
- enabled := false |
|
| 51 |
- cli.hasExperimental = &enabled |
|
| 52 |
- enabled, _ = cli.client.Ping(context.Background()) |
|
| 45 |
+ if cli.client == nil {
|
|
| 46 |
+ return false |
|
| 53 | 47 |
} |
| 54 |
- |
|
| 55 |
- return *cli.hasExperimental |
|
| 48 |
+ enabled, _ := cli.client.Ping(context.Background()) |
|
| 49 |
+ return enabled |
|
| 56 | 50 |
} |
| 57 | 51 |
|
| 58 | 52 |
// Client returns the APIClient |
| ... | ... |
@@ -46,8 +46,8 @@ func NewStartCommand(dockerCli *command.DockerCli) *cobra.Command {
|
| 46 | 46 |
flags.StringVar(&opts.detachKeys, "detach-keys", "", "Override the key sequence for detaching a container") |
| 47 | 47 |
|
| 48 | 48 |
flags.StringVar(&opts.checkpoint, "checkpoint", "", "Restore from this checkpoint") |
| 49 |
- flags.StringVar(&opts.checkpointDir, "checkpoint-dir", "", "Use a custom checkpoint storage directory") |
|
| 50 | 49 |
flags.SetAnnotation("checkpoint", "experimental", nil)
|
| 50 |
+ flags.StringVar(&opts.checkpointDir, "checkpoint-dir", "", "Use a custom checkpoint storage directory") |
|
| 51 | 51 |
flags.SetAnnotation("checkpoint-dir", "experimental", nil)
|
| 52 | 52 |
return cmd |
| 53 | 53 |
} |
| ... | ... |
@@ -17,6 +17,7 @@ func NewPluginCommand(dockerCli *command.DockerCli) *cobra.Command {
|
| 17 | 17 |
Run: func(cmd *cobra.Command, args []string) {
|
| 18 | 18 |
fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString()) |
| 19 | 19 |
}, |
| 20 |
+ Tags: map[string]string{"experimental": ""},
|
|
| 20 | 21 |
} |
| 21 | 22 |
|
| 22 | 23 |
cmd.AddCommand( |
| ... | ... |
@@ -17,6 +17,7 @@ func NewStackCommand(dockerCli *command.DockerCli) *cobra.Command {
|
| 17 | 17 |
Run: func(cmd *cobra.Command, args []string) {
|
| 18 | 18 |
fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString()) |
| 19 | 19 |
}, |
| 20 |
+ Tags: map[string]string{"experimental": ""},
|
|
| 20 | 21 |
} |
| 21 | 22 |
cmd.AddCommand( |
| 22 | 23 |
newConfigCommand(dockerCli), |
| ... | ... |
@@ -3,7 +3,6 @@ package main |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"os" |
| 6 |
- "strings" |
|
| 7 | 6 |
|
| 8 | 7 |
"github.com/Sirupsen/logrus" |
| 9 | 8 |
"github.com/docker/docker/cli" |
| ... | ... |
@@ -134,8 +133,7 @@ func hideExperimentalFeatures(cmd *cobra.Command) {
|
| 134 | 134 |
|
| 135 | 135 |
for _, subcmd := range cmd.Commands() {
|
| 136 | 136 |
// hide subcommands |
| 137 |
- name := strings.Split(subcmd.Use, " ")[0] |
|
| 138 |
- if name == "stack" || name == "deploy" || name == "checkpoint" || name == "plugin" {
|
|
| 137 |
+ if _, ok := subcmd.Tags["experimental"]; ok {
|
|
| 139 | 138 |
subcmd.Hidden = true |
| 140 | 139 |
} |
| 141 | 140 |
} |
| ... | ... |
@@ -123,7 +123,7 @@ github.com/matttproud/golang_protobuf_extensions fc2b8d3a73c4867e51861bbdd5ae3c1 |
| 123 | 123 |
github.com/pkg/errors 01fa4104b9c248c8945d14d9f128454d5b28d595 |
| 124 | 124 |
|
| 125 | 125 |
# cli |
| 126 |
-github.com/spf13/cobra v1.4.1 https://github.com/dnephin/cobra.git |
|
| 126 |
+github.com/spf13/cobra v1.5 https://github.com/dnephin/cobra.git |
|
| 127 | 127 |
github.com/spf13/pflag dabebe21bf790f782ea4c7bbd2efc430de182afd |
| 128 | 128 |
github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 |
| 129 | 129 |
github.com/flynn-archive/go-shlex 3f9db97f856818214da2e1057f8ad84803971cff |
| ... | ... |
@@ -59,6 +59,9 @@ type Command struct {
|
| 59 | 59 |
Deprecated string |
| 60 | 60 |
// Is this command hidden and should NOT show up in the list of available commands? |
| 61 | 61 |
Hidden bool |
| 62 |
+ // Tags are key/value pairs that can be used by applications to identify or |
|
| 63 |
+ // group commands |
|
| 64 |
+ Tags map[string]string |
|
| 62 | 65 |
// Full set of flags |
| 63 | 66 |
flags *flag.FlagSet |
| 64 | 67 |
// Set of flags childrens of this command will inherit |
| ... | ... |
@@ -111,10 +114,10 @@ type Command struct {
|
| 111 | 111 |
|
| 112 | 112 |
flagErrorBuf *bytes.Buffer |
| 113 | 113 |
|
| 114 |
- args []string // actual args parsed from flags |
|
| 115 |
- output *io.Writer // nil means stderr; use Out() method instead |
|
| 116 |
- usageFunc func(*Command) error // Usage can be defined by application |
|
| 117 |
- usageTemplate string // Can be defined by Application |
|
| 114 |
+ args []string // actual args parsed from flags |
|
| 115 |
+ output *io.Writer // nil means stderr; use Out() method instead |
|
| 116 |
+ usageFunc func(*Command) error // Usage can be defined by application |
|
| 117 |
+ usageTemplate string // Can be defined by Application |
|
| 118 | 118 |
flagErrorFunc func(*Command, error) error |
| 119 | 119 |
helpTemplate string // Can be defined by Application |
| 120 | 120 |
helpFunc func(*Command, []string) // Help can be defined by application |
| ... | ... |
@@ -417,7 +420,7 @@ func argsMinusFirstX(args []string, x string) []string {
|
| 417 | 417 |
|
| 418 | 418 |
func isFlagArg(arg string) bool {
|
| 419 | 419 |
return ((len(arg) >= 3 && arg[1] == '-') || |
| 420 |
- (len(arg) >= 2 && arg[0] == '-' && arg[1] != '-')) |
|
| 420 |
+ (len(arg) >= 2 && arg[0] == '-' && arg[1] != '-')) |
|
| 421 | 421 |
} |
| 422 | 422 |
|
| 423 | 423 |
// Find the target command given the args and command tree |
| ... | ... |
@@ -820,7 +823,7 @@ func (c commandSorterByName) Less(i, j int) bool { return c[i].Name() < c[j].Nam
|
| 820 | 820 |
// Commands returns a sorted slice of child commands. |
| 821 | 821 |
func (c *Command) Commands() []*Command {
|
| 822 | 822 |
// do not sort commands if it already sorted or sorting was disabled |
| 823 |
- if EnableCommandSorting && !c.commandsAreSorted{
|
|
| 823 |
+ if EnableCommandSorting && !c.commandsAreSorted {
|
|
| 824 | 824 |
sort.Sort(commandSorterByName(c.commands)) |
| 825 | 825 |
c.commandsAreSorted = true |
| 826 | 826 |
} |