Skip to content

Commit 3671cb0

Browse files
New spec for volumes and files as map (#188)
Signed-off-by: Mathieu Benoit <mathieu-benoit@hotmail.fr>
1 parent db83d39 commit 3671cb0

3 files changed

Lines changed: 86 additions & 66 deletions

File tree

content/en/docs/examples/nginx.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ containers:
5555
webapp:
5656
image: .
5757
volumes:
58-
- source: ${resources.tmp}
59-
target: /tmp
60-
readOnly: false
58+
/tmp:
59+
source: ${resources.tmp}
60+
readOnly: false
6161
service:
6262
ports:
6363
tcp:

content/en/docs/score specification/score-spec-reference.md

Lines changed: 70 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ containers:
8080
variables: # optional
8181
VAR_NAME: string
8282
files: # optional
83-
- target: string
83+
target:
8484
mode: string # optional
8585
source: string # oneOf source or content is required
8686
content: string # oneOf source or content is required
8787
noExpand: boolean # optional
8888
volumes: # optional
89-
- source: string
89+
target:
90+
source: string
9091
path: string # optional
91-
target: string
9292
readOnly: boolean # optional
9393
resources: # optional
9494
limits: # optional
@@ -127,21 +127,48 @@ containers:
127127

128128
`variables`: the environment variables for the container. Container variables support both metadata and resource output [placeholders]({{< relref "#placeholder-references" >}}).
129129

130-
`files`: the extra files to mount into the container. Either `content` or `source` must be specified along with `target`.
130+
`files`: the extra files to mount into the container. Either `content`, `binaryContent` or `source` must be specified.
131131

132132
- `target`: the file path to expose in the container.
133-
- `mode`: the optional file access mode in octal encoding. For example 0600.
134-
- `source`: the relative or absolute path to the content file. File content supports both metadata and resource output [placeholders]({{< relref "#placeholder-references" >}}) unless `noExpand` is true.
135-
- `content`: the inline content for the file. File content supports both metadata and resource output [placeholders]({{< relref "#placeholder-references" >}}) unless `noExpand` is true.
136-
- `binaryContent`: base64-encoded inline content for the file. This field supports non-utf-8 bytes for binary or archive files. Placeholder expansion is never supported.
137-
- `noExpand`: if set to true, the placeholders expansion will not occur in the contents of the `content` or `source` file.
133+
- `mode`: the optional file access mode in octal encoding. For example 0600.
134+
- `source`: the relative or absolute path to the content file. File content supports both metadata and resource output [placeholders]({{< relref "#placeholder-references" >}}) unless `noExpand` is true.
135+
- `content`: the inline content for the file. File content supports both metadata and resource output [placeholders]({{< relref "#placeholder-references" >}}) unless `noExpand` is true.
136+
- `binaryContent`: base64-encoded inline content for the file. This field supports non-utf-8 bytes for binary or archive files. Placeholder expansion is never supported.
137+
- `noExpand`: if set to true, the placeholders expansion will not occur in the contents of the `content` or `source` file.
138+
139+
Note: Since [`score-compose` `0.28.0`](https://github.com/score-spec/score-compose/releases/tag/0.28.0) and [`score-k8s` `0.5.0`](https://github.com/score-spec/score-k8s/releases/tag/0.5.0), the list of `files` is now a `map` which is the recommended approach moving forward. The previous and other option as an `array`, like illustrated below is still supported for backward compatibility (and may be deprecated in the future).
140+
141+
```yaml
142+
containers:
143+
container-name:
144+
...
145+
files: # optional as an array
146+
- target: string
147+
mode: string # optional
148+
source: string # oneOf source or content is required
149+
content: string # oneOf source or content is required
150+
noExpand: boolean # optional
151+
```
138152

139153
`volumes`: the volumes to mount.
140154

141-
- `source`: the external volume reference. The volume source supports resource output [placeholders]({{< relref "#placeholder-references" >}}).
142-
- `path`: an optional sub path in the volume.
143155
- `target`: the target mount on the container.
144-
- `readOnly`: indicates if the volume should be mounted in a read-only mode.
156+
- `source`: the external volume reference. The volume source supports resource output [placeholders]({{< relref "#placeholder-references" >}}).
157+
- `path`: an optional sub path in the volume.
158+
- `readOnly`: indicates if the volume should be mounted in a read-only mode.
159+
160+
Note: Since [`score-compose` `0.28.0`](https://github.com/score-spec/score-compose/releases/tag/0.28.0) and [`score-k8s` `0.5.0`](https://github.com/score-spec/score-k8s/releases/tag/0.5.0), the list of `volumes` is now a `map` which is the recommended approach moving forward. The previous and other option as an `array`, like illustrated below is still supported for backward compatibility (and may be deprecated in the future).
161+
162+
```yaml
163+
containers:
164+
container-name:
165+
...
166+
volumes: # optional as an array
167+
- target: string
168+
source: string
169+
path: string # optional
170+
readOnly: boolean # optional
171+
```
145172

146173
`resources`: the compute resources for the container.
147174

@@ -185,39 +212,39 @@ containers:
185212
FRIEND: World!
186213
MESSAGE: Hello ${metadata.name}
187214
188-
files: # (Optional) Specifies extra files to mount
189-
- target: /etc/hello-world/config.yaml # - Target file path and name
190-
mode: "666" # - Access mode
191-
content: | # - Inline content (supports templates)
192-
"---"
193-
${resources.env.APP_CONFIG}
194-
195-
volumes: # (Optional) Specifies volumes to mount
196-
- source: ${resources.data} # - External volume reference
197-
path: sub/path # - (Optional) Sub path in the volume
198-
target: /mnt/data # - Target mount path on the container
199-
readOnly: true # - (Optional) Mount as read-only
200-
201-
resources: # (Optional) CPU and memory resources needed
202-
limits: # - (Optional) Maximum allowed
215+
files: # (Optional) Specifies extra files to mount
216+
/etc/hello-world/config.yaml: # - Target file path and name
217+
mode: "666" # - Access mode
218+
content: | # - Inline content (supports templates)
219+
"---"
220+
${resources.env.APP_CONFIG}
221+
222+
volumes: # (Optional) Specifies volumes to mount
223+
/mnt/data: # - Target mount path on the container
224+
source: ${resources.data} # - External volume reference
225+
path: sub/path # - (Optional) Sub path in the volume
226+
readOnly: true # - (Optional) Mount as read-only
227+
228+
resources: # (Optional) CPU and memory resources needed
229+
limits: # - (Optional) Maximum allowed
203230
memory: "128Mi"
204231
cpu: "500m"
205-
requests: # - (Optional) Minimal required
232+
requests: # - (Optional) Minimal required
206233
memory: "64Mi"
207234
cpu: "250m"
208235
209-
livenessProbe: # (Optional) Liveness probe
210-
httpGet: # - Only HTTP GET is supported
211-
scheme: http # - Specify the schema (http or https)
236+
livenessProbe: # (Optional) Liveness probe
237+
httpGet: # - Only HTTP GET is supported
238+
scheme: http # - Specify the schema (http or https)
212239
path: /alive
213240
port: 8080
214241
215-
readinessProbe: # (Optional) Readiness probe
216-
httpGet: # - Only HTTP GET is supported
217-
scheme: http # - Specify the schema (http or https)
242+
readinessProbe: # (Optional) Readiness probe
243+
httpGet: # - Only HTTP GET is supported
244+
scheme: http # - Specify the schema (http or https)
218245
path: /ready
219246
port: 8080
220-
httpHeaders: # - (Optional) HTTP Headers to include
247+
httpHeaders: # - (Optional) HTTP Headers to include
221248
- name: Custom-Header
222249
value: Awesome
223250
```
@@ -323,23 +350,16 @@ resources:
323350
type: postgres
324351
```
325352

326-
### Reserved resource types
327-
328-
In general, the Score specification does not specify a set of supported `resource types or outputs of those resources however there are some types that have historical significance in some Score implementations that you may want to be aware of.
329-
330-
- `environment`: This resource type is a source of environment specific values. In `score-compose` this comes from environment variables present when running `score-compose generate`, in Humanitec this comes from the deployed environment configuration. In `score-k8s` this has no specific meaning.
331-
- `volume`: This resource type should be used with the container volume source field. This is generally implementation specific due to the varied behavior and configuration of mounted volumes.
332-
- `service`: This resource type is used in Humanitec to return service placeholders. It has no specific meaning in `score-compose` or `score-k8s`.
333-
334353
## Placeholder References
335354

336355
Score Workloads support `${..}` placeholder references in order to support dynamic configuration within the Workload. Placeholders operate within the context of their Workload and can be used to interpolate values from either Workload metadata or the outputs of named resources. References to unknown keys will result in a failure. The `${}` syntax can be escaped with an additional dollar sign, for example: `$${not a placeholder}` and any `.`'s in a key can be escaped with a backslash: `${some\.thing}`.
337356

338357
Placeholders are supported in the following locations:
339358

340359
- `containers.*.variables.*`: The value of a variable may contain one or more placeholders.
341-
- `containers.*.files[*].content`: The inline content of a file may contain one or more placeholders.
342-
- `containers.*.volumes[*].source`: The volume source may contain placeholders. This usually refers to a particular named resource of type `volume`.
360+
- `containers.*.files.*.content`: The inline content of a file may contain one or more placeholders.
361+
- `containers.*.files.*.source`: The file source may contain one or more placeholders.
362+
- `containers.*.volumes.*.source`: The volume source may contain placeholders. This usually refers to a particular named resource of type `volume`.
343363
- `resources.*.params.*`: The resource params may accept placeholder resolutions.
344364

345365
### Workload metadata references
@@ -386,9 +406,9 @@ containers:
386406
RESOURCE_HOOK: ${resources.some-resource.hook}
387407
COMBINED: ${resources.some-resource.a}-${resources.other-resource.b}
388408
files:
389-
- target: /something.properties
390-
content: |
391-
xyz=${resources.some-resource.a}
409+
/something.properties:
410+
content: |
411+
xyz=${resources.some-resource.a}
392412
resources:
393413
some-resource:
394414
type: something
@@ -417,8 +437,8 @@ containers:
417437
example:
418438
image: some-image
419439
volumes:
420-
- source: ${resources.my-volume}
421-
target: /mnt/volume
440+
/mnt/volume:
441+
source: ${resources.my-volume}
422442
resources:
423443
my-volume:
424444
type: volume

schemas/samples/score-full.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ containers:
2525
variables:
2626
SOME_VAR: some content here
2727
files:
28-
- target: /my/file
29-
mode: "0600"
30-
source: file.txt
31-
- target: /my/other/file
32-
content: |
33-
some multiline
34-
content
28+
/my/file:
29+
mode: "0600"
30+
source: file.txt
31+
/my/other/file:
32+
content: |
33+
some multiline
34+
content
3535
volumes:
36-
- source: volume-name
37-
target: /mnt/something
38-
path: /sub/path
39-
readOnly: false
40-
- source: volume-two
41-
target: /mnt/something-else
36+
/mnt/something:
37+
source: volume-name
38+
path: /sub/path
39+
readOnly: false
40+
/mnt/something-else:
41+
source: volume-two
4242
livenessProbe:
4343
httpGet:
4444
port: 8080

0 commit comments

Comments
 (0)