mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #87423 from soltysh/fix_tain_validation
Fix kubectl taint's Complete parsing
This commit is contained in:
commit
29b09c7fb1
@ -129,7 +129,7 @@ func (o *TaintOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
|
||||
taintArgs := []string{}
|
||||
metTaintArg := false
|
||||
for _, s := range args {
|
||||
isTaint := strings.Contains(s, "=") || strings.HasSuffix(s, "-")
|
||||
isTaint := strings.Contains(s, "=") || strings.Contains(s, ":") || strings.HasSuffix(s, "-")
|
||||
switch {
|
||||
case !metTaintArg && isTaint:
|
||||
metTaintArg = true
|
||||
|
@ -74,11 +74,16 @@ __EOF__
|
||||
# taint/untaint
|
||||
# Pre-condition: node doesn't have dedicated=foo:PreferNoSchedule taint
|
||||
kube::test::get_object_assert "nodes 127.0.0.1" '{{range .spec.taints}}{{if eq .key \"dedicated\"}}{{.key}}={{.value}}:{{.effect}}{{end}}{{end}}' "" # expect no output
|
||||
# taint can add a taint
|
||||
# taint can add a taint (<key>=<value>:<effect>)
|
||||
kubectl taint node 127.0.0.1 dedicated=foo:PreferNoSchedule
|
||||
kube::test::get_object_assert "nodes 127.0.0.1" '{{range .spec.taints}}{{if eq .key \"dedicated\"}}{{.key}}={{.value}}:{{.effect}}{{end}}{{end}}' "dedicated=foo:PreferNoSchedule"
|
||||
# taint can remove a taint
|
||||
kubectl taint node 127.0.0.1 dedicated-
|
||||
# taint can add a taint (<key>:<effect>)
|
||||
kubectl taint node 127.0.0.1 dedicated:PreferNoSchedule
|
||||
kube::test::get_object_assert "nodes 127.0.0.1" '{{range .spec.taints}}{{if eq .key \"dedicated\"}}{{.key}}={{.value}}:{{.effect}}{{end}}{{end}}' "dedicated=<no value>:PreferNoSchedule"
|
||||
# taint can remove a taint
|
||||
kubectl taint node 127.0.0.1 dedicated-
|
||||
# Post-condition: node doesn't have dedicated=foo:PreferNoSchedule taint
|
||||
kube::test::get_object_assert "nodes 127.0.0.1" '{{range .spec.taints}}{{if eq .key \"dedicated\"}}{{.key}}={{.value}}:{{.effect}}{{end}}{{end}}' "" # expect no output
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user