-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump_tool.cue
82 lines (72 loc) · 1.73 KB
/
dump_tool.cue
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
package scripts
import "tool/cli"
import "tool/file"
import "tool/exec"
import "path"
import "strings"
args: {
env: string | *"preprod" @tag(env,short=prod|preprod)
}
command: sloth: {
// create output dir for kubectl and debug
mkdirsloth: file.MkdirAll & {
path: "./_sloth_raw/"
}
mkdirgen: file.MkdirAll & {
path: "./_gen/"
}
// generate sloth manifest from cue
list: file.Glob & {
glob: "./values/**/**_sloth.cue"
}
for _, filepath in list.files {
(filepath): {
echo: exec.Run & {
cmd: ["cue", "export", "./" + filepath, "--out", "yaml", "-t", "env=\(args.env)", ]
stdout: string
}
write: file.Create & {
filename: "./_sloth_raw/" + strings.Replace(path.Base(filepath), ".cue", ".yaml", -1)
contents: echo.stdout
}
}
}
// generate customprometheusrule from sloth manifest
listslothraw: file.Glob & {
glob: "./_sloth_raw/**_sloth.yaml"
}
for _, filepath in listslothraw.files {
(filepath): {
echo: exec.Run & {
cmd: ["sloth", "generate", "-i", "./" + filepath]
stdout: string
}
write: file.Create & {
filename: "./_gen/" + path.Base(filepath)
contents: strings.Replace(strings.Replace(echo.stdout, "apiVersion: monitoring.coreos.com/v1", "apiVersion: deckhouse.io/v1alpha1", -1), "kind: PrometheusRule", "kind: CustomPrometheusRules", -1)
}
}
}
}
// TODO
command: alert: {
list: file.Glob & {
glob: "./values/**/**_alert.cue"
}
for _, filepath in list.files {
(filepath): {
echo: exec.Run & {
// note the reference to ask and city here
cmd: ["cue", "export", "./" + filepath, "--out", "yaml"]
stdout: string
}
read: file.Read & {
filename: filepath
contents: string
}
print: cli.Print & {
text: echo.stdout + "---"
}
}
}
}