mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 18:54:06 +00:00
update resource selector - kubectl drain
This commit is contained in:
parent
78ada62c30
commit
ee2f9c95e7
@ -237,20 +237,18 @@ func (o *DrainOptions) SetupDrain(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
nameArgs := []string{"nodes"}
|
builder := o.Factory.NewBuilder().
|
||||||
if len(args) > 0 {
|
NamespaceParam(cmdNamespace).DefaultNamespace().
|
||||||
nameArgs = append(nameArgs, args[0])
|
ResourceNames("nodes", args...).
|
||||||
if strings.Contains(args[0], "/") {
|
SingleResourceType().
|
||||||
nameArgs = []string{args[0]}
|
Flatten()
|
||||||
}
|
|
||||||
|
if len(o.Selector) > 0 {
|
||||||
|
builder = builder.SelectorParam(o.Selector).
|
||||||
|
ResourceTypes("nodes")
|
||||||
}
|
}
|
||||||
|
|
||||||
r := o.Factory.NewBuilder().
|
r := builder.Do()
|
||||||
NamespaceParam(cmdNamespace).DefaultNamespace().
|
|
||||||
SelectorParam(o.Selector).
|
|
||||||
ResourceTypeOrNameArgs(true, nameArgs...).
|
|
||||||
Flatten().
|
|
||||||
Do()
|
|
||||||
|
|
||||||
if err = r.Err(); err != nil {
|
if err = r.Err(); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -260,6 +258,10 @@ func (o *DrainOptions) SetupDrain(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if info.Mapping.Resource != "nodes" {
|
||||||
|
return fmt.Errorf("error: expected resource of type node, got %q", info.Mapping.Resource)
|
||||||
|
}
|
||||||
|
|
||||||
o.nodeInfos = append(o.nodeInfos, info)
|
o.nodeInfos = append(o.nodeInfos, info)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user