mirror of https://github.com/docker/cli.git
Merge pull request #28010 from vieux/fix_experimental_client
always add but hide experimental cmds and flags
This commit is contained in:
commit
db706f3c38
|
@ -17,6 +17,7 @@ func NewCheckpointCommand(dockerCli *command.DockerCli) *cobra.Command {
|
|||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString())
|
||||
},
|
||||
Tags: map[string]string{"experimental": ""},
|
||||
}
|
||||
cmd.AddCommand(
|
||||
newCreateCommand(dockerCli),
|
||||
|
|
|
@ -38,21 +38,15 @@ type DockerCli struct {
|
|||
err io.Writer
|
||||
keyFile string
|
||||
client client.APIClient
|
||||
hasExperimental *bool
|
||||
}
|
||||
|
||||
// HasExperimental returns true if experimental features are accessible
|
||||
func (cli *DockerCli) HasExperimental() bool {
|
||||
if cli.hasExperimental == nil {
|
||||
if cli.client == nil {
|
||||
cli.Initialize(cliflags.NewClientOptions())
|
||||
return false
|
||||
}
|
||||
enabled := false
|
||||
cli.hasExperimental = &enabled
|
||||
enabled, _ = cli.client.Ping(context.Background())
|
||||
}
|
||||
|
||||
return *cli.hasExperimental
|
||||
enabled, _ := cli.client.Ping(context.Background())
|
||||
return enabled
|
||||
}
|
||||
|
||||
// Client returns the APIClient
|
||||
|
|
|
@ -70,16 +70,11 @@ func AddCommands(cmd *cobra.Command, dockerCli *command.DockerCli) {
|
|||
hide(image.NewSaveCommand(dockerCli)),
|
||||
hide(image.NewTagCommand(dockerCli)),
|
||||
hide(system.NewInspectCommand(dockerCli)),
|
||||
)
|
||||
|
||||
if dockerCli.HasExperimental() {
|
||||
cmd.AddCommand(
|
||||
stack.NewStackCommand(dockerCli),
|
||||
stack.NewTopLevelDeployCommand(dockerCli),
|
||||
checkpoint.NewCheckpointCommand(dockerCli),
|
||||
plugin.NewPluginCommand(dockerCli),
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -45,11 +45,10 @@ func NewStartCommand(dockerCli *command.DockerCli) *cobra.Command {
|
|||
flags.BoolVarP(&opts.openStdin, "interactive", "i", false, "Attach container's STDIN")
|
||||
flags.StringVar(&opts.detachKeys, "detach-keys", "", "Override the key sequence for detaching a container")
|
||||
|
||||
if dockerCli.HasExperimental() {
|
||||
flags.StringVar(&opts.checkpoint, "checkpoint", "", "Restore from this checkpoint")
|
||||
flags.SetAnnotation("checkpoint", "experimental", nil)
|
||||
flags.StringVar(&opts.checkpointDir, "checkpoint-dir", "", "Use a custom checkpoint storage directory")
|
||||
}
|
||||
|
||||
flags.SetAnnotation("checkpoint-dir", "experimental", nil)
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
|
|
@ -111,9 +111,8 @@ func NewBuildCommand(dockerCli *command.DockerCli) *cobra.Command {
|
|||
|
||||
command.AddTrustedFlags(flags, true)
|
||||
|
||||
if dockerCli.HasExperimental() {
|
||||
flags.BoolVar(&options.squash, "squash", false, "Squash newly built layers into a single new layer")
|
||||
}
|
||||
flags.SetAnnotation("squash", "experimental", nil)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ func NewPluginCommand(dockerCli *command.DockerCli) *cobra.Command {
|
|||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString())
|
||||
},
|
||||
Tags: map[string]string{"experimental": ""},
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
|
|
|
@ -17,6 +17,7 @@ func NewStackCommand(dockerCli *command.DockerCli) *cobra.Command {
|
|||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString())
|
||||
},
|
||||
Tags: map[string]string{"experimental": ""},
|
||||
}
|
||||
cmd.AddCommand(
|
||||
newConfigCommand(dockerCli),
|
||||
|
|
|
@ -36,6 +36,7 @@ func newDeployCommand(dockerCli *command.DockerCli) *cobra.Command {
|
|||
opts.namespace = strings.TrimSuffix(args[0], ".dab")
|
||||
return runDeploy(dockerCli, opts)
|
||||
},
|
||||
Tags: map[string]string{"experimental": ""},
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
|
|
Loading…
Reference in New Issue