mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-26 12:02:34 +00:00
kubectl: renmae deprecatedCmd -> deprecatedAlias
This will clear up some of the confusion around the deprecatedCmd / Deprecated function.
This commit is contained in:
parent
699a3e20ff
commit
bf2fc62144
@ -284,7 +284,7 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob
|
|||||||
NewCmdCreate(f, out, err),
|
NewCmdCreate(f, out, err),
|
||||||
NewCmdExposeService(f, out),
|
NewCmdExposeService(f, out),
|
||||||
NewCmdRun(f, in, out, err),
|
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),
|
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{
|
Commands: []*cobra.Command{
|
||||||
rollout.NewCmdRollout(f, out, err),
|
rollout.NewCmdRollout(f, out, err),
|
||||||
NewCmdRollingUpdate(f, out),
|
NewCmdRollingUpdate(f, out),
|
||||||
deprecatedCmd("rollingupdate", NewCmdRollingUpdate(f, out)),
|
deprecatedAlias("rollingupdate", NewCmdRollingUpdate(f, out)),
|
||||||
NewCmdScale(f, out),
|
NewCmdScale(f, out),
|
||||||
deprecatedCmd("resize", NewCmdScale(f, out)),
|
deprecatedAlias("resize", NewCmdScale(f, out)),
|
||||||
NewCmdAutoscale(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{
|
Commands: []*cobra.Command{
|
||||||
NewCmdCertificate(f, out),
|
NewCmdCertificate(f, out),
|
||||||
NewCmdClusterInfo(f, out),
|
NewCmdClusterInfo(f, out),
|
||||||
deprecatedCmd("clusterinfo", NewCmdClusterInfo(f, out)),
|
deprecatedAlias("clusterinfo", NewCmdClusterInfo(f, out)),
|
||||||
NewCmdTop(f, out, err),
|
NewCmdTop(f, out, err),
|
||||||
NewCmdCordon(f, out),
|
NewCmdCordon(f, out),
|
||||||
NewCmdUncordon(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),
|
NewCmdApply(f, out, err),
|
||||||
NewCmdPatch(f, out),
|
NewCmdPatch(f, out),
|
||||||
NewCmdReplace(f, out),
|
NewCmdReplace(f, out),
|
||||||
deprecatedCmd("update", NewCmdReplace(f, out)),
|
deprecatedAlias("update", NewCmdReplace(f, out)),
|
||||||
NewCmdConvert(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(NewCmdPlugin(f, in, out, err))
|
||||||
cmds.AddCommand(NewCmdVersion(f, out))
|
cmds.AddCommand(NewCmdVersion(f, out))
|
||||||
cmds.AddCommand(NewCmdApiVersions(f, out))
|
cmds.AddCommand(NewCmdApiVersions(f, out))
|
||||||
cmds.AddCommand(deprecatedCmd("apiversions", NewCmdApiVersions(f, out)))
|
cmds.AddCommand(deprecatedAlias("apiversions", NewCmdApiVersions(f, out)))
|
||||||
cmds.AddCommand(NewCmdOptions())
|
cmds.AddCommand(NewCmdOptions())
|
||||||
|
|
||||||
return cmds
|
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)
|
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
|
// deprecatedAlias is intended to be used to create a "wrapper" command around
|
||||||
// existing command. The wrapper works the same but prints a deprecation
|
// an existing command. The wrapper works the same but prints a deprecation
|
||||||
// message before running.
|
// message before running. This command is identical functionality.
|
||||||
func deprecatedCmd(deprecatedVersion string, cmd *cobra.Command) *cobra.Command {
|
func deprecatedAlias(deprecatedVersion string, cmd *cobra.Command) *cobra.Command {
|
||||||
// Have to be careful here because Cobra automatically extracts the name
|
// Have to be careful here because Cobra automatically extracts the name
|
||||||
// of the command from the .Use field.
|
// of the command from the .Use field.
|
||||||
originalName := cmd.Name()
|
originalName := cmd.Name()
|
||||||
@ -405,6 +405,9 @@ func deprecatedCmd(deprecatedVersion string, cmd *cobra.Command) *cobra.Command
|
|||||||
return cmd
|
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 {
|
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.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)
|
cmd.Short = fmt.Sprintf("Deprecated: %s", to)
|
||||||
|
Loading…
Reference in New Issue
Block a user