Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e3a9054

Browse files
committed
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
1 parent 1f13a4c commit e3a9054

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

pkg/kubectl/cmd/taint.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,15 @@ func (o *TaintOptions) Complete(f *cmdutil.Factory, out io.Writer, cmd *cobra.Co
282282
// Validate checks to the TaintOptions to see if there is sufficient information run the command.
283283
func (o TaintOptions) Validate(args []string) error {
284284
resourceType := strings.ToLower(o.resources[0])
285-
if resourceType != "node" && resourceType != "nodes" {
286-
return fmt.Errorf("invalid resource type %s, only node(s) is supported", o.resources[0])
285+
validResources, isValidResource := append(kubectl.ResourceAliases([]string{"node"}), "node"), false
286+
for _, validResource := range validResources {
287+
if resourceType == validResource {
288+
isValidResource = true
289+
break
290+
}
291+
}
292+
if !isValidResource {
293+
return fmt.Errorf("invalid resource type %s, only %q are supported", o.resources[0], validResources)
287294
}
288295

289296
// check the format of taint args and checks removed taints aren't in the new taints list

0 commit comments

Comments
 (0)