{
  "$defs": {
    "TemplateValue": {
      "oneOf": [
        {
          "additionalProperties": false,
          "properties": {
            "fromArtifact": {
              "additionalProperties": false,
              "properties": {
                "apiVersion": {
                  "pattern": "^[^/]+/[^/]+$",
                  "type": "string"
                },
                "dryFallback": {
                  "$ref": "#/$defs/TemplateValue",
                  "description": "Type-correct speculative value used only during dry resolution when the reference is unavailable."
                },
                "kind": {
                  "pattern": "^[A-Z][A-Za-z0-9]*$",
                  "type": "string"
                },
                "name": {
                  "pattern": "^[a-z0-9][a-z0-9-]*$",
                  "type": "string"
                },
                "pointer": {
                  "default": "",
                  "description": "JSON Pointer relative to the complete artifact resource; empty selects the whole resource.",
                  "pattern": "^(?:$|/(?:[^~]|~[01])*)$",
                  "type": "string"
                },
                "unit": {
                  "description": "Logical name of the unit that provides the referenced value.",
                  "pattern": "^[a-z0-9][a-z0-9-]*(?:/[a-z0-9][a-z0-9-]*)*$",
                  "type": "string"
                }
              },
              "required": [
                "unit",
                "name",
                "apiVersion",
                "kind"
              ],
              "type": "object"
            }
          },
          "required": [
            "fromArtifact"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "fromEnvironment": {
              "additionalProperties": false,
              "properties": {
                "pointer": {
                  "description": "JSON Pointer relative to the target Environment resource.",
                  "pattern": "^(?:$|/(?:[^~]|~[01])*)$",
                  "type": "string"
                },
                "unit": {
                  "description": "Logical name of the unit that provides the referenced value.",
                  "pattern": "^[a-z0-9][a-z0-9-]*(?:/[a-z0-9][a-z0-9-]*)*$",
                  "type": "string"
                }
              },
              "required": [],
              "type": "object"
            }
          },
          "required": [
            "fromEnvironment"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "fromPromotion": {
              "additionalProperties": false,
              "properties": {
                "dryFallback": {
                  "$ref": "#/$defs/TemplateValue",
                  "description": "Type-correct speculative value used only during dry resolution when the reference is unavailable."
                },
                "pointer": {
                  "description": "JSON Pointer relative to the promoted unit's public spec; omit it to use the containing field path, or set it to an empty string to select the whole spec.",
                  "pattern": "^(?:$|/(?:[^~]|~[01])*)$",
                  "type": "string"
                },
                "unit": {
                  "description": "Promoted source unit name; omit it to use the target unit name.",
                  "pattern": "^[a-z0-9][a-z0-9-]*(?:/[a-z0-9][a-z0-9-]*)*$",
                  "type": "string"
                }
              },
              "required": [],
              "type": "object"
            }
          },
          "required": [
            "fromPromotion"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "fromReceipt": {
              "additionalProperties": false,
              "properties": {
                "dryFallback": {
                  "$ref": "#/$defs/TemplateValue",
                  "description": "Type-correct speculative value used only during dry resolution when the reference is unavailable."
                },
                "pointer": {
                  "default": "",
                  "description": "JSON Pointer relative to the producer's typed receipt result; empty selects the whole result.",
                  "pattern": "^(?:$|/(?:[^~]|~[01])*)$",
                  "type": "string"
                },
                "unit": {
                  "description": "Logical name of the unit that provides the referenced value.",
                  "pattern": "^[a-z0-9][a-z0-9-]*(?:/[a-z0-9][a-z0-9-]*)*$",
                  "type": "string"
                }
              },
              "required": [
                "unit"
              ],
              "type": "object"
            }
          },
          "required": [
            "fromReceipt"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "fromParameter": {
              "additionalProperties": false,
              "properties": {
                "name": {
                  "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                  "type": "string"
                }
              },
              "required": [
                "name"
              ],
              "type": "object"
            }
          },
          "required": [
            "fromParameter"
          ],
          "type": "object"
        },
        {
          "type": "null"
        },
        {
          "type": "boolean"
        },
        {
          "type": "number"
        },
        {
          "type": "string"
        },
        {
          "items": {
            "$ref": "#/$defs/TemplateValue"
          },
          "type": "array"
        },
        {
          "additionalProperties": {
            "$ref": "#/$defs/TemplateValue"
          },
          "propertyNames": {
            "not": {
              "enum": [
                "fromArtifact",
                "fromEnvironment",
                "fromParameter",
                "fromPromotion",
                "fromReceipt"
              ]
            }
          },
          "type": "object"
        }
      ]
    }
  },
  "$id": "https://niklasrosenstein.github.io/gitopsctr/schemas/apis/gitopsctr.io/v1/StackTemplate/authored.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "apiVersion": {
      "const": "gitopsctr.io/v1"
    },
    "kind": {
      "const": "StackTemplate"
    },
    "metadata": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "minLength": 1,
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    },
    "spec": {
      "anyOf": [
        {
          "additionalProperties": false,
          "properties": {
            "parameters": {
              "items": {
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "string",
                      "integer",
                      "number",
                      "boolean",
                      "object",
                      "array"
                    ]
                  }
                },
                "required": [
                  "name",
                  "type"
                ],
                "title": "ParameterDeclaration",
                "type": "object"
              },
              "type": "array"
            },
            "unitTemplates": {
              "additionalProperties": {
                "additionalProperties": false,
                "properties": {
                  "apiVersion": {
                    "pattern": "^[^/]+/[^/]+$",
                    "type": "string"
                  },
                  "dependsOn": {
                    "items": {
                      "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "kind": {
                    "pattern": "^[A-Z][A-Za-z0-9]*$",
                    "type": "string"
                  },
                  "spec": {
                    "additionalProperties": {
                      "$ref": "#/$defs/TemplateValue"
                    },
                    "propertyNames": {
                      "not": {
                        "enum": [
                          "fromArtifact",
                          "fromEnvironment",
                          "fromParameter",
                          "fromPromotion",
                          "fromReceipt"
                        ]
                      }
                    },
                    "type": "object"
                  }
                },
                "required": [
                  "apiVersion",
                  "kind",
                  "spec"
                ],
                "title": "StackTemplateUnitTemplate",
                "type": "object"
              },
              "propertyNames": {
                "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                "type": "string"
              },
              "type": "object"
            }
          },
          "required": [
            "parameters",
            "unitTemplates"
          ],
          "title": "StackTemplateInlineSpec",
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "source": {
              "additionalProperties": false,
              "properties": {
                "fromGit": {
                  "additionalProperties": false,
                  "properties": {
                    "documentDigest": {
                      "anyOf": [
                        {
                          "pattern": "^sha256:[0-9a-f]{64}$",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "default": null
                    },
                    "path": {
                      "pattern": "^(?!/)(?!.*\\\\)(?!.*(?:^|/)(?:\\.{1,2})(?:/|$))[^/]+(?:/[^/]+)*$",
                      "type": "string"
                    },
                    "repository": {
                      "pattern": "^[^\\s\\x00]+$",
                      "type": "string"
                    },
                    "revision": {
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9._/-]*$",
                      "type": "string"
                    }
                  },
                  "required": [
                    "repository",
                    "revision",
                    "path"
                  ],
                  "title": "StackTemplateGitRequest",
                  "type": "object"
                }
              },
              "required": [
                "fromGit"
              ],
              "title": "StackTemplateSourceFromGit",
              "type": "object"
            }
          },
          "required": [
            "source"
          ],
          "title": "StackTemplateGitSpec",
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "source": {
              "additionalProperties": false,
              "properties": {
                "fromPromotion": {
                  "additionalProperties": false,
                  "properties": {
                    "stack": {
                      "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                      "type": "string"
                    }
                  },
                  "required": [
                    "stack"
                  ],
                  "title": "StackTemplatePromotionRequest",
                  "type": "object"
                }
              },
              "required": [
                "fromPromotion"
              ],
              "title": "StackTemplateSourceFromPromotion",
              "type": "object"
            }
          },
          "required": [
            "source"
          ],
          "title": "StackTemplatePromotionSpec",
          "type": "object"
        }
      ]
    }
  },
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "spec"
  ],
  "title": "StackTemplate (gitopsctr.io/v1)",
  "type": "object"
}
