Skip to content

Commit

Permalink
Fixed 'taint' command to support resource aliases.
Browse files Browse the repository at this point in the history
This patch fixed kubectl 'taint' command to support
resource "node"'s aliaes, including "no" and "nodes".

Fixes #25287
  • Loading branch information
xingzhou committed Aug 29, 2016
1 parent 1f13a4c commit e3a9054
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/kubectl/cmd/taint.go
Expand Up @@ -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
Expand Down

0 comments on commit e3a9054

Please sign in to comment.