{
  "$schema": "http://json-schema.org/schema#",
  "type": "object",
  "properties": {
    "architecture": {
      "type": "string",
      "title": "MySQL architecture",
      "form": true,
      "description": "Allowed values: `standalone` or `replication`",
      "enum": ["standalone", "replication"]
    },
    "auth": {
      "type": "object",
      "title": "Authentication configuration",
      "form": true,
      "required": ["username", "password"],
      "if": {
        "properties": {
          "createDatabase":  { "enum": [ true ] }
        }
      },
      "then": {
        "properties": {
          "database": {
            "pattern": "[a-zA-Z0-9]{1,64}"
          }
        }
      },
      "properties": {
        "rootPassword": {
          "type": "string",
          "title": "MySQL root password",
          "description": "Defaults to a random 10-character alphanumeric string if not set"
        },
        "database": {
          "type": "string",
          "title": "MySQL custom database name",
          "maxLength": 64
        },
        "username": {
          "type": "string",
          "title": "MySQL custom username"
        },
        "password": {
          "type": "string",
          "title": "MySQL custom password"
        },
        "replicationUser": {
          "type": "string",
          "title": "MySQL replication username"
        },
        "replicationPassword": {
          "type": "string",
          "title": "MySQL replication password"
        },
        "createDatabase": {
          "type": "boolean",
          "title": "MySQL create custom database"
        }
      }
    },
    "primary": {
      "type": "object",
      "title": "Primary database configuration",
      "form": true,
      "properties": {
        "podSecurityContext": {
          "type": "object",
          "title": "MySQL primary Pod security context",
          "properties": {
            "enabled": {
              "type": "boolean",
              "default": false
            },
            "fsGroup": {
              "type": "integer",
              "default": 1001,
              "hidden": {
                "value": false,
                "path": "primary/podSecurityContext/enabled"
              }
            }
          }
        },
        "containerSecurityContext": {
          "type": "object",
          "title": "MySQL primary container security context",
          "properties": {
            "enabled": {
              "type": "boolean",
              "default": false
            },
            "runAsUser": {
              "type": "integer",
              "default": 1001,
              "hidden": {
                "value": false,
                "path": "primary/containerSecurityContext/enabled"
              }
            }
          }
        },
        "persistence": {
          "type": "object",
          "title": "Enable persistence using Persistent Volume Claims",
          "properties": {
            "enabled": {
              "type": "boolean",
              "default": true,
              "title": "If true, use a Persistent Volume Claim, If false, use emptyDir"
            },
            "size": {
              "type": "string",
              "title": "Persistent Volume Size",
              "form": true,
              "render": "slider",
              "sliderMin": 1,
              "sliderUnit": "Gi",
              "hidden": {
                "value": false,
                "path": "primary/persistence/enabled"
              }
            }
          }
        }
      }
    },
    "secondary": {
      "type": "object",
      "title": "Secondary database configuration",
      "form": true,
      "properties": {
        "podSecurityContext": {
          "type": "object",
          "title": "MySQL secondary Pod security context",
          "properties": {
            "enabled": {
              "type": "boolean",
              "default": false
            },
            "fsGroup": {
              "type": "integer",
              "default": 1001,
              "hidden": {
                "value": false,
                "path": "secondary/podSecurityContext/enabled"
              }
            }
          }
        },
        "containerSecurityContext": {
          "type": "object",
          "title": "MySQL secondary container security context",
          "properties": {
            "enabled": {
              "type": "boolean",
              "default": false
            },
            "runAsUser": {
              "type": "integer",
              "default": 1001,
              "hidden": {
                "value": false,
                "path": "secondary/containerSecurityContext/enabled"
              }
            }
          }
        },
        "persistence": {
          "type": "object",
          "title": "Enable persistence using Persistent Volume Claims",
          "properties": {
            "enabled": {
              "type": "boolean",
              "default": true,
              "title": "If true, use a Persistent Volume Claim, If false, use emptyDir"
            },
            "size": {
              "type": "string",
              "title": "Persistent Volume Size",
              "form": true,
              "render": "slider",
              "sliderMin": 1,
              "sliderUnit": "Gi",
              "hidden": {
                "value": false,
                "path": "secondary/persistence/enabled"
              }
            }
          }
        }
      }
    }
  }
}
