-
Notifications
You must be signed in to change notification settings - Fork 327
/
main.go
104 lines (94 loc) · 2.29 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package main
import (
"io/ioutil"
"os"
"tkestack.io/tke/cmd/tke-upgrade/app/options"
"tkestack.io/tke/pkg/util/log"
"tkestack.io/tke/pkg/util/template"
)
var (
DataDir string
Manifests string
Output string
Version string
)
func main() {
DataDir = os.Getenv("DATADIR")
Manifests = os.Getenv("MANIFESTS")
Output = os.Getenv("OUTPUT")
Version = os.Getenv("VERSION")
if DataDir == "" {
log.Error("Please configure environment variables: DATADIR")
return
}
if Manifests == "" {
log.Error("Please configure environment variables: MANIFESTS")
return
}
if Output == "" {
log.Error("Please configure environment variables: OUTPUT")
return
}
if Version == "" {
log.Error("Please configure environment variables: VERSION")
return
}
client := options.New(DataDir, Version)
client.Init()
dir, err := ioutil.ReadDir(Manifests)
if err != nil {
log.Error(err.Error())
return
}
_, err = os.Stat(Output)
if os.IsNotExist(err) {
err = os.MkdirAll(Output, os.ModePerm)
if err != nil {
log.Error(err.Error())
return
}
}
for _, d := range dir {
component := d.Name()
filePath := Manifests + "/" + component + "/" + component + ".yaml"
var option options.Options
switch component {
case "etcd":
option = client.ETCD()
case "influxdb":
option = client.InfluxDB()
case "tke-auth-api":
option = client.TKEAuthAPI()
case "tke-auth-controller":
option = client.TKEAuthController()
case "tke-business-api":
option = client.TKEBusinessAPI()
case "tke-business-controller":
option = client.TKEBusinessController()
case "tke-gateway":
option = client.TKEGateway()
case "tke-monitor-api":
option = client.TKEMonitorAPI()
case "tke-monitor-controller":
option = client.TKEMonitorController()
case "tke-notify-api":
option = client.TKENotifyAPI()
case "tke-notify-controller":
option = client.TKENotifyController()
case "tke-platform-api":
option = client.TKEPlatformAPI()
case "tke-platform-controller":
option = client.TKEPlatformController()
}
if option != nil {
yaml, _ := template.ParseFile(filePath, option)
fileName := Output + "/" + component + ".yaml"
err := ioutil.WriteFile(fileName, yaml, 0644)
if err != nil {
log.Error(err.Error())
return
}
log.Info(fileName + " is Created")
}
}
}