Merge pull request #27844 from hodovska/1336632-hpa_flag_tips

Automatic merge from submit-queue

kubectl/autoscale: fix tips when validating --max flag

While autoscaling, it was not clear what was the reason of failed --max flag validation.
This fix divides reasons to:
- value not provided or too low
- value of max is lower than value of min

bug 1336632
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1336632
This commit is contained in:
k8s-merge-robot 2016-07-06 08:40:14 -07:00 committed by GitHub
commit c0579af684

View File

@ -197,8 +197,10 @@ func RunAutoscale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []
func validateFlags(cmd *cobra.Command) error {
errs := []error{}
max, min := cmdutil.GetFlagInt(cmd, "max"), cmdutil.GetFlagInt(cmd, "min")
if max < 1 || max < min {
errs = append(errs, fmt.Errorf("--max=MAXPODS is required, and must be at least 1 and --min=MINPODS"))
if max < 1 {
errs = append(errs, fmt.Errorf("--max=MAXPODS is required and must be at least 1"))
} else if max < min {
errs = append(errs, fmt.Errorf("--max=MAXPODS must be larger or equal to --min=MINPODS"))
}
return utilerrors.NewAggregate(errs)
}