From e3a9054ad108c96c6caeb1492bbc8af389ceb758 Mon Sep 17 00:00:00 2001 From: Xing Zhou Date: Mon, 29 Aug 2016 14:32:59 +0800 Subject: [PATCH] Fixed 'taint' command to support resource aliases. This patch fixed kubectl 'taint' command to support resource "node"'s aliaes, including "no" and "nodes". Fixes #25287 --- pkg/kubectl/cmd/taint.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl/cmd/taint.go b/pkg/kubectl/cmd/taint.go index 05be8a5bd2b7..a794a7184b7d 100644 --- a/pkg/kubectl/cmd/taint.go +++ b/pkg/kubectl/cmd/taint.go @@ -282,8 +282,15 @@ func (o *TaintOptions) Complete(f *cmdutil.Factory, out io.Writer, cmd *cobra.Co // Validate checks to the TaintOptions to see if there is sufficient information run the command. func (o TaintOptions) Validate(args []string) error { resourceType := strings.ToLower(o.resources[0]) - if resourceType != "node" && resourceType != "nodes" { - return fmt.Errorf("invalid resource type %s, only node(s) is supported", o.resources[0]) + validResources, isValidResource := append(kubectl.ResourceAliases([]string{"node"}), "node"), false + for _, validResource := range validResources { + if resourceType == validResource { + isValidResource = true + break + } + } + if !isValidResource { + return fmt.Errorf("invalid resource type %s, only %q are supported", o.resources[0], validResources) } // check the format of taint args and checks removed taints aren't in the new taints list