-
Notifications
You must be signed in to change notification settings - Fork 8
/
uninstall.go
69 lines (63 loc) · 1.66 KB
/
uninstall.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
64
65
66
67
68
69
package kubernetes
import (
"fmt"
"os"
"time"
"github.com/tkeel-io/cli/fileutil"
"github.com/tkeel-io/cli/pkg/print"
helm "helm.sh/helm/v3/pkg/action"
)
// UninstallPlatform removes tKeel from a Kubernetes cluster.
func UninstallPlatform(namespace string, timeout uint, debugMode bool) error {
config, err := InitHelmConfig(namespace, getLog(debugMode))
if err != nil {
return err
}
uninstallClient := helm.NewUninstall(config)
uninstallClient.Timeout = time.Duration(timeout) * time.Second
_, err = uninstallClient.Run(tKeelReleaseName)
if err != nil {
return fmt.Errorf("helm uninstall err:%w", err)
}
_, err = uninstallClient.Run(fmt.Sprintf("tkeel-%s", tkeelCoreHelmChart))
if err != nil {
return fmt.Errorf("helm uninstall err:%w", err)
}
_, err = uninstallClient.Run(fmt.Sprintf("tkeel-%s", tkeelRudderHelmChart))
if err != nil {
return fmt.Errorf("helm uninstall err:%w", err)
}
_, err = uninstallClient.Run(tKeelMiddlewareReleaseName)
if err != nil {
return fmt.Errorf("helm uninstall err:%w", err)
}
return nil
}
func UninstallAllPlugin() error {
pluginList, err := InstalledPlugin()
if err != nil {
return err
}
for _, plugin := range pluginList {
// TODO 为所有租户禁用插件
tenantList, err := TenantPluginList(plugin.Name)
if err != nil {
return err
}
print.InfoStatusEvent(os.Stdout, "Removing plugin %s ...", plugin.Name)
for _, tenant := range tenantList {
err = DisablePlugin(plugin.Name, tenant.ID)
if err != nil {
return err
}
}
err = UninstallPlugin(plugin.Name)
if err != nil {
return err
}
}
return nil
}
func CleanToken() {
_, _ = fileutil.LocateAdminToken(fileutil.RewriteFlag())
}