{
  "$id": "https://niklasrosenstein.github.io/gitopsctr/schemas/apis/gitopsctr.io/v1/Project.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "apiVersion": {
      "const": "gitopsctr.io/v1"
    },
    "kind": {
      "const": "Project"
    },
    "metadata": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "maxLength": 253,
          "minLength": 1,
          "pattern": "^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?(?:\\.[a-z0-9](?:[-a-z0-9]*[a-z0-9])?)*$",
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    },
    "spec": {
      "additionalProperties": false,
      "properties": {
        "effectLease": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "additionalProperties": false,
              "properties": {
                "store": {
                  "oneOf": [
                    {
                      "type": "null"
                    },
                    {
                      "additionalProperties": false,
                      "properties": {
                        "branch": {
                          "additionalProperties": false,
                          "properties": {
                            "ref": {
                              "minLength": 1,
                              "pattern": "^(?:[^{}]|\\{environment\\}|\\{unit\\})+$",
                              "type": "string"
                            }
                          },
                          "required": [
                            "ref"
                          ],
                          "type": "object"
                        }
                      },
                      "required": [
                        "branch"
                      ],
                      "type": "object"
                    }
                  ]
                }
              },
              "required": [
                "store"
              ],
              "type": "object"
            }
          ]
        },
        "environmentDefaults": {
          "additionalProperties": false,
          "properties": {
            "refs": {
              "additionalProperties": false,
              "minProperties": 1,
              "properties": {
                "candidate": {
                  "description": "Default reviewed-change candidate ref template. Must contain {environment}; may also contain {id} and {operation}.",
                  "pattern": "^(?:[^{}]|\\{id\\}|\\{operation\\})*\\{environment\\}(?:[^{}]|\\{environment\\}|\\{id\\}|\\{operation\\})*$",
                  "type": "string"
                },
                "desired": {
                  "description": "Default desired-state ref template. Must contain {environment}; no other placeholders are supported.",
                  "pattern": "^(?:[^{}]|\\{environment\\})*\\{environment\\}(?:[^{}]|\\{environment\\})*$",
                  "type": "string"
                },
                "observed": {
                  "description": "Default observed-state ref template. Must contain {environment}; no other placeholders are supported.",
                  "pattern": "^(?:[^{}]|\\{environment\\})*\\{environment\\}(?:[^{}]|\\{environment\\})*$",
                  "type": "string"
                }
              },
              "type": "object"
            }
          },
          "required": [
            "refs"
          ],
          "type": "object"
        },
        "environmentsPath": {
          "description": "Repository-relative directory containing authored environments.",
          "minLength": 1,
          "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$)).+$",
          "type": "string"
        },
        "sourceRevisionPolicy": {
          "additionalProperties": false,
          "properties": {
            "unavailableWhen": {
              "default": "outside-candidate-history",
              "description": "Treat a retained source as unavailable when its commit is missing or outside the candidate revision's history.",
              "enum": [
                "missing",
                "outside-candidate-history"
              ],
              "type": "string"
            },
            "whenUnavailableDuringApply": {
              "default": "refresh",
              "description": "Action when an unavailable retained source is found during apply.",
              "enum": [
                "refresh",
                "error"
              ],
              "type": "string"
            },
            "whenUnavailableDuringPlan": {
              "default": "error",
              "description": "Action when an unavailable retained source is found during planning.",
              "enum": [
                "error",
                "refresh"
              ],
              "type": "string"
            }
          },
          "type": "object"
        },
        "stackTemplatesPath": {
          "description": "Repository-relative directory containing authored StackTemplates.",
          "minLength": 1,
          "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$)).+$",
          "type": "string"
        },
        "writeFormat": {
          "enum": [
            "yaml",
            "json"
          ]
        }
      },
      "required": [
        "effectLease"
      ],
      "type": "object"
    }
  },
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "spec"
  ],
  "title": "Project (gitopsctr.io/v1)",
  "type": "object"
}
