Automatic merge from release/2.1.0 -> release/2.2.0

* commit '923a5490f9a05a771febf8b5ebc5c82b3f643bb2':
  climc: batch delete k8s resource
This commit is contained in:
邱剑
2018-09-18 16:26:31 +08:00
2 changed files with 47 additions and 2 deletions
+26 -2
View File
@@ -142,7 +142,19 @@ func initK8sClusterResource(kind string, manager modules.Manager) *ShellCommands
return nil
},
)
return NewShellCommands(cmdN).AddR(listCmd, getCmd)
// Delete resource
deleteCmd := NewCommand(
&o.ResourceDeleteOptions{},
cmdN("delete"),
fmt.Sprintf("Delete k8s %s", kind),
func(s *mcclient.ClientSession, args *o.ResourceDeleteOptions) error {
ret := manager.BatchDelete(s, args.NAME, args.Params())
printBatchResults(ret, manager.GetColumns(s))
return nil
},
)
return NewShellCommands(cmdN).AddR(listCmd, getCmd, deleteCmd)
}
func initK8sNamespaceResource(kind string, manager modules.Manager) *ShellCommands {
@@ -179,5 +191,17 @@ func initK8sNamespaceResource(kind string, manager modules.Manager) *ShellComman
return nil
},
)
return NewShellCommands(cmdN).AddR(listCmd, getCmd)
// Delete resource
deleteCmd := NewCommand(
&o.NamespaceResourceDeleteOptions{},
cmdN("delete"),
fmt.Sprintf("Delete k8s %s", kind),
func(s *mcclient.ClientSession, args *o.NamespaceResourceDeleteOptions) error {
ret := manager.BatchDelete(s, args.NAME, args.Params())
printBatchResults(ret, manager.GetColumns(s))
return nil
},
)
return NewShellCommands(cmdN).AddR(listCmd, getCmd, deleteCmd)
}
+21
View File
@@ -55,6 +55,16 @@ func (o ResourceGetOptions) Params() *jsonutils.JSONDict {
return params
}
type ResourceDeleteOptions struct {
ClusterBaseOptions
NAME []string `help:"Name ident of the resources"`
}
func (o ResourceDeleteOptions) Params() *jsonutils.JSONDict {
params := o.ClusterBaseOptions.Params()
return params
}
type NamespaceResourceListOptions struct {
ResourceListOptions
Namespace string `help:"Namespace of this resource"`
@@ -96,6 +106,17 @@ func (o NamespaceResourceGetOptions) Params() *jsonutils.JSONDict {
return params
}
type NamespaceResourceDeleteOptions struct {
ResourceDeleteOptions
NamespaceOptions
}
func (o NamespaceResourceDeleteOptions) Params() *jsonutils.JSONDict {
params := o.ResourceDeleteOptions.Params()
params.Update(o.NamespaceOptions.Params())
return params
}
type NamespaceWithClusterOptions struct {
NamespaceOptions
ClusterBaseOptions