Skip to content

Commit 94e3167

Browse files
authored
feat: support map of files and volumes and mark arrays as deprecated (#123)
Signed-off-by: Ben Meier <[email protected]>
1 parent de85176 commit 94e3167

File tree

3 files changed

+157
-96
lines changed

3 files changed

+157
-96
lines changed

Diff for: samples/score-deprecated-files-and-volumes.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The following workload describes a container which has a file and volume mounted. The file mount is using the deprecated format of an array of files.
2+
# This was deprecated since files do not infer order and the "target" path can be considered both required and unique. Simalarly, the volume mount is also
3+
# using a deprecated array format.
4+
# ==========================================================================================================================================
5+
apiVersion: score.dev/v1b1
6+
metadata:
7+
name: "deprecated-files-example"
8+
containers:
9+
main:
10+
image: "example-image:latest"
11+
files:
12+
- target: /mnt/some-path
13+
content: "my content here"
14+
volumes:
15+
- target: /mnt/vol
16+
source: some-volume

Diff for: samples/score-full.yaml

+15-15
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ containers:
2727
variables:
2828
SOME_VAR: some content here
2929
files:
30-
- target: /my/file
31-
mode: "0600"
32-
source: file.txt
33-
- target: /my/other/file
34-
content: |
35-
some multiline
36-
content
37-
- target: /my/other/binaryfile
38-
binaryContent: ADBgwpA=
30+
/my/file:
31+
mode: "0600"
32+
source: file.txt
33+
/my/other/file:
34+
content: |
35+
some multiline
36+
content
37+
/my/other/binaryfile:
38+
binaryContent: ADBgwpA=
3939
volumes:
40-
- source: volume-name
41-
target: /mnt/something
42-
path: /sub/path
43-
readOnly: false
44-
- source: volume-two
45-
target: /mnt/something-else
40+
/mnt/something:
41+
source: volume-name
42+
path: /sub/path
43+
readOnly: false
44+
/mnt/something-else:
45+
source: volume-two
4646
livenessProbe:
4747
httpGet:
4848
port: 8080

Diff for: score-v1b1.json

+126-81
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,84 @@
193193
}
194194
}
195195
},
196+
"containerFile": {
197+
"description": "The details of a file to mount in the container. One of 'source', 'content', or 'binaryContent' must be provided.",
198+
"type": "object",
199+
"additionalProperties": false,
200+
"properties": {
201+
"target": {
202+
"description": "(Deprecated) The file path to expose in the container. This is only used in Score workloads that describe files as an array.",
203+
"deprecated": true,
204+
"type": "string",
205+
"minLength": 1
206+
},
207+
"mode": {
208+
"description": "The optional file access mode in octal encoding. For example 0600.",
209+
"type": "string",
210+
"pattern": "^0?[0-7]{3}$"
211+
},
212+
"source": {
213+
"description": "The relative or absolute path to the content file.",
214+
"type": "string",
215+
"minLength": 1
216+
},
217+
"content": {
218+
"description": "The inline content for the file. Only supports valid utf-8.",
219+
"type": "string"
220+
},
221+
"binaryContent": {
222+
"description": "Inline standard-base64 encoded content for the file. Does not support placeholder expansion.",
223+
"type": "string"
224+
},
225+
"noExpand": {
226+
"description": "If set to true, the placeholders expansion will not occur in the contents of the file.",
227+
"type": "boolean"
228+
}
229+
},
230+
"oneOf": [
231+
{
232+
"required": [
233+
"content"
234+
]
235+
},
236+
{
237+
"required": [
238+
"binaryContent"
239+
]
240+
},
241+
{
242+
"required": [
243+
"source"
244+
]
245+
}
246+
]
247+
},
248+
"containerVolume": {
249+
"type": "object",
250+
"additionalProperties": false,
251+
"required": [
252+
"source"
253+
],
254+
"properties": {
255+
"source": {
256+
"description": "The external volume reference.",
257+
"type": "string"
258+
},
259+
"path": {
260+
"description": "An optional sub path in the volume.",
261+
"type": "string"
262+
},
263+
"target": {
264+
"description": "(Deprecated) The target mount on the container. This is only used in Score workloads that describe volumes as an array.",
265+
"deprecated": true,
266+
"type": "string"
267+
},
268+
"readOnly": {
269+
"description": "Indicates if the volume should be mounted in a read-only mode.",
270+
"type": "boolean"
271+
}
272+
}
273+
},
196274
"container": {
197275
"description": "The specification of a Container within the Workload.",
198276
"type": "object",
@@ -232,95 +310,62 @@
232310
}
233311
},
234312
"files": {
235-
"description": "The extra files to mount into the container.",
236-
"type": "array",
237-
"items": {
238-
"description": "The details of a file to mount in the container. One of 'source', 'content', or 'binaryContent' must be provided.",
239-
"type": "object",
240-
"required": [
241-
"target"
242-
],
243-
"additionalProperties": false,
244-
"properties": {
245-
"target": {
246-
"description": "The file path to expose in the container.",
247-
"type": "string",
248-
"minLength": 1
249-
},
250-
"mode": {
251-
"description": "The optional file access mode in octal encoding. For example 0600.",
252-
"type": "string",
253-
"pattern": "^0?[0-7]{3}$"
254-
},
255-
"source": {
256-
"description": "The relative or absolute path to the content file.",
257-
"type": "string",
258-
"minLength": 1
259-
},
260-
"content": {
261-
"description": "The inline content for the file. Only supports valid utf-8.",
262-
"type": "string"
263-
},
264-
"binaryContent": {
265-
"description": "Inline standard-base64 encoded content for the file. Does not support placeholder expansion.",
266-
"type": "string"
267-
},
268-
"noExpand": {
269-
"description": "If set to true, the placeholders expansion will not occur in the contents of the file.",
270-
"type": "boolean"
313+
"description": "The extra files to mount into the container. Described as a map of target paths to file details. The array form is deprecated.",
314+
"oneOf": [
315+
{
316+
"type": "array",
317+
"deprecated": true,
318+
"items": {
319+
"$ref": "#/$defs/containerFile"
271320
}
272321
},
273-
"oneOf": [
274-
{
275-
"required": [
276-
"target",
277-
"content"
278-
]
279-
},
280-
{
281-
"required": [
282-
"target",
283-
"binaryContent"
284-
]
285-
},
286-
{
287-
"required": [
288-
"target",
289-
"source"
322+
{
323+
"type": "object",
324+
"additionalProperties": {
325+
"allOf": [
326+
{
327+
"not": {
328+
"type": "object",
329+
"additionalProperties": true,
330+
"required": ["target"]
331+
}
332+
},
333+
{
334+
"$ref": "#/$defs/containerFile"
335+
}
290336
]
291337
}
292-
]
293-
}
338+
}
339+
]
294340
},
295341
"volumes": {
296-
"description": "The volumes to mount.",
297-
"type": "array",
298-
"items": {
299-
"type": "object",
300-
"additionalProperties": false,
301-
"required": [
302-
"source",
303-
"target"
304-
],
305-
"properties": {
306-
"source": {
307-
"description": "The external volume reference.",
308-
"type": "string"
309-
},
310-
"path": {
311-
"description": "An optional sub path in the volume.",
312-
"type": "string"
313-
},
314-
"target": {
315-
"description": "The target mount on the container.",
316-
"type": "string"
317-
},
318-
"readOnly": {
319-
"description": "Indicates if the volume should be mounted in a read-only mode.",
320-
"type": "boolean"
342+
"description": "The volumes to mount. Described as a map of target paths to volume details. The array form is deprecated.",
343+
"oneOf": [
344+
{
345+
"type": "array",
346+
"deprecated": true,
347+
"items": {
348+
"$ref": "#/$defs/containerVolume"
349+
}
350+
},
351+
{
352+
"type": "object",
353+
"additionalProperties": {
354+
"allOf": [
355+
{
356+
"not": {
357+
"type": "object",
358+
"additionalProperties": true,
359+
"required": ["target"]
360+
}
361+
},
362+
{
363+
"$ref": "#/$defs/containerVolume"
364+
}
365+
]
321366
}
322367
}
323-
}
368+
]
324369
},
325370
"resources": {
326371
"description": "The compute resources for the container.",

0 commit comments

Comments
 (0)