Merge pull request #30497 from ping035627/ping035627-patch-0811

Automatic merge from submit-queue

Add validation conditions for autoscale

When validate the value of max and min in autoscale.go, it should append all the invalid conditions to errs, and print the value.
This commit is contained in:
Kubernetes Submit Queue 2016-08-17 00:55:29 -07:00 committed by GitHub
commit c07ef7163c

View File

@ -198,9 +198,10 @@ func validateFlags(cmd *cobra.Command) error {
errs := []error{}
max, min := cmdutil.GetFlagInt(cmd, "max"), cmdutil.GetFlagInt(cmd, "min")
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"))
errs = append(errs, fmt.Errorf("--max=MAXPODS is required and must be at least 1, max: %d", max))
}
if max < min {
errs = append(errs, fmt.Errorf("--max=MAXPODS must be larger or equal to --min=MINPODS, max: %d, min: %d", max, min))
}
return utilerrors.NewAggregate(errs)
}