How do you express "password is required only when the internal database is enabled" in a schema?
AdvancedConceptSchema, Helmfile, Argo CD & Secrets
Answer
With if/then (JSON Schema draft 7):
"postgres": {
"type": "object",
"properties": {
"enabled": { "type": "boolean" },
"auth": { "type": "object", "properties": { "password": { "type": "string" } } }
},
"if": { "properties": { "enabled": { "const": true } } },
"then": {
"required": ["auth"],
"properties": { "auth": { "required": ["password"], "properties": { "password": { "minLength": 12 } } } }
}
}
Keep schemas readable; deeply nested conditionals are better replaced with a fail in a template helper with a clear message.
More on Schema, Helmfile, Argo CD & Secrets
When is `values.schema.json` validated, and can it be skipped?IntermediateWhat is Helmfile?BeginnerShow a realistic `helmfile.yaml`.IntermediateWhat is the difference between `helmfile sync` and `helmfile apply`?IntermediateHow does Argo CD deploy a Helm chart?AdvancedWhat are the consequences of Argo CD using `helm template` instead of `helm install`?Advanced