-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsynth_tool.cue
68 lines (63 loc) · 1.89 KB
/
synth_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 netserv
import (
"tool/exec"
"tool/file"
"tool/os"
"strings"
//"path"
//"list"
//"crypto/sha256"
//"encoding/hex"
"encoding/yaml"
//"encoding/json"
)
outputDir: string & strings.MinRunes(1) @tag(outputDir)
#FluxResourceOrdering: {
_obj: {apiVersion: string}
order: [
if strings.HasPrefix(_obj.apiVersion, "source.toolkit.fluxcd.io/") {-1},
0,
][0]
}
command: synth: {
envVars: os.Environ
for kustomizationName, kustomization in kustomizations {
(kustomizationName): {
_kustomizationSubdir: "\(appName)\([if kustomizationName == "$default" {""}, "-" + kustomizationName][0])"
kustomizationDir: file.Mkdir & {
createParents: true
permissions: 0o777
path: "\(outputDir)/\(_kustomizationSubdir)"
}
for output, input in kustomization._extraManifests {
"manifest:\(output)": exec.Run & {
$after: [kustomizationDir]
cmd: ["cp", input, "\(kustomizationDir.path)/\(output)"]
}
}
for manifestName, manifest in kustomization {
"manifest:\(manifestName)": file.Create & {
$after: [kustomizationDir]
filename: "\(kustomizationDir.path)/\(manifestName)"
contents: yaml.MarshalStream([
for _, r in manifest.clusterResources {r},
for _, r in manifest.resources {r},
])
}
}
oci: exec.Run & {
$after: [
for output, _ in kustomization._extraManifests { command.synth["manifest:\(output)"] },
for manifestName, _ in kustomization { command.synth["manifest:\(manifestName)"] },
]
cmd: ["bash", "./tools/scripts/build_manifest_oci.sh", "\(outputDir)/\(_kustomizationSubdir)"]
env: {
out: "\(outputDir)/oci/\(_kustomizationSubdir)"
for k, v in envVars if k !~"^[$]" && k != "out" {
(k): v
}
}
}
}
}
}