Merge pull request #31604 from ping035627/ping035627-patch-0830-1

Automatic merge from submit-queue

Return all the invalid parameters for set_image

Suggest returning all the invalid parameters for "ImageOptions.Validate()" in set_image.go.
This commit is contained in:
Kubernetes Submit Queue 2016-09-10 09:26:25 -07:00 committed by GitHub
commit 4389446d4e

View File

@ -147,15 +147,16 @@ func (o *ImageOptions) Complete(f *cmdutil.Factory, cmd *cobra.Command, args []s
} }
func (o *ImageOptions) Validate() error { func (o *ImageOptions) Validate() error {
errors := []error{}
if len(o.Resources) < 1 && len(o.Filenames) == 0 { if len(o.Resources) < 1 && len(o.Filenames) == 0 {
return fmt.Errorf("one or more resources must be specified as <resource> <name> or <resource>/<name>") errors = append(errors, fmt.Errorf("one or more resources must be specified as <resource> <name> or <resource>/<name>"))
} }
if len(o.ContainerImages) < 1 { if len(o.ContainerImages) < 1 {
return fmt.Errorf("at least one image update is required") errors = append(errors, fmt.Errorf("at least one image update is required"))
} else if len(o.ContainerImages) > 1 && hasWildcardKey(o.ContainerImages) { } else if len(o.ContainerImages) > 1 && hasWildcardKey(o.ContainerImages) {
return fmt.Errorf("all containers are already specified by *, but saw more than one container_name=container_image pairs") errors = append(errors, fmt.Errorf("all containers are already specified by *, but saw more than one container_name=container_image pairs"))
} }
return nil return utilerrors.NewAggregate(errors)
} }
func (o *ImageOptions) Run() error { func (o *ImageOptions) Run() error {