mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #10585 from caesarxuchao/fix-alias
Add boundary check before accessing os.Args[1]
This commit is contained in:
commit
2e848ed707
@ -41,7 +41,7 @@ func NewCmdApiVersions(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RunApiVersions(f *cmdutil.Factory, out io.Writer) error {
|
func RunApiVersions(f *cmdutil.Factory, out io.Writer) error {
|
||||||
if os.Args[1] == "apiversions" {
|
if len(os.Args) > 1 && os.Args[1] == "apiversions" {
|
||||||
printDeprecationWarning("api-versions", "apiversions")
|
printDeprecationWarning("api-versions", "apiversions")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func NewCmdClusterInfo(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RunClusterInfo(factory *cmdutil.Factory, out io.Writer, cmd *cobra.Command) error {
|
func RunClusterInfo(factory *cmdutil.Factory, out io.Writer, cmd *cobra.Command) error {
|
||||||
if os.Args[1] == "clusterinfo" {
|
if len(os.Args) > 1 && os.Args[1] == "clusterinfo" {
|
||||||
printDeprecationWarning("cluster-info", "clusterinfo")
|
printDeprecationWarning("cluster-info", "clusterinfo")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ func NewCmdReplace(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RunReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string, filenames util.StringList) error {
|
func RunReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string, filenames util.StringList) error {
|
||||||
if os.Args[1] == "update" {
|
if len(os.Args) > 1 && os.Args[1] == "update" {
|
||||||
printDeprecationWarning("replace", "update")
|
printDeprecationWarning("replace", "update")
|
||||||
}
|
}
|
||||||
schema, err := f.Validator()
|
schema, err := f.Validator()
|
||||||
|
@ -105,7 +105,7 @@ func validateArguments(cmd *cobra.Command, args []string) (deploymentKey, filena
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) error {
|
func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) error {
|
||||||
if os.Args[1] == "rollingupdate" {
|
if len(os.Args) > 1 && os.Args[1] == "rollingupdate" {
|
||||||
printDeprecationWarning("rolling-update", "rollingupdate")
|
printDeprecationWarning("rolling-update", "rollingupdate")
|
||||||
}
|
}
|
||||||
deploymentKey, filename, image, oldName, err := validateArguments(cmd, args)
|
deploymentKey, filename, image, oldName, err := validateArguments(cmd, args)
|
||||||
|
@ -70,7 +70,7 @@ func NewCmdRun(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Run(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) error {
|
func Run(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) error {
|
||||||
if os.Args[1] == "run-container" {
|
if len(os.Args) > 1 && os.Args[1] == "run-container" {
|
||||||
printDeprecationWarning("run", "run-container")
|
printDeprecationWarning("run", "run-container")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ func NewCmdScale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
|||||||
|
|
||||||
// RunScale executes the scaling
|
// RunScale executes the scaling
|
||||||
func RunScale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) error {
|
func RunScale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) error {
|
||||||
if os.Args[1] == "resize" {
|
if len(os.Args) > 1 && os.Args[1] == "resize" {
|
||||||
printDeprecationWarning("scale", "resize")
|
printDeprecationWarning("scale", "resize")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user