Interview Prep/Helm/Schema, Helmfile, Argo CD & Secrets

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.

All Helm questions Roadmap: Helm

More on Schema, Helmfile, Argo CD & Secrets