Skip to content

Commit

Permalink
Added 'ValidArgs' and 'ArgAliases' for several kubectl commands.
Browse files Browse the repository at this point in the history
Added 'ValidArgs' and 'ArgAliases' for the following comands:
  • kubectl scale
  • kubectl autoscale
  • kubectl rollout *

Fixed 'ValidArgs' and 'ArgAliases' for 'kubectl taint' command.
  • Loading branch information
xingzhou committed Aug 29, 2016
1 parent 839adf9 commit 1f13a4c
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 10 deletions.
5 changes: 5 additions & 0 deletions pkg/kubectl/cmd/autoscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ var (
func NewCmdAutoscale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
options := &AutoscaleOptions{}

validArgs := []string{"deployment", "replicaset", "replicationcontroller"}
argAliases := kubectl.ResourceAliases(validArgs)

cmd := &cobra.Command{
Use: "autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU] [flags]",
Short: "Auto-scale a Deployment, ReplicaSet, or ReplicationController",
Expand All @@ -64,6 +67,8 @@ func NewCmdAutoscale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
err := RunAutoscale(f, out, cmd, args, options)
cmdutil.CheckErr(err)
},
ValidArgs: validArgs,
ArgAliases: argAliases,
}
cmdutil.AddPrinterFlags(cmd)
cmd.Flags().String("generator", "horizontalpodautoscaler/v1", "The name of the API generator to use. Currently there is only 1 generator.")
Expand Down
5 changes: 5 additions & 0 deletions pkg/kubectl/cmd/rollout/rollout_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ var (
func NewCmdRolloutHistory(f *cmdutil.Factory, out io.Writer) *cobra.Command {
options := &HistoryOptions{}

validArgs := []string{"deployment"}
argAliases := kubectl.ResourceAliases(validArgs)

cmd := &cobra.Command{
Use: "history (TYPE NAME | TYPE/NAME) [flags]",
Short: "View rollout history",
Expand All @@ -57,6 +60,8 @@ func NewCmdRolloutHistory(f *cmdutil.Factory, out io.Writer) *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(RunHistory(f, cmd, out, args, options))
},
ValidArgs: validArgs,
ArgAliases: argAliases,
}

cmd.Flags().Int64("revision", 0, "See the details, including podTemplate of the revision specified")
Expand Down
5 changes: 5 additions & 0 deletions pkg/kubectl/cmd/rollout/rollout_pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ var (
func NewCmdRolloutPause(f *cmdutil.Factory, out io.Writer) *cobra.Command {
opts := &PauseConfig{}

validArgs := []string{"deployment"}
argAliases := kubectl.ResourceAliases(validArgs)

cmd := &cobra.Command{
Use: "pause RESOURCE",
Short: "Mark the provided resource as paused",
Expand All @@ -78,6 +81,8 @@ func NewCmdRolloutPause(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}
cmdutil.CheckErr(utilerrors.Flatten(utilerrors.NewAggregate(allErrs)))
},
ValidArgs: validArgs,
ArgAliases: argAliases,
}

usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
Expand Down
5 changes: 5 additions & 0 deletions pkg/kubectl/cmd/rollout/rollout_resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ var (
func NewCmdRolloutResume(f *cmdutil.Factory, out io.Writer) *cobra.Command {
opts := &ResumeConfig{}

validArgs := []string{"deployment"}
argAliases := kubectl.ResourceAliases(validArgs)

cmd := &cobra.Command{
Use: "resume RESOURCE",
Short: "Resume a paused resource",
Expand All @@ -76,6 +79,8 @@ func NewCmdRolloutResume(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}
cmdutil.CheckErr(utilerrors.Flatten(utilerrors.NewAggregate(allErrs)))
},
ValidArgs: validArgs,
ArgAliases: argAliases,
}

usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
Expand Down
5 changes: 5 additions & 0 deletions pkg/kubectl/cmd/rollout/rollout_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ var (
func NewCmdRolloutStatus(f *cmdutil.Factory, out io.Writer) *cobra.Command {
options := &StatusOptions{}

validArgs := []string{"deployment"}
argAliases := kubectl.ResourceAliases(validArgs)

cmd := &cobra.Command{
Use: "status (TYPE NAME | TYPE/NAME) [flags]",
Short: "Watch rollout status until it's done",
Expand All @@ -55,6 +58,8 @@ func NewCmdRolloutStatus(f *cmdutil.Factory, out io.Writer) *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(RunStatus(f, cmd, out, args, options))
},
ValidArgs: validArgs,
ArgAliases: argAliases,
}

usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
Expand Down
5 changes: 5 additions & 0 deletions pkg/kubectl/cmd/rollout/rollout_undo.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ var (
func NewCmdRolloutUndo(f *cmdutil.Factory, out io.Writer) *cobra.Command {
opts := &UndoOptions{}

validArgs := []string{"deployment"}
argAliases := kubectl.ResourceAliases(validArgs)

cmd := &cobra.Command{
Use: "undo (TYPE NAME | TYPE/NAME) [flags]",
Short: "Undo a previous rollout",
Expand All @@ -75,6 +78,8 @@ func NewCmdRolloutUndo(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}
cmdutil.CheckErr(utilerrors.Flatten(utilerrors.NewAggregate(allErrs)))
},
ValidArgs: validArgs,
ArgAliases: argAliases,
}

cmd.Flags().Int64("to-revision", 0, "The revision to rollback to. Default to 0 (last revision).")
Expand Down
5 changes: 5 additions & 0 deletions pkg/kubectl/cmd/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ var (
func NewCmdScale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
options := &ScaleOptions{}

validArgs := []string{"deployment", "replicaset", "replicationcontroller", "job"}
argAliases := kubectl.ResourceAliases(validArgs)

cmd := &cobra.Command{
Use: "scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT (-f FILENAME | TYPE NAME)",
// resize is deprecated
Expand All @@ -79,6 +82,8 @@ func NewCmdScale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
err := RunScale(f, out, cmd, args, shortOutput, options)
cmdutil.CheckErr(err)
},
ValidArgs: validArgs,
ArgAliases: argAliases,
}
cmd.Flags().String("resource-version", "", "Precondition for resource version. Requires that the current resource version match this value in order to scale.")
cmd.Flags().Int("current-replicas", -1, "Precondition for current size. Requires that the current size of the resource match this value in order to scale.")
Expand Down
14 changes: 4 additions & 10 deletions pkg/kubectl/cmd/taint.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,8 @@ var (
func NewCmdTaint(f *cmdutil.Factory, out io.Writer) *cobra.Command {
options := &TaintOptions{}

// retrieve a list of handled resources from printer as valid args
validArgs := []string{}
p, err := f.Printer(nil, kubectl.PrintOptions{
ColumnLabels: []string{},
})
cmdutil.CheckErr(err)
if p != nil {
validArgs = p.HandledResources()
}
validArgs := []string{"node"}
argAliases := kubectl.ResourceAliases(validArgs)

cmd := &cobra.Command{
Use: "taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N",
Expand All @@ -102,7 +95,8 @@ func NewCmdTaint(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmdutil.CheckErr(err)
}
},
ValidArgs: validArgs,
ValidArgs: validArgs,
ArgAliases: argAliases,
}
cmdutil.AddValidateFlags(cmd)

Expand Down

0 comments on commit 1f13a4c

Please sign in to comment.