Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support map of files and volumes and mark arrays as deprecated #123

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions samples/score-deprecated-files-and-volumes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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.
# 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
# using a deprecated array format.
# ==========================================================================================================================================
apiVersion: score.dev/v1b1
metadata:
name: "deprecated-files-example"
containers:
main:
image: "example-image:latest"
files:
- target: /mnt/some-path
content: "my content here"
volumes:
- target: /mnt/vol
source: some-volume
30 changes: 15 additions & 15 deletions samples/score-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ containers:
variables:
SOME_VAR: some content here
files:
- target: /my/file
mode: "0600"
source: file.txt
- target: /my/other/file
content: |
some multiline
content
- target: /my/other/binaryfile
binaryContent: ADBgwpA=
/my/file:
mode: "0600"
source: file.txt
/my/other/file:
content: |
some multiline
content
/my/other/binaryfile:
binaryContent: ADBgwpA=
volumes:
- source: volume-name
target: /mnt/something
path: /sub/path
readOnly: false
- source: volume-two
target: /mnt/something-else
/mnt/something:
source: volume-name
path: /sub/path
readOnly: false
/mnt/something-else:
source: volume-two
livenessProbe:
httpGet:
port: 8080
Expand Down
187 changes: 105 additions & 82 deletions score-v1b1.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,84 @@
}
}
},
"containerFile": {
"description": "The details of a file to mount in the container. One of 'source', 'content', or 'binaryContent' must be provided.",
"type": "object",
"additionalProperties": false,
"properties": {
"target": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to not include this here and instead have it part of an allOf in the array version?

Technically, this will validate with target even when using the map version. This could be inconsistent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 It was a bit more complicated than expected and I needed to use a allOf(not(x), y) to exclude the target property from the object-form.

But it works, and validated against some negative examples.

"description": "(Deprecated) The file path to expose in the container. This is only used in Score workloads that describe files as an array.",
"deprecated": true,
"type": "string",
"minLength": 1
},
"mode": {
"description": "The optional file access mode in octal encoding. For example 0600.",
"type": "string",
"pattern": "^0?[0-7]{3}$"
},
"source": {
"description": "The relative or absolute path to the content file.",
"type": "string",
"minLength": 1
},
"content": {
"description": "The inline content for the file. Only supports valid utf-8.",
"type": "string"
},
"binaryContent": {
"description": "Inline standard-base64 encoded content for the file. Does not support placeholder expansion.",
"type": "string"
},
"noExpand": {
"description": "If set to true, the placeholders expansion will not occur in the contents of the file.",
"type": "boolean"
}
},
"oneOf": [
{
"required": [
"content"
]
},
{
"required": [
"binaryContent"
]
},
{
"required": [
"source"
]
}
]
},
"containerVolume": {
"type": "object",
"additionalProperties": false,
"required": [
"source"
],
"properties": {
"source": {
"description": "The external volume reference.",
"type": "string"
},
"path": {
"description": "An optional sub path in the volume.",
"type": "string"
},
"target": {
"description": "(Deprecated) The target mount on the container. This is only used in Score workloads that describe volumes as an array.",
"deprecated": true,
"type": "string"
},
"readOnly": {
"description": "Indicates if the volume should be mounted in a read-only mode.",
"type": "boolean"
}
}
},
"container": {
"description": "The specification of a Container within the Workload.",
"type": "object",
Expand Down Expand Up @@ -232,95 +310,40 @@
}
},
"files": {
"description": "The extra files to mount into the container.",
"type": "array",
"items": {
"description": "The details of a file to mount in the container. One of 'source', 'content', or 'binaryContent' must be provided.",
"type": "object",
"required": [
"target"
],
"additionalProperties": false,
"properties": {
"target": {
"description": "The file path to expose in the container.",
"type": "string",
"minLength": 1
},
"mode": {
"description": "The optional file access mode in octal encoding. For example 0600.",
"type": "string",
"pattern": "^0?[0-7]{3}$"
},
"source": {
"description": "The relative or absolute path to the content file.",
"type": "string",
"minLength": 1
},
"content": {
"description": "The inline content for the file. Only supports valid utf-8.",
"type": "string"
},
"binaryContent": {
"description": "Inline standard-base64 encoded content for the file. Does not support placeholder expansion.",
"type": "string"
},
"noExpand": {
"description": "If set to true, the placeholders expansion will not occur in the contents of the file.",
"type": "boolean"
"description": "The extra files to mount into the container. Described as a map of target paths to file details. The array form is deprecated.",
"oneOf": [
{
"type": "array",
"deprecated": true,
"items": {
"$ref": "#/$defs/containerFile"
}
},
"oneOf": [
{
"required": [
"target",
"content"
]
},
{
"required": [
"target",
"binaryContent"
]
},
{
"required": [
"target",
"source"
]
{
"type": "object",
"additionalProperties": {
"$ref": "#/$defs/containerFile"
}
]
}
}
]
},
"volumes": {
"description": "The volumes to mount.",
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"source",
"target"
],
"properties": {
"source": {
"description": "The external volume reference.",
"type": "string"
},
"path": {
"description": "An optional sub path in the volume.",
"type": "string"
},
"target": {
"description": "The target mount on the container.",
"type": "string"
},
"readOnly": {
"description": "Indicates if the volume should be mounted in a read-only mode.",
"type": "boolean"
"description": "The volumes to mount. Described as a map of target paths to volume details. The array form is deprecated.",
"oneOf": [
{
"type": "array",
"deprecated": true,
"items": {
"$ref": "#/$defs/containerVolume"
}
},
{
"type": "object",
"additionalProperties": {
"$ref": "#/$defs/containerVolume"
}
}
}
]
},
"resources": {
"description": "The compute resources for the container.",
Expand Down
Loading