Today cozyvalues-gen can mark a field as required only unconditionally (via @field {type} name without brackets) or optional (@field {type} [name]). There is no way to express "field X is required only when field Y has value Z" in the generated values.schema.json, even though JSON Schema Draft 7 supports this via if/then/else or allOf + dependencies.
Use case. In chart packages/extra/etcd (cozystack/cozystack), the fields backup.destinationPath, backup.endpointURL, backup.s3AccessKey, and backup.s3SecretKey are required when backup.enabled: true and should be left empty otherwise. Render-time validation with the Helm required function is already in place, but the dashboard would give users earlier, field-level feedback if the generated schema could express the condition.
Proposed annotation (sketch, open to bikeshedding):
## @typedef {struct} Backup - ...
## @field {bool} [enabled] - ...
## @field {string} [destinationPath] - ...
## @requiredIf enabled=true destinationPath endpointURL s3AccessKey s3SecretKey
which would emit:
"backup": {
"properties": {...},
"if": {"properties": {"enabled": {"const": true}}},
"then": {"required": ["destinationPath","endpointURL","s3AccessKey","s3SecretKey"]}
}
Context: cozystack/cozystack#2428 (review thread cozystack/cozystack#2428 (comment)).
Today cozyvalues-gen can mark a field as required only unconditionally (via
@field {type} namewithout brackets) or optional (@field {type} [name]). There is no way to express "field X is required only when field Y has value Z" in the generatedvalues.schema.json, even though JSON Schema Draft 7 supports this viaif/then/elseorallOf+dependencies.Use case. In chart
packages/extra/etcd(cozystack/cozystack), the fieldsbackup.destinationPath,backup.endpointURL,backup.s3AccessKey, andbackup.s3SecretKeyare required whenbackup.enabled: trueand should be left empty otherwise. Render-time validation with the Helmrequiredfunction is already in place, but the dashboard would give users earlier, field-level feedback if the generated schema could express the condition.Proposed annotation (sketch, open to bikeshedding):
which would emit:
Context: cozystack/cozystack#2428 (review thread cozystack/cozystack#2428 (comment)).