You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some fields fields: files and volumes in containers are arrays. Both of these have a required unique identifier: target which is the path to mount in the container.
Using arrays for this introduces the following complexities:
Additional validation is required to verify that no two files and no two volumes use the same path
The order is not actually important
Arrays are harder to visually parse in yaml compared to objects.
Context
In general, it would make sense for arrays to only be used where order is actually important or there is no unique key.
Possible implementation
The spec can be changed to use oneOf as follows:
{
"files": {
"description": "The extra files to mount into the container.",
"oneOf": [
{
"type": "array",
"items": {
"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.",
"type": "string"
},
"noExpand": {
"description": "If set to true, the placeholders expansion will not occur in the contents of the file.",
"type": "boolean"
}
},
"oneOf": [
{
"required": [
"target",
"content"
]
},
{
"required": [
"target",
"source"
]
}
]
}
},
{
"type": "object",
"patternProperties": {
".+": {
"type": "object",
"additionalProperties": false,
"properties": {
"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.",
"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": [
"source"
]
}
]
}
}
]
}
}
Additional information
score-go would need to support both but surface via the existing API. This would mean that implementations using score-go get this for free.
The text was updated successfully, but these errors were encountered:
Detailed description
Some fields fields:
files
andvolumes
incontainers
are arrays. Both of these have a required unique identifier:target
which is the path to mount in the container.Using arrays for this introduces the following complexities:
Context
In general, it would make sense for arrays to only be used where order is actually important or there is no unique key.
Possible implementation
The spec can be changed to use
oneOf
as follows:Additional information
score-go
would need to support both but surface via the existing API. This would mean that implementations usingscore-go
get this for free.The text was updated successfully, but these errors were encountered: