1package core
2
3// Core schema for the syslet tool
4
5// Values of the 'type' field, selecting which spec a document describes
6#SpecTypeContainer: "container"
7#SpecTypeNetwork: "network"
8#SpecTypeVolume: "volume"
9#SpecTypeBuild: "build"
10#SpecTypeSecret: "secret"
11
12// Retain keeps the podman resource when its unit is removed
13#ReclaimPolicyRetain: "Retain"
14
15// Delete removes the podman resource when its unit is removed
16#ReclaimPolicyDelete: "Delete"
17
18// All valid reclaim policy values
19#ReclaimPolicy: #ReclaimPolicyRetain | #ReclaimPolicyDelete
20
21// Spec apiVersion this schema describes, syslet routes each spec to its decoder by it
22#APIVersionV1: "v1"
23
24// Fields shared by every spec type
25#Spec: {
26 // Spec apiVersion, fixed by the schema so exported specs always carry it
27 apiVersion: #APIVersionV1
28
29 // Spec type
30 type!: string
31
32 // Spec name, will be also set as the unit name and podman name
33 name!: string
34}
35
36// Map form of a unit option value (e.g. Environment), rendered as one entry per key
37#Env: {
38 [string]: string
39}
40
41// Section name of a unit option
42#UnitOptionSectionName: string
43
44// Section key of a unit option
45#UnitOptionSectionKey: string
46
47// Value of a unit option
48#UnitOptionValue: string | [...string] | #Env
49
50// Fields shared by specs that render to a quadlet unit (all except secret)
51#UnitSpec: {
52 #Spec
53
54 // Quadlet unit options, keyed by section name and then option name; use {} for none
55 unit!: [#UnitOptionSectionName]: [#UnitOptionSectionKey]: #UnitOptionValue
56}
57
58// Fields shared by specs whose unit syslet only prunes when allowed (container, volume, network).
59// Builds are pruned unconditionally, so #BuildSpec doesn't include it.
60#RemovableSpec: {
61 // If this is true, and the unit is no longer in the input, syslet will remove the unit
62 removalAllowed!: bool
63}
64
65// Container should be running after reconciliation
66#ContainerDesiredStateRunning: "running"
67
68// Container should be stopped after reconciliation
69#ContainerDesiredStateStopped: "stopped"
70
71// Container runs as a oneshot service (Type=oneshot). syslet never starts or
72// stops it, other units trigger it through their [Unit] dependencies.
73#ContainerDesiredStateOneshot: "oneshot"
74
75// All valid container desired states
76#ContainerDesiredState: #ContainerDesiredStateRunning | #ContainerDesiredStateStopped | #ContainerDesiredStateOneshot
77
78// Container rendered to a .container quadlet unit
79#ContainerSpec: {
80 #UnitSpec
81 #RemovableSpec
82
83 // Spec type
84 type: #SpecTypeContainer
85
86 // Desired state controls if container will be started or stopped
87 desiredState!: #ContainerDesiredState
88
89 // Bind-mounted config files
90 configFiles?: [...#ContainerConfigFile]
91
92 // Bind-mounted config directories
93 configDirs?: [...#ContainerConfigDir]
94}
95
96// Single file bind-mounted into a container
97#ContainerConfigFile: {
98 // Mount path within the container
99 mountPath!: string
100
101 // File mode, e.g. 0600, defaults to 0644
102 mode?: string
103
104 // File content
105 content!: string
106}
107
108// Directory of files bind-mounted into a container
109#ContainerConfigDir: {
110 // Mount path within the container
111 mountPath!: string
112
113 // Files inside the directory
114 files!: [...#ContainerConfigDirFile]
115}
116
117// File within a #ContainerConfigDir
118#ContainerConfigDirFile: {
119 // Filename within the directory
120 name!: string
121
122 // File mode, e.g. 0600, defaults to 0644
123 mode?: string
124
125 // File content
126 content!: string
127}
128
129// Network rendered to a .network quadlet unit
130#NetworkSpec: {
131 #UnitSpec
132 #RemovableSpec
133
134 // Spec type
135 type: #SpecTypeNetwork
136
137 // Reclaim policy controls if the podman network will be removed when the unit is removed
138 reclaimPolicy!: #ReclaimPolicy
139}
140
141// Volume rendered to a .volume quadlet unit
142#VolumeSpec: {
143 #UnitSpec
144 #RemovableSpec
145
146 // Spec type
147 type: #SpecTypeVolume
148
149 // Reclaim policy controls if the volume will be removed when the unit is removed
150 reclaimPolicy!: #ReclaimPolicy
151}
152
153// Image build rendered to a .build quadlet unit
154#BuildSpec: {
155 #UnitSpec
156
157 // Spec type
158 type: #SpecTypeBuild
159
160 // Reclaim policy controls if the built image will be removed when the unit is removed
161 reclaimPolicy!: #ReclaimPolicy
162
163 // Containerfile content
164 containerfile!: string
165
166 // Files that will be added to the build context
167 contextFiles?: [...#BuildContextFile]
168}
169
170// File added to the build context
171#BuildContextFile: {
172 // Filename within the build context
173 filename!: string
174
175 // File mode, e.g. 0600, defaults to 0644
176 mode?: string
177
178 // File content
179 content!: string
180}
181
182// SOPS-encrypted key/value file, each key becomes a podman secret named <name>-<key>
183#SecretSpec: {
184 #Spec
185
186 // Spec type
187 type: #SpecTypeSecret
188
189 // SOPS-encrypted YAML file content, a flat mapping of key to encrypted value
190 ciphertext: string
191}