Merge pull request #97440 from pandaamanda/kubectl_label_errorlog

fix kubectl label error when local=true is set.

Kubernetes-commit: 815d7769f32b10469b2aa9fd6a02e1efabb57d4c
This commit is contained in:
Kubernetes Publisher 2021-01-05 07:03:58 -08:00
commit 73dbcbddc7
4 changed files with 18 additions and 9 deletions

2
Godeps/Godeps.json generated
View File

@ -928,7 +928,7 @@
},
{
"ImportPath": "k8s.io/apimachinery",
"Rev": "15c5dba13c59"
"Rev": "0ca7b349afd2"
},
{
"ImportPath": "k8s.io/cli-runtime",

4
go.mod
View File

@ -35,7 +35,7 @@ require (
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd
gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.0.0-20201218085720-9c6b1a9487e0
k8s.io/apimachinery v0.0.0-20201209085528-15c5dba13c59
k8s.io/apimachinery v0.0.0-20210103120354-0ca7b349afd2
k8s.io/cli-runtime v0.0.0-20201218091240-9547a43879a0
k8s.io/client-go v0.0.0-20201229090012-e9d996dae239
k8s.io/component-base v0.0.0-20201217090229-e05af43f81e2
@ -50,7 +50,7 @@ require (
replace (
k8s.io/api => k8s.io/api v0.0.0-20201218085720-9c6b1a9487e0
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20201209085528-15c5dba13c59
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20210103120354-0ca7b349afd2
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20201218091240-9547a43879a0
k8s.io/client-go => k8s.io/client-go v0.0.0-20201229090012-e9d996dae239
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20201211071722-8cc0d294774b

2
go.sum
View File

@ -633,7 +633,7 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.0.0-20201218085720-9c6b1a9487e0/go.mod h1:RfHTN0YuX1yj8GjBNCMS6JbbdmX/jjszu9vXIt47SpM=
k8s.io/apimachinery v0.0.0-20201209085528-15c5dba13c59/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU=
k8s.io/apimachinery v0.0.0-20210103120354-0ca7b349afd2/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU=
k8s.io/cli-runtime v0.0.0-20201218091240-9547a43879a0/go.mod h1:YGZiEr0qwB6XSdVC2kbXtQG/+bm7+18eWKXckr167Io=
k8s.io/client-go v0.0.0-20201229090012-e9d996dae239/go.mod h1:QnFOWF5TLJOP+E4gUNVwc3EPtaB+ZB8WGcyyBDoOHyI=
k8s.io/code-generator v0.0.0-20201211071722-8cc0d294774b/go.mod h1:UsqdF+VX4PU2g46NC2JRs4gc+IfrctnwHb76RNbWHJg=

View File

@ -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")