Remove experimentalCli annotation from all kubernetes flags and commands

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
This commit is contained in:
Silvin Lubecki 2018-05-18 17:54:18 +02:00
parent 82053236a3
commit f2b75a879a
8 changed files with 4 additions and 33 deletions

View File

@ -166,7 +166,7 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions) error {
if err != nil { if err != nil {
return errors.Wrap(err, "Experimental field") return errors.Wrap(err, "Experimental field")
} }
orchestrator, err := GetOrchestrator(hasExperimental, opts.Common.Orchestrator, cli.configFile.Orchestrator) orchestrator, err := GetOrchestrator(opts.Common.Orchestrator, cli.configFile.Orchestrator)
if err != nil { if err != nil {
return err return err
} }
@ -244,7 +244,7 @@ type ClientInfo struct {
// HasKubernetes checks if kubernetes orchestrator is enabled // HasKubernetes checks if kubernetes orchestrator is enabled
func (c ClientInfo) HasKubernetes() bool { func (c ClientInfo) HasKubernetes() bool {
return c.HasExperimental && (c.Orchestrator == OrchestratorKubernetes || c.Orchestrator == OrchestratorAll) return c.Orchestrator == OrchestratorKubernetes || c.Orchestrator == OrchestratorAll
} }
// HasSwarm checks if swarm orchestrator is enabled // HasSwarm checks if swarm orchestrator is enabled

View File

@ -176,28 +176,14 @@ func TestOrchestratorSwitch(t *testing.T) {
{ {
doc: "default", doc: "default",
configfile: `{ configfile: `{
"experimental": "enabled"
}`, }`,
expectedOrchestrator: "swarm", expectedOrchestrator: "swarm",
expectedKubernetes: false, expectedKubernetes: false,
expectedSwarm: true, expectedSwarm: true,
}, },
{
doc: "kubernetesIsExperimental",
configfile: `{
"experimental": "disabled",
"orchestrator": "kubernetes"
}`,
envOrchestrator: "kubernetes",
flagOrchestrator: "kubernetes",
expectedOrchestrator: "swarm",
expectedKubernetes: false,
expectedSwarm: true,
},
{ {
doc: "kubernetesConfigFile", doc: "kubernetesConfigFile",
configfile: `{ configfile: `{
"experimental": "enabled",
"orchestrator": "kubernetes" "orchestrator": "kubernetes"
}`, }`,
expectedOrchestrator: "kubernetes", expectedOrchestrator: "kubernetes",
@ -207,7 +193,6 @@ func TestOrchestratorSwitch(t *testing.T) {
{ {
doc: "kubernetesEnv", doc: "kubernetesEnv",
configfile: `{ configfile: `{
"experimental": "enabled"
}`, }`,
envOrchestrator: "kubernetes", envOrchestrator: "kubernetes",
expectedOrchestrator: "kubernetes", expectedOrchestrator: "kubernetes",
@ -217,7 +202,6 @@ func TestOrchestratorSwitch(t *testing.T) {
{ {
doc: "kubernetesFlag", doc: "kubernetesFlag",
configfile: `{ configfile: `{
"experimental": "enabled"
}`, }`,
flagOrchestrator: "kubernetes", flagOrchestrator: "kubernetes",
expectedOrchestrator: "kubernetes", expectedOrchestrator: "kubernetes",
@ -227,7 +211,6 @@ func TestOrchestratorSwitch(t *testing.T) {
{ {
doc: "allOrchestratorFlag", doc: "allOrchestratorFlag",
configfile: `{ configfile: `{
"experimental": "enabled"
}`, }`,
flagOrchestrator: "all", flagOrchestrator: "all",
expectedOrchestrator: "all", expectedOrchestrator: "all",
@ -237,7 +220,6 @@ func TestOrchestratorSwitch(t *testing.T) {
{ {
doc: "envOverridesConfigFile", doc: "envOverridesConfigFile",
configfile: `{ configfile: `{
"experimental": "enabled",
"orchestrator": "kubernetes" "orchestrator": "kubernetes"
}`, }`,
envOrchestrator: "swarm", envOrchestrator: "swarm",
@ -248,7 +230,6 @@ func TestOrchestratorSwitch(t *testing.T) {
{ {
doc: "flagOverridesEnv", doc: "flagOverridesEnv",
configfile: `{ configfile: `{
"experimental": "enabled"
}`, }`,
envOrchestrator: "kubernetes", envOrchestrator: "kubernetes",
flagOrchestrator: "swarm", flagOrchestrator: "swarm",

View File

@ -38,11 +38,7 @@ func normalize(value string) (Orchestrator, error) {
// GetOrchestrator checks DOCKER_ORCHESTRATOR environment variable and configuration file // GetOrchestrator checks DOCKER_ORCHESTRATOR environment variable and configuration file
// orchestrator value and returns user defined Orchestrator. // orchestrator value and returns user defined Orchestrator.
func GetOrchestrator(isExperimental bool, flagValue, value string) (Orchestrator, error) { func GetOrchestrator(flagValue, value string) (Orchestrator, error) {
// Non experimental CLI has kubernetes disabled
if !isExperimental {
return defaultOrchestrator, nil
}
// Check flag // Check flag
if o, err := normalize(flagValue); o != orchestratorUnset { if o, err := normalize(flagValue); o != orchestratorUnset {
return o, err return o, err

View File

@ -33,7 +33,6 @@ func NewStackCommand(dockerCli command.Cli) *cobra.Command {
flags := cmd.PersistentFlags() flags := cmd.PersistentFlags()
flags.String("kubeconfig", "", "Kubernetes config file") flags.String("kubeconfig", "", "Kubernetes config file")
flags.SetAnnotation("kubeconfig", "kubernetes", nil) flags.SetAnnotation("kubeconfig", "kubernetes", nil)
flags.SetAnnotation("kubeconfig", "experimentalCLI", nil)
return cmd return cmd
} }

View File

@ -42,7 +42,6 @@ func NewOptions(flags *flag.FlagSet) Options {
func AddNamespaceFlag(flags *flag.FlagSet) { func AddNamespaceFlag(flags *flag.FlagSet) {
flags.String("namespace", "", "Kubernetes namespace to use") flags.String("namespace", "", "Kubernetes namespace to use")
flags.SetAnnotation("namespace", "kubernetes", nil) flags.SetAnnotation("namespace", "kubernetes", nil)
flags.SetAnnotation("namespace", "experimentalCLI", nil)
} }
// WrapCli wraps command.Cli with kubernetes specifics // WrapCli wraps command.Cli with kubernetes specifics

View File

@ -30,10 +30,8 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
flags.StringVar(&opts.Format, "format", "", "Pretty-print stacks using a Go template") flags.StringVar(&opts.Format, "format", "", "Pretty-print stacks using a Go template")
flags.StringSliceVar(&opts.Namespaces, "namespace", []string{}, "Kubernetes namespaces to use") flags.StringSliceVar(&opts.Namespaces, "namespace", []string{}, "Kubernetes namespaces to use")
flags.SetAnnotation("namespace", "kubernetes", nil) flags.SetAnnotation("namespace", "kubernetes", nil)
flags.SetAnnotation("namespace", "experimentalCLI", nil)
flags.BoolVarP(&opts.AllNamespaces, "all-namespaces", "", false, "List stacks from all Kubernetes namespaces") flags.BoolVarP(&opts.AllNamespaces, "all-namespaces", "", false, "List stacks from all Kubernetes namespaces")
flags.SetAnnotation("all-namespaces", "kubernetes", nil) flags.SetAnnotation("all-namespaces", "kubernetes", nil)
flags.SetAnnotation("all-namespaces", "experimentalCLI", nil)
return cmd return cmd
} }

View File

@ -108,7 +108,6 @@ func NewVersionCommand(dockerCli command.Cli) *cobra.Command {
flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template")
flags.StringVarP(&opts.kubeConfig, "kubeconfig", "k", "", "Kubernetes config file") flags.StringVarP(&opts.kubeConfig, "kubeconfig", "k", "", "Kubernetes config file")
flags.SetAnnotation("kubeconfig", "kubernetes", nil) flags.SetAnnotation("kubeconfig", "kubernetes", nil)
flags.SetAnnotation("kubeconfig", "experimentalCLI", nil)
return cmd return cmd
} }

View File

@ -53,8 +53,7 @@ func newDockerCommand(dockerCli *command.DockerCli) *cobra.Command {
// Install persistent flags // Install persistent flags
persistentFlags := cmd.PersistentFlags() persistentFlags := cmd.PersistentFlags()
persistentFlags.StringVar(&opts.Common.Orchestrator, "orchestrator", "", "Orchestrator to use (swarm|kubernetes|all) (experimental)") persistentFlags.StringVar(&opts.Common.Orchestrator, "orchestrator", "", "Orchestrator to use (swarm|kubernetes|all)")
persistentFlags.SetAnnotation("orchestrator", "experimentalCLI", nil)
setFlagErrorFunc(dockerCli, cmd, flags, opts) setFlagErrorFunc(dockerCli, cmd, flags, opts)