Merge pull request #86952 from zhouya0/fix_kubectl_annotate_local_error

fix kubectl annotate error when local=true is set.
This commit is contained in:
Kubernetes Prow Robot 2020-01-09 11:33:20 -08:00 committed by GitHub
commit 6026a6a151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -207,8 +207,17 @@ func (o AnnotateOptions) Validate() error {
if o.all && len(o.fieldSelector) > 0 {
return fmt.Errorf("cannot set --all and --field-selector at the same time")
}
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>")
if !o.local {
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>")
}
} 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 {
return fmt.Errorf("at least one annotation update is required")