-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtue.cue
More file actions
53 lines (48 loc) · 991 Bytes
/
Copy pathtue.cue
File metadata and controls
53 lines (48 loc) · 991 Bytes
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
package tue
import (
"tool/cli"
"tool/exec"
"tool/file"
"github.com/abcue/cup"
)
#Command: cup.PrintRun & {
// sync resources by generate, init and apply
"tf-sync": {
gen: exec.Run & {
cmd: "cue cmd tf-gen"
}
init: exec.Run & {
$after: gen
cmd: "terraform init"
}
apply: exec.Run & {
$after: init
cmd: "terraform apply"
}
printR: _
}
// generate main.tf.json for terraform
"tf-gen": {
export: exec.Run & {
cmd: "cue export --out=json"
stdout: string
}
jq: exec.Run & {
cmd: "jq --sort-keys"
stdin: export.stdout
stdout: string
}
save: file.Create & {
filename: "main.tf.json"
contents: jq.stdout
}
print: cli.Print & {
text: "Generating main.tf.json"
}
printR: _
}
// generate all main.tf.json for terraform
"tf-gen-all": cup.RunPrint & {
runP: exec.Run & {cmd: ["sh", "-euc", "find . -type d -not -path '*/.terraform*' -mindepth 1 | xargs -I {} sh -euc 'cd {} && cue cmd tf-gen'"]}
}
}