Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cli/command/context/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
&opts.DefaultStackOrchestrator,
"default-stack-orchestrator", "",
"Default orchestrator for stack operations to use with this context (swarm|kubernetes|all)")
flags.SetAnnotation("default-stack-orchestrator", "deprecated", nil)
flags.StringToStringVar(&opts.Docker, "docker", nil, "set the docker endpoint")
flags.StringToStringVar(&opts.Kubernetes, "kubernetes", nil, "set the kubernetes endpoint")
flags.SetAnnotation("kubernetes", "kubernetes", nil)
flags.SetAnnotation("kubernetes", "deprecated", nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious; did you also try if flags.MarkDeprecated("kubernetes", "<deprecation message>") would do the trick?

Given: that also hides the flag, and prints a deprecation message when used, so it would have a slightly different result; https://github.com/spf13/pflag/blob/85dd5c8bc61cfa382fecd072378089d4e856579d/flag.go#L408-L422

// MarkDeprecated indicated that a flag is deprecated in your program. It will
// continue to function but will not show up in help or usage messages. Using
// this flag will also print the given usageMessage.
func (f *FlagSet) MarkDeprecated(name string, usageMessage string) error {
	flag := f.Lookup(name)
	if flag == nil {
		return fmt.Errorf("flag %q does not exist", name)
	}
	if usageMessage == "" {
		return fmt.Errorf("deprecated message for flag %q must be set", name)
	}
	flag.Deprecated = usageMessage
	flag.Hidden = true
	return nil
}

Copy link
Member Author

@mat007 mat007 Jul 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but will not show up in help or usage messages

Do we really want that?

I was expecting flags.SetAnnotation("kubernetes", "deprecated", nil) to actually end up marking the flag as deprecated in the docs, a bit like the "kubernetes" annotation (sorry it doesn’t help that "kubernetes" here it’s both a flag and an annotation 😬) in https://docs.docker.com/engine/reference/commandline/stack/#options
I think it has a good chance to work according to the code for the deprecated-badge and kubernetes at https://github.com/docker/docker.github.io/blob/master/_includes/cli.md#options

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want that?

Gotcha.

Normally, yes (deprecate in "major" release X, and remove in "major release X+n"), but given that we're "cheating" a bit, and do this in a patch release, I it may indeed be a bit unexpected.

flags.StringVar(&opts.From, "from", "", "create context from a named context")
return cmd
}
Expand Down
2 changes: 2 additions & 0 deletions cli/command/context/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func newExportCommand(dockerCli command.Cli) *cobra.Command {

flags := cmd.Flags()
flags.BoolVar(&opts.Kubeconfig, "kubeconfig", false, "Export as a kubeconfig file")
flags.SetAnnotation("kubeconfig", "kubernetes", nil)
flags.SetAnnotation("kubeconfig", "deprecated", nil)
return cmd
}

Expand Down
3 changes: 3 additions & 0 deletions cli/command/context/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ func newUpdateCommand(dockerCli command.Cli) *cobra.Command {
&opts.DefaultStackOrchestrator,
"default-stack-orchestrator", "",
"Default orchestrator for stack operations to use with this context (swarm|kubernetes|all)")
flags.SetAnnotation("default-stack-orchestrator", "deprecated", nil)
flags.StringToStringVar(&opts.Docker, "docker", nil, "set the docker endpoint")
flags.StringToStringVar(&opts.Kubernetes, "kubernetes", nil, "set the kubernetes endpoint")
flags.SetAnnotation("kubernetes", "kubernetes", nil)
flags.SetAnnotation("kubernetes", "deprecated", nil)
return cmd
}

Expand Down
2 changes: 2 additions & 0 deletions cli/command/stack/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ func NewStackCommand(dockerCli command.Cli) *cobra.Command {
flags := cmd.PersistentFlags()
flags.String("kubeconfig", "", "Kubernetes config file")
flags.SetAnnotation("kubeconfig", "kubernetes", nil)
flags.SetAnnotation("kubeconfig", "deprecated", nil)
flags.String("orchestrator", "", "Orchestrator to use (swarm|kubernetes|all)")
flags.SetAnnotation("orchestrator", "deprecated", nil)
return cmd
}

Expand Down
1 change: 1 addition & 0 deletions cli/command/stack/kubernetes/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func NewOptions(flags *flag.FlagSet, orchestrator command.Orchestrator) Options
func AddNamespaceFlag(flags *flag.FlagSet) {
flags.String("namespace", "", "Kubernetes namespace to use")
flags.SetAnnotation("namespace", "kubernetes", nil)
flags.SetAnnotation("namespace", "deprecated", nil)
}

// WrapCli wraps command.Cli with kubernetes specifics
Expand Down
2 changes: 2 additions & 0 deletions cli/command/stack/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ func newListCommand(dockerCli command.Cli, common *commonOptions) *cobra.Command
flags.StringVar(&opts.Format, "format", "", "Pretty-print stacks using a Go template")
flags.StringSliceVar(&opts.Namespaces, "namespace", []string{}, "Kubernetes namespaces to use")
flags.SetAnnotation("namespace", "kubernetes", nil)
flags.SetAnnotation("namespace", "deprecated", nil)
flags.BoolVarP(&opts.AllNamespaces, "all-namespaces", "", false, "List stacks from all Kubernetes namespaces")
flags.SetAnnotation("all-namespaces", "kubernetes", nil)
flags.SetAnnotation("all-namespaces", "deprecated", nil)
return cmd
}

Expand Down
1 change: 1 addition & 0 deletions cli/command/system/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func NewVersionCommand(dockerCli command.Cli) *cobra.Command {
flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template")
flags.StringVar(&opts.kubeConfig, "kubeconfig", "", "Kubernetes config file")
flags.SetAnnotation("kubeconfig", "kubernetes", nil)
flags.SetAnnotation("kubeconfig", "deprecated", nil)

return cmd
}
Expand Down
6 changes: 3 additions & 3 deletions docs/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The table below provides an overview of the current status of deprecated feature

Status | Feature | Deprecated | Remove
-----------|------------------------------------------------------------------------------------------------------------------------------------|------------|------------
Deprecated | [Kubernetes stack support](#kubernetes-stack-support) | v20.10 | -
Deprecated | [Kubernetes stack and context support](#kubernetes-stack-and-context-support) | v20.10 | -
Deprecated | [Pulling images from non-compliant image registries](#pulling-images-from-non-compliant-image-registries) | v20.10 | -
Deprecated | [Linux containers on Windows (LCOW)](#linux-containers-on-windows-lcow-experimental) | v20.10 | -
Deprecated | [BLKIO weight options with cgroups v1](#blkio-weight-options–with-cgroups-v1) | v20.10 | -
Expand Down Expand Up @@ -98,12 +98,12 @@ Removed | [`--api-enable-cors` flag on `dockerd`](#--api-enable-cors-flag-on-
Removed | [`--run` flag on `docker commit`](#--run-flag-on-docker-commit) | v0.10 | v1.13
Removed | [Three arguments form in `docker import`](#three-arguments-form-in-docker-import) | v0.6.7 | v1.12

### Kubernetes stack support
### Kubernetes stack and context support

**Deprecated in Release: v20.10**

Following the deprecation of [Compose on Kubernetes](https://github.com/docker/compose-on-kubernetes), support for
Kubernetes in the `stack` command in the docker CLI is now marked as deprecated as well.
Kubernetes in the `stack` and `context` commands in the docker CLI is now marked as deprecated as well.

### Pulling images from non-compliant image registries

Expand Down
3 changes: 3 additions & 0 deletions docs/yaml/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ func genFlagResult(flags *pflag.FlagSet) []cmdOption {
if _, ok := flag.Annotations["experimental"]; ok {
opt.Experimental = true
}
if _, ok := flag.Annotations["deprecated"]; ok {
opt.Deprecated = true
}
if v, ok := flag.Annotations["version"]; ok {
opt.MinAPIVersion = v[0]
}
Expand Down