fix kubectl annotate local error
This commit is contained in:
		| @@ -207,9 +207,18 @@ func (o AnnotateOptions) Validate() error { | |||||||
| 	if o.all && len(o.fieldSelector) > 0 { | 	if o.all && len(o.fieldSelector) > 0 { | ||||||
| 		return fmt.Errorf("cannot set --all and --field-selector at the same time") | 		return fmt.Errorf("cannot set --all and --field-selector at the same time") | ||||||
| 	} | 	} | ||||||
|  | 	if !o.local { | ||||||
| 		if len(o.resources) < 1 && cmdutil.IsFilenameSliceEmpty(o.Filenames, o.Kustomize) { | 		if len(o.resources) < 1 && cmdutil.IsFilenameSliceEmpty(o.Filenames, o.Kustomize) { | ||||||
| 			return fmt.Errorf("one or more resources must be specified as <resource> <name> or <resource>/<name>") | 			return fmt.Errorf("one or more resources must be specified as <resource> <name> or <resource>/<name>") | ||||||
| 		} | 		} | ||||||
|  | 	} else { | ||||||
|  | 		if len(o.resources) > 0 { | ||||||
|  | 			return fmt.Errorf("can only use local files by -f rsrc.yaml or --filename=rsrc.json when --local=true is set") | ||||||
|  | 		} | ||||||
|  | 		if cmdutil.IsFilenameSliceEmpty(o.Filenames, o.Kustomize) { | ||||||
|  | 			return fmt.Errorf("one or more files must be specified as -f rsrc.yaml or --filename=rsrc.json") | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| 	if len(o.newAnnotations) < 1 && len(o.removeAnnotations) < 1 { | 	if len(o.newAnnotations) < 1 && len(o.removeAnnotations) < 1 { | ||||||
| 		return fmt.Errorf("at least one annotation update is required") | 		return fmt.Errorf("at least one annotation update is required") | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 zhouya0
					zhouya0