{
  "properties": {
    "apiVersion": {
      "type": "string"
    },
    "kind": {
      "type": "string"
    },
    "metadata": {
      "type": "object"
    },
    "spec": {
      "properties": {
        "clusters": {
          "items": {
            "properties": {
              "endpoints": {
                "items": {
                  "properties": {
                    "host": {
                      "maxLength": 253,
                      "type": "string",
                      "x-kubernetes-validations": [
                        {
                          "message": "host must be a valid IP address or domain name",
                          "rule": "isIP(self) || !format.dns1123Subdomain().validate(self).hasValue()"
                        }
                      ]
                    },
                    "port": {
                      "default": 3306,
                      "format": "int32",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "host"
                  ],
                  "type": "object",
                  "additionalProperties": false
                },
                "maxItems": 9,
                "minItems": 1,
                "type": "array"
              },
              "innodbClusterName": {
                "maxLength": 63,
                "type": "string",
                "x-kubernetes-validations": [
                  {
                    "message": "innodbClusterName must contain only alphanumeric characters",
                    "rule": "self.matches('^[A-Za-z0-9]+$')"
                  }
                ]
              }
            },
            "required": [
              "endpoints",
              "innodbClusterName"
            ],
            "type": "object",
            "additionalProperties": false
          },
          "maxItems": 10,
          "minItems": 1,
          "type": "array",
          "x-kubernetes-list-map-keys": [
            "innodbClusterName"
          ],
          "x-kubernetes-list-type": "map",
          "x-kubernetes-validations": [
            {
              "message": "cluster names must be unique",
              "rule": "self.all(c, self.exists_one(d, d.innodbClusterName == c.innodbClusterName))"
            }
          ]
        },
        "createReplicaClusterOptions": {
          "properties": {
            "recoveryMethod": {
              "default": "clone",
              "enum": [
                "clone",
                "incremental",
                "auto"
              ],
              "type": "string"
            }
          },
          "type": "object",
          "additionalProperties": false
        },
        "credentialsSecret": {
          "properties": {
            "key": {
              "type": "string"
            },
            "name": {
              "default": "",
              "type": "string"
            },
            "optional": {
              "type": "boolean"
            }
          },
          "required": [
            "key"
          ],
          "type": "object",
          "x-kubernetes-map-type": "atomic",
          "x-kubernetes-validations": [
            {
              "message": "credentialsSecret.name must be set",
              "rule": "has(self.name) && self.name != ''"
            }
          ],
          "additionalProperties": false
        },
        "mysqlshellRunner": {
          "properties": {
            "image": {
              "minLength": 1,
              "type": "string"
            }
          },
          "required": [
            "image"
          ],
          "type": "object",
          "additionalProperties": false
        },
        "primaryCluster": {
          "maxLength": 63,
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "primaryCluster must contain only alphanumeric characters",
              "rule": "self.matches('^[A-Za-z0-9]+$')"
            }
          ]
        },
        "sslMode": {
          "default": "AUTO",
          "enum": [
            "AUTO",
            "DISABLED",
            "REQUIRED",
            "VERIFY_CA",
            "VERIFY_IDENTITY"
          ],
          "type": "string"
        },
        "unsafeFlags": {
          "properties": {
            "forcedClusterRemoval": {
              "default": false,
              "type": "boolean"
            },
            "forcedFailover": {
              "default": false,
              "type": "boolean"
            }
          },
          "type": "object",
          "additionalProperties": false
        }
      },
      "required": [
        "clusters",
        "credentialsSecret",
        "mysqlshellRunner",
        "primaryCluster"
      ],
      "type": "object",
      "x-kubernetes-validations": [
        {
          "message": "spec.primaryCluster not found in spec.clusters",
          "rule": "self.clusters.exists(c, c.innodbClusterName == self.primaryCluster)"
        },
        {
          "message": "endpoint host must be unique across all clusters",
          "rule": "self.clusters.all(c, c.endpoints.all(e, self.clusters.map(c2, c2.endpoints.filter(e2, e2.host == e.host).size()).sum() == 1))"
        }
      ],
      "additionalProperties": false
    },
    "status": {
      "properties": {
        "clusters": {
          "additionalProperties": {
            "properties": {
              "clusterRole": {
                "type": "string"
              },
              "globalStatus": {
                "type": "string"
              },
              "primary": {
                "type": "string"
              }
            },
            "required": [
              "clusterRole",
              "globalStatus",
              "primary"
            ],
            "type": "object",
            "additionalProperties": false
          },
          "type": "object"
        },
        "conditions": {
          "items": {
            "properties": {
              "lastTransitionTime": {
                "format": "date-time",
                "type": "string"
              },
              "message": {
                "maxLength": 32768,
                "type": "string"
              },
              "observedGeneration": {
                "format": "int64",
                "minimum": 0,
                "type": "integer"
              },
              "reason": {
                "maxLength": 1024,
                "minLength": 1,
                "pattern": "^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$",
                "type": "string"
              },
              "status": {
                "enum": [
                  "True",
                  "False",
                  "Unknown"
                ],
                "type": "string"
              },
              "type": {
                "maxLength": 316,
                "pattern": "^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$",
                "type": "string"
              }
            },
            "required": [
              "lastTransitionTime",
              "message",
              "reason",
              "status",
              "type"
            ],
            "type": "object",
            "additionalProperties": false
          },
          "type": "array"
        },
        "lastObservedAt": {
          "format": "date-time",
          "type": "string"
        },
        "lastObservedGeneration": {
          "format": "int64",
          "type": "integer"
        },
        "primaryCluster": {
          "type": "string"
        },
        "primaryClusterEndpoint": {
          "type": "string"
        }
      },
      "required": [
        "primaryCluster",
        "primaryClusterEndpoint"
      ],
      "type": "object",
      "additionalProperties": false
    }
  },
  "type": "object"
}
