kubectl: renmae deprecatedCmd -> deprecatedAlias

This will clear up some of the confusion around the deprecatedCmd /
Deprecated function.
This commit is contained in:
Alexander Campbell 2017-05-19 10:40:21 -07:00
parent 699a3e20ff
commit bf2fc62144

View File

@ -284,7 +284,7 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob
NewCmdCreate(f, out, err),
NewCmdExposeService(f, out),
NewCmdRun(f, in, out, err),
deprecatedCmd("run-container", NewCmdRun(f, in, out, err)),
deprecatedAlias("run-container", NewCmdRun(f, in, out, err)),
set.NewCmdSet(f, out, err),
},
},
@ -302,9 +302,9 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob
Commands: []*cobra.Command{
rollout.NewCmdRollout(f, out, err),
NewCmdRollingUpdate(f, out),
deprecatedCmd("rollingupdate", NewCmdRollingUpdate(f, out)),
deprecatedAlias("rollingupdate", NewCmdRollingUpdate(f, out)),
NewCmdScale(f, out),
deprecatedCmd("resize", NewCmdScale(f, out)),
deprecatedAlias("resize", NewCmdScale(f, out)),
NewCmdAutoscale(f, out),
},
},
@ -313,7 +313,7 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob
Commands: []*cobra.Command{
NewCmdCertificate(f, out),
NewCmdClusterInfo(f, out),
deprecatedCmd("clusterinfo", NewCmdClusterInfo(f, out)),
deprecatedAlias("clusterinfo", NewCmdClusterInfo(f, out)),
NewCmdTop(f, out, err),
NewCmdCordon(f, out),
NewCmdUncordon(f, out),
@ -340,7 +340,7 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob
NewCmdApply(f, out, err),
NewCmdPatch(f, out),
NewCmdReplace(f, out),
deprecatedCmd("update", NewCmdReplace(f, out)),
deprecatedAlias("update", NewCmdReplace(f, out)),
NewCmdConvert(f, out),
},
},
@ -377,7 +377,7 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob
cmds.AddCommand(NewCmdPlugin(f, in, out, err))
cmds.AddCommand(NewCmdVersion(f, out))
cmds.AddCommand(NewCmdApiVersions(f, out))
cmds.AddCommand(deprecatedCmd("apiversions", NewCmdApiVersions(f, out)))
cmds.AddCommand(deprecatedAlias("apiversions", NewCmdApiVersions(f, out)))
cmds.AddCommand(NewCmdOptions())
return cmds
@ -391,10 +391,10 @@ func printDeprecationWarning(command, alias string) {
glog.Warningf("%s is DEPRECATED and will be removed in a future version. Use %s instead.", alias, command)
}
// deprecatedCmd is intended to be used to create a "wrapper" command around an
// existing command. The wrapper works the same but prints a deprecation
// message before running.
func deprecatedCmd(deprecatedVersion string, cmd *cobra.Command) *cobra.Command {
// deprecatedAlias is intended to be used to create a "wrapper" command around
// an existing command. The wrapper works the same but prints a deprecation
// message before running. This command is identical functionality.
func deprecatedAlias(deprecatedVersion string, cmd *cobra.Command) *cobra.Command {
// Have to be careful here because Cobra automatically extracts the name
// of the command from the .Use field.
originalName := cmd.Name()
@ -405,6 +405,9 @@ func deprecatedCmd(deprecatedVersion string, cmd *cobra.Command) *cobra.Command
return cmd
}
// Deprecated is similar to deprecatedAlias, but it is used for deprecations
// that are not simple aliases; this command is actually a different
// (deprecated) codepath.
func Deprecated(baseName, to string, parent, cmd *cobra.Command) string {
cmd.Long = fmt.Sprintf("Deprecated: This command is deprecated, all its functionalities are covered by \"%s %s\"", baseName, to)
cmd.Short = fmt.Sprintf("Deprecated: %s", to)