-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmd_kube_delete.go
63 lines (61 loc) · 1.88 KB
/
cmd_kube_delete.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package completer
import (
"github.com/cxweilai/kubectlx/internal/command"
"github.com/cxweilai/kubectlx/internal/ctx"
"github.com/cxweilai/kubectlx/internal/kubecli"
"strings"
)
func NewKubeDeleteCommand() *command.Command {
options := []*command.Option{
{
Name: "--force=true",
Description: "强制删除",
},
}
return &command.Command{
Name: "delete",
Description: "删除资源",
DynamicCommands: func() []*command.Command {
var cmds []*command.Command
for _, rcmd := range kubecli.GetK8sResourceCommand("删除%s资源") {
finalCrd := *rcmd
cmds = append(cmds, &command.Command{
Name: finalCrd.Name,
Description: finalCrd.Description,
DynamicParam: &command.DynamicParam{
Func: func(input string) []*command.Param {
return kubecli.GetK8sResource(finalCrd.Extended["group"], finalCrd.Extended["version"], finalCrd.Name,
ctx.GetNamespace(), input, LIMIT_SUGGEST)
},
Flag: strings.ToUpper(finalCrd.Name) + "_NAME",
Description: "删除" + finalCrd.Name,
},
Run: WarpHelp(func(cmd *command.ExecCmd) {
execKubectl(cmd.Input)
}),
Options: options,
})
}
for _, crd := range kubecli.GetCrdCommand("删除%s资源") {
finalCrd := *crd
cmds = append(cmds, &command.Command{
Name: finalCrd.Name,
Description: finalCrd.Description,
DynamicParam: &command.DynamicParam{
Func: func(input string) []*command.Param {
return kubecli.GetCrdResource(finalCrd.Extended["group"], finalCrd.Extended["version"], finalCrd.Name,
ctx.GetNamespace(), input, LIMIT_SUGGEST)
},
Flag: strings.ToUpper(finalCrd.Name) + "_NAME",
Description: "删除" + finalCrd.Name,
},
Options: options,
Run: WarpHelp(func(cmd *command.ExecCmd) {
execKubectl(cmd.Input)
}),
})
}
return cmds
},
}
}