-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddcompose.cue
132 lines (120 loc) · 2.95 KB
/
ddcompose.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package ddcompose
import (
"dagger.io/dagger"
)
#DDCompose: {
manifests: [...#Manifest]
sops: {
config: bool | *false
age: bool | *false
}
docker: config: bool | *false
builders: bool | *false
plan: dagger.#Plan & {
client: filesystem: {
"manifests": read: contents: dagger.#FS
if builders {
"builders": read: contents: dagger.#FS
}
".ssh": read: {
contents: dagger.#FS
exclude: ["id_rsa"]
}
".ssh/id_rsa": read: contents: dagger.#Secret
if sops.config {
".sops.yaml": read: {
contents: dagger.#FS
path: "."
include: [".sops.yaml"]
}
}
if sops.age {
".sops/age/keys.txt": read: contents: dagger.#Secret
}
if docker.config {
".docker/config.json": read: contents: dagger.#Secret
}
}
client: env: {
PWD: string
HOME: string
}
client: network: "unix:///var/run/docker.sock": connect: dagger.#Socket
actions: fenvname: #FenvName & {
"manifests": [
for manifest in manifests {
manifest & {
source: client.filesystem."manifests".read.contents
}
},
]
if sops.age {
sops: age: client.filesystem.".sops/age/keys.txt".read.contents
}
}
if builders {
actions: build: #Terraform & {
manifests: client.filesystem."manifests".read.contents
source: client.filesystem."builders".read.contents
"sops": {
if sops.config {
config: client.filesystem.".sops.yaml".read.contents
}
if sops.age {
age: client.filesystem.".sops/age/keys.txt".read.contents
}
}
}
}
actions: deploy: {
_compose: {
ssh: {
config: client.filesystem.".ssh".read.contents
privateKey: client.filesystem.".ssh/id_rsa".read.contents
}
if sops.age {
sops: age: client.filesystem.".sops/age/keys.txt".read.contents
}
if docker.config {
docker: config: client.filesystem.".docker/config.json".read.contents
}
env: {
DDCOMPOSE_PWD: client.env.PWD
DDCOMPOSE_HOME: client.env.HOME
}
}
for manifest in manifests {
(manifest.name): {
if manifest.remoteHost != _|_ && manifest.remotePath != _|_ {
(manifest.remoteHost): (manifest.remotePath): #Compose & _compose & {
"manifest": manifest & {
source: client.filesystem."manifests".read.contents
}
}
}
if manifest.remoteHost == _|_ || manifest.remotePath == _|_ {
"_": "_": #Compose & _compose & {
"manifest": manifest & {
source: client.filesystem."manifests".read.contents
}
docker: socket: client.network."unix:///var/run/docker.sock".connect
}
}
}
}
}
client: filesystem: {
"_output": write: contents: actions.fenvname.export.directories."/tmp/fenv.txt"
if builders {
"builders_output": write: {
contents: actions.build.output.source
path: "builders"
}
"manifests_output": write: {
contents: actions.build.output.manifests
path: "manifests"
}
}
}
}
}