-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_tool.cue
68 lines (59 loc) · 1.48 KB
/
build_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
package fastnetmon
import (
"tool/file"
"tool/exec"
"encoding/json"
)
command: build: tasks: {
for host, cfg in config {
"\(host)": {
build: {
mkdir: {
hostgroup: file.MkdirAll & {
path: "out/\(host)/hostgroup"
}
traffic_rule: file.MkdirAll & {
path: "out/\(host)/traffic_rule"
}
bgp: file.MkdirAll & {
path: "out/\(host)/bgp"
}
}
"main.json": file.Create & {
$after: [ for v in mkdir {v}]
filename: "out/\(host)/main.json"
contents: json.Marshal(cfg.main)
}
for i, group in cfg.hostgroups {
"hostgroup/\(i).json": file.Create & {
$after: mkdir.hostgroup
filename: "out/\(host)/hostgroup/\(i).json"
contents: json.Marshal(group)
}
}
for i, rule in cfg.trafficRules {
"traffic_rule/\(i).json": file.Create & {
$after: mkdir.traffic_rule
filename: "out/\(host)/traffic_rule/\(i).json"
contents: json.Marshal(rule)
}
}
for i, session in cfg.bgpSessions {
"bgp/\(i).json": file.Create & {
$after: mkdir.bgp
filename: "out/\(host)/bgp/\(i).json"
contents: json.Marshal(session)
}
}
}
"\(host).tar": exec.Run & {
$after: build
dir: "out/\(host)"
cmd: ["tar", "-cf", "../\(host).tar", "main.json"] +
[ for i, _ in cfg.hostgroups {"hostgroup/\(i).json"}] +
[ for i, _ in cfg.trafficRules {"traffic_rule/\(i).json"}] +
[ for i, _ in cfg.bgpSessions {"bgp/\(i).json"}]
}
}
}
}