-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: validate server options (#529)
* feat: add jsonschema validation for server options in values.yaml * feat: add specific schemas for server options in notebooks api * fix: validate server options values are valid when launching notebook Co-authored-by: Andreas Bleuler <ableuler@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
340 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft-07/schema#", | ||
"definitions": { | ||
"informationAmount": { | ||
"type": "string", | ||
"pattern": "^(?:[1-9][0-9]*|[0-9]\\.[0-9]*)[EPTGMK][i]{0,1}$" | ||
}, | ||
"cpuRequest": { | ||
"type": "number", | ||
"exclusiveMinimum": 0.0, | ||
"multipleOf": 0.001 | ||
}, | ||
"gpuRequest": { | ||
"type": "integer", | ||
"minimum": 0.0 | ||
}, | ||
"serverOption": { | ||
"type": "object", | ||
"properties": { | ||
"order": { | ||
"type": "integer", | ||
"minimum": 1 | ||
}, | ||
"displayName": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"order", | ||
"displayName" | ||
] | ||
}, | ||
"serverOptionEnumStr": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/serverOption" | ||
}, | ||
{ | ||
"properties": { | ||
"order": true, | ||
"displayName": true, | ||
"type": { | ||
"type": "string", | ||
"pattern": "^enum$" | ||
}, | ||
"default": { | ||
"type": "string" | ||
}, | ||
"options": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
} | ||
}, | ||
"required": [ | ||
"type", | ||
"default", | ||
"options" | ||
], | ||
"additionalProperties": false | ||
} | ||
] | ||
}, | ||
"serverOptionBool": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/serverOption" | ||
}, | ||
{ | ||
"properties": { | ||
"order": true, | ||
"displayName": true, | ||
"type": { | ||
"type": "string", | ||
"pattern": "^boolean$" | ||
}, | ||
"default": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"required": [ | ||
"type", | ||
"default" | ||
], | ||
"additionalProperties": false | ||
} | ||
] | ||
}, | ||
"serverOptionGpu": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/serverOption" | ||
}, | ||
{ | ||
"properties": { | ||
"order": true, | ||
"displayName": true, | ||
"type": { | ||
"type": "string", | ||
"pattern": "^enum$" | ||
}, | ||
"default": { "$ref": "#/definitions/gpuRequest" }, | ||
"options": { | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/gpuRequest" }, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
} | ||
}, | ||
"required": [ | ||
"type", | ||
"default", | ||
"options" | ||
], | ||
"additionalProperties": false | ||
} | ||
] | ||
}, | ||
"serverOptionCpu": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/serverOption" | ||
}, | ||
{ | ||
"properties": { | ||
"order": true, | ||
"displayName": true, | ||
"type": { | ||
"type": "string", | ||
"pattern": "^enum$" | ||
}, | ||
"default": { "$ref": "#/definitions/cpuRequest" }, | ||
"options": { | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/cpuRequest" }, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
} | ||
}, | ||
"required": [ | ||
"type", | ||
"default", | ||
"options" | ||
], | ||
"additionalProperties": false | ||
} | ||
] | ||
}, | ||
"serverOptionMemory": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/serverOptionEnumStr" | ||
}, | ||
{ | ||
"properties": { | ||
"order": true, | ||
"displayName": true, | ||
"type": { | ||
"type": "string", | ||
"pattern": "^enum$" | ||
}, | ||
"default": { "$ref": "#/definitions/informationAmount" }, | ||
"options": { | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/informationAmount" }, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
} | ||
}, | ||
"required": [ | ||
"type", | ||
"default", | ||
"options" | ||
], | ||
"additionalProperties": false | ||
} | ||
] | ||
} | ||
}, | ||
"properties": { | ||
"serverOptions": { | ||
"description": "Options provided to the user in the UI when launching a server.", | ||
"properties": { | ||
"defaultUrl": { "$ref": "#/definitions/serverOptionEnumStr" }, | ||
"cpu_request": { "$ref": "#/definitions/serverOptionCpu" }, | ||
"mem_request": { "$ref": "#/definitions/serverOptionMemory" }, | ||
"lfs_auto_fetch": { "$ref": "#/definitions/serverOptionBool" }, | ||
"gpu_request": { "$ref": "#/definitions/serverOptionGpu" } | ||
}, | ||
"required": [ | ||
"defaultUrl", | ||
"cpu_request", | ||
"mem_request", | ||
"lfs_auto_fetch" | ||
], | ||
"type": "object", | ||
"additionalProperties": false | ||
} | ||
}, | ||
"required": [ | ||
"serverOptions" | ||
], | ||
"title": "Values", | ||
"type": "object" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.