fix kubectl label error when local=true is set.
fix kubectl label error when local=true is set. fix kubectl label error when local=true is set. Kubernetes-commit: cb7009a63bbc90569493f070463ae6715088d46a
This commit is contained in:
parent
89cc98529f
commit
13d5d50660
|
@ -213,17 +213,26 @@ func (o *LabelOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
|
|||
|
||||
// Validate checks to the LabelOptions to see if there is sufficient information run the command.
|
||||
func (o *LabelOptions) Validate() error {
|
||||
if o.local && o.dryRunStrategy == cmdutil.DryRunServer {
|
||||
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
|
||||
}
|
||||
if o.all && len(o.selector) > 0 {
|
||||
return fmt.Errorf("cannot set --all and --selector at the same time")
|
||||
}
|
||||
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.FilenameOptions.Filenames, o.FilenameOptions.Kustomize) {
|
||||
return fmt.Errorf("one or more resources must be specified as <resource> <name> or <resource>/<name>")
|
||||
if o.local {
|
||||
if o.dryRunStrategy == cmdutil.DryRunServer {
|
||||
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
|
||||
}
|
||||
if len(o.resources) > 0 {
|
||||
return fmt.Errorf("can only use local files by -f pod.yaml or --filename=pod.json when --local=true is set")
|
||||
}
|
||||
if cmdutil.IsFilenameSliceEmpty(o.FilenameOptions.Filenames, o.FilenameOptions.Kustomize) {
|
||||
return fmt.Errorf("one or more files must be specified as -f pod.yaml or --filename=pod.json")
|
||||
}
|
||||
} else {
|
||||
if len(o.resources) < 1 && cmdutil.IsFilenameSliceEmpty(o.FilenameOptions.Filenames, o.FilenameOptions.Kustomize) {
|
||||
return fmt.Errorf("one or more resources must be specified as <resource> <name> or <resource>/<name>")
|
||||
}
|
||||
}
|
||||
if len(o.newLabels) < 1 && len(o.removeLabels) < 1 && !o.list {
|
||||
return fmt.Errorf("at least one label update is required")
|
||||
|
|
Loading…
Reference in New Issue