mirror of https://github.com/docker/cli.git
Remove duplicated getOrchestrator(), and rename hideFlag()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
151990de62
commit
e02c28f40a
|
@ -7,7 +7,6 @@ import (
|
|||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
cliconfig "github.com/docker/cli/cli/config"
|
||||
"github.com/docker/cli/cli/config/configfile"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
@ -32,7 +31,7 @@ func NewStackCommand(dockerCli command.Cli) *cobra.Command {
|
|||
return err
|
||||
}
|
||||
opts.orchestrator = orchestrator
|
||||
hideFlag(cmd, orchestrator)
|
||||
hideOrchestrationFlags(cmd, orchestrator)
|
||||
return checkSupportedFlag(cmd, orchestrator)
|
||||
},
|
||||
|
||||
|
@ -43,13 +42,7 @@ func NewStackCommand(dockerCli command.Cli) *cobra.Command {
|
|||
}
|
||||
defaultHelpFunc := cmd.HelpFunc()
|
||||
cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
|
||||
config := cliconfig.LoadDefaultConfigFile(dockerCli.Err()) // dockerCli is not yet initialized, but we only need config file here
|
||||
o, err := getOrchestrator(config, cmd)
|
||||
if err != nil {
|
||||
fmt.Fprint(dockerCli.Err(), err)
|
||||
return
|
||||
}
|
||||
hideFlag(cmd, o)
|
||||
hideOrchestrationFlags(cmd, opts.orchestrator)
|
||||
defaultHelpFunc(cmd, args)
|
||||
})
|
||||
cmd.AddCommand(
|
||||
|
@ -86,7 +79,7 @@ func getOrchestrator(config *configfile.ConfigFile, cmd *cobra.Command) (command
|
|||
return command.GetStackOrchestrator(orchestratorFlag, config.StackOrchestrator)
|
||||
}
|
||||
|
||||
func hideFlag(cmd *cobra.Command, orchestrator command.Orchestrator) {
|
||||
func hideOrchestrationFlags(cmd *cobra.Command, orchestrator command.Orchestrator) {
|
||||
cmd.Flags().VisitAll(func(f *pflag.Flag) {
|
||||
if _, ok := f.Annotations["kubernetes"]; ok && !orchestrator.HasKubernetes() {
|
||||
f.Hidden = true
|
||||
|
@ -96,7 +89,7 @@ func hideFlag(cmd *cobra.Command, orchestrator command.Orchestrator) {
|
|||
}
|
||||
})
|
||||
for _, subcmd := range cmd.Commands() {
|
||||
hideFlag(subcmd, orchestrator)
|
||||
hideOrchestrationFlags(subcmd, orchestrator)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue