diff --git a/cmd/kubeadm/app/cmd/alpha/alpha.go b/cmd/kubeadm/app/cmd/alpha/alpha.go index a8a980fb145..b3e68bd9f54 100644 --- a/cmd/kubeadm/app/cmd/alpha/alpha.go +++ b/cmd/kubeadm/app/cmd/alpha/alpha.go @@ -29,32 +29,29 @@ func NewCmdAlpha(in io.Reader, out io.Writer) *cobra.Command { Short: "Kubeadm experimental sub-commands", } - cmd.AddCommand(newCmdKubeConfigUtility(out)) + kubeconfigCmd := NewCmdKubeConfigUtility(out) + deprecateCommand(`please use the same command under "kubeadm kubeconfig"`, kubeconfigCmd) + cmd.AddCommand(kubeconfigCmd) const shDeprecatedMessage = "self-hosting support in kubeadm is deprecated " + "and will be removed in a future release" shCommand := newCmdSelfhosting(in) - shCommand.Deprecated = shDeprecatedMessage - for _, cmd := range shCommand.Commands() { - cmd.Deprecated = shDeprecatedMessage - } + deprecateCommand(shDeprecatedMessage, shCommand) cmd.AddCommand(shCommand) certsCommand := NewCmdCertsUtility(out) - deprecateCertsCommand(certsCommand) + deprecateCommand(`please use the same command under "kubeadm certs"`, certsCommand) cmd.AddCommand(certsCommand) return cmd } -func deprecateCertsCommand(cmds ...*cobra.Command) { - const deprecatedMessage = "please use the same command under \"kubeadm certs\"" - +func deprecateCommand(msg string, cmds ...*cobra.Command) { for _, cmd := range cmds { - cmd.Deprecated = deprecatedMessage + cmd.Deprecated = msg childCmds := cmd.Commands() if len(childCmds) > 0 { - deprecateCertsCommand(childCmds...) + deprecateCommand(msg, childCmds...) } } } diff --git a/cmd/kubeadm/app/cmd/alpha/kubeconfig.go b/cmd/kubeadm/app/cmd/alpha/kubeconfig.go index aa168b85850..925636e969d 100644 --- a/cmd/kubeadm/app/cmd/alpha/kubeconfig.go +++ b/cmd/kubeadm/app/cmd/alpha/kubeconfig.go @@ -43,8 +43,8 @@ var ( `) ) -// newCmdKubeConfigUtility returns main command for kubeconfig phase -func newCmdKubeConfigUtility(out io.Writer) *cobra.Command { +// NewCmdKubeConfigUtility returns main command for kubeconfig phase +func NewCmdKubeConfigUtility(out io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "kubeconfig", Short: "Kubeconfig file utilities", diff --git a/cmd/kubeadm/app/cmd/cmd.go b/cmd/kubeadm/app/cmd/cmd.go index 81a84c94603..7fd62877bb5 100644 --- a/cmd/kubeadm/app/cmd/cmd.go +++ b/cmd/kubeadm/app/cmd/cmd.go @@ -95,6 +95,9 @@ func NewKubeadmCommand(in io.Reader, out, err io.Writer) *cobra.Command { // TODO: remove "certs" from "alpha" // https://github.com/kubernetes/kubeadm/issues/2291 cmds.AddCommand(alpha.NewCmdCertsUtility(out)) + // TODO: remove "kubeconfig" from "alpha" + // https://github.com/kubernetes/kubeadm/issues/2292 + cmds.AddCommand(alpha.NewCmdKubeConfigUtility(out)) return cmds }