feat!: Validate monotonic numbers for rich parameters (#6046)

* Database changes

* protobuf

* Fix: docs

* workspaces_test

* Validation in coderd

* Fix: resources

* omitempty

* UI changes

* UI tests

* fix
This commit is contained in:
Marcin Tojek
2023-02-07 09:36:13 +01:00
committed by GitHub
parent e3ae664a29
commit b86bce8494
32 changed files with 917 additions and 392 deletions

87
coderd/apidoc/docs.go generated
View File

@ -2636,7 +2636,7 @@ const docTemplate = `{
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/parameter.ComputedValue"
"$ref": "#/definitions/codersdk.TemplateVersionParameter"
}
}
}
@ -7543,6 +7543,80 @@ const docTemplate = `{
}
}
},
"codersdk.TemplateVersionParameter": {
"type": "object",
"properties": {
"default_value": {
"type": "string"
},
"description": {
"type": "string"
},
"icon": {
"type": "string"
},
"mutable": {
"type": "boolean"
},
"name": {
"type": "string"
},
"options": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.TemplateVersionParameterOption"
}
},
"type": {
"type": "string",
"enum": [
"string",
"number",
"bool"
]
},
"validation_error": {
"type": "string"
},
"validation_max": {
"type": "integer"
},
"validation_min": {
"type": "integer"
},
"validation_monotonic": {
"enum": [
"increasing",
"decreasing"
],
"allOf": [
{
"$ref": "#/definitions/codersdk.ValidationMonotonicOrder"
}
]
},
"validation_regex": {
"type": "string"
}
}
},
"codersdk.TemplateVersionParameterOption": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"icon": {
"type": "string"
},
"name": {
"type": "string"
},
"value": {
"type": "string"
}
}
},
"codersdk.TraceConfig": {
"type": "object",
"properties": {
@ -7769,6 +7843,17 @@ const docTemplate = `{
}
}
},
"codersdk.ValidationMonotonicOrder": {
"type": "string",
"enum": [
"increasing",
"decreasing"
],
"x-enum-varnames": [
"MonotonicOrderIncreasing",
"MonotonicOrderDecreasing"
]
},
"codersdk.Workspace": {
"type": "object",
"properties": {

View File

@ -2320,7 +2320,7 @@
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/parameter.ComputedValue"
"$ref": "#/definitions/codersdk.TemplateVersionParameter"
}
}
}
@ -6781,6 +6781,73 @@
}
}
},
"codersdk.TemplateVersionParameter": {
"type": "object",
"properties": {
"default_value": {
"type": "string"
},
"description": {
"type": "string"
},
"icon": {
"type": "string"
},
"mutable": {
"type": "boolean"
},
"name": {
"type": "string"
},
"options": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.TemplateVersionParameterOption"
}
},
"type": {
"type": "string",
"enum": ["string", "number", "bool"]
},
"validation_error": {
"type": "string"
},
"validation_max": {
"type": "integer"
},
"validation_min": {
"type": "integer"
},
"validation_monotonic": {
"enum": ["increasing", "decreasing"],
"allOf": [
{
"$ref": "#/definitions/codersdk.ValidationMonotonicOrder"
}
]
},
"validation_regex": {
"type": "string"
}
}
},
"codersdk.TemplateVersionParameterOption": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"icon": {
"type": "string"
},
"name": {
"type": "string"
},
"value": {
"type": "string"
}
}
},
"codersdk.TraceConfig": {
"type": "object",
"properties": {
@ -6984,6 +7051,14 @@
}
}
},
"codersdk.ValidationMonotonicOrder": {
"type": "string",
"enum": ["increasing", "decreasing"],
"x-enum-varnames": [
"MonotonicOrderIncreasing",
"MonotonicOrderDecreasing"
]
},
"codersdk.Workspace": {
"type": "object",
"properties": {