{
  "$defs": {
    "ProjectionValue": {
      "oneOf": [
        {
          "additionalProperties": false,
          "properties": {
            "fromArtifact": {
              "additionalProperties": false,
              "properties": {
                "apiVersion": {
                  "pattern": "^[^/]+/[^/]+$",
                  "type": "string"
                },
                "dryFallback": {
                  "$ref": "#/$defs/ProjectionValue",
                  "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/ProjectionValue",
                  "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/ProjectionValue",
                  "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"
        },
        {
          "type": "null"
        },
        {
          "type": "boolean"
        },
        {
          "type": "number"
        },
        {
          "type": "string"
        },
        {
          "items": {
            "$ref": "#/$defs/ProjectionValue"
          },
          "type": "array"
        },
        {
          "additionalProperties": {
            "$ref": "#/$defs/ProjectionValue"
          },
          "propertyNames": {
            "not": {
              "enum": [
                "fromArtifact",
                "fromEnvironment",
                "fromParameter",
                "fromPromotion",
                "fromReceipt"
              ]
            }
          },
          "type": "object"
        }
      ]
    }
  },
  "$id": "https://niklasrosenstein.github.io/gitopsctr/schemas/apis/gitopsctr.io/v1/Stack/desired.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "apiVersion": {
      "const": "gitopsctr.io/v1"
    },
    "kind": {
      "const": "Stack"
    },
    "metadata": {
      "additionalProperties": false,
      "not": {
        "properties": {
          "labels": {
            "required": [
              "gitopsctr.io/partition"
            ]
          }
        },
        "required": [
          "ownerReferences",
          "labels"
        ]
      },
      "properties": {
        "deletion": {
          "additionalProperties": false,
          "properties": {
            "generation": {
              "minimum": 1,
              "type": "integer"
            },
            "resourceDigest": {
              "pattern": "^sha256:[0-9a-f]{64}$",
              "type": "string"
            }
          },
          "required": [
            "generation",
            "resourceDigest"
          ],
          "title": "DeletionMetadata",
          "type": "object"
        },
        "labels": {
          "additionalProperties": {
            "type": "string"
          },
          "properties": {
            "gitopsctr.io/partition": {
              "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
              "type": "string"
            }
          },
          "propertyNames": {
            "type": "string"
          },
          "type": "object"
        },
        "name": {
          "minLength": 1,
          "type": "string"
        },
        "ownerReferences": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "apiVersion": {
                "minLength": 1,
                "type": "string"
              },
              "kind": {
                "minLength": 1,
                "type": "string"
              },
              "name": {
                "minLength": 1,
                "type": "string"
              },
              "uid": {
                "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                "type": "string"
              }
            },
            "required": [
              "apiVersion",
              "kind",
              "name",
              "uid"
            ],
            "title": "DesiredOwnerReference",
            "type": "object"
          },
          "maxItems": 1,
          "minItems": 1,
          "type": "array"
        },
        "uid": {
          "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
          "type": "string"
        }
      },
      "required": [
        "name",
        "uid"
      ],
      "type": "object"
    },
    "spec": {
      "additionalProperties": false,
      "properties": {
        "activeProjection": {
          "anyOf": [
            {
              "additionalProperties": false,
              "properties": {
                "projectionContextDigest": {
                  "pattern": "^sha256:[0-9a-f]{64}$",
                  "type": "string"
                },
                "projectionDigest": {
                  "pattern": "^sha256:[0-9a-f]{64}$",
                  "type": "string"
                },
                "sourceProjectionDigest": {
                  "pattern": "^sha256:[0-9a-f]{64}$",
                  "type": "string"
                },
                "units": {
                  "additionalProperties": {
                    "additionalProperties": false,
                    "properties": {
                      "apiVersion": {
                        "pattern": "^[^/]+/[^/]+$",
                        "type": "string"
                      },
                      "dependsOn": {
                        "items": {
                          "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                          "type": "string"
                        },
                        "type": "array"
                      },
                      "desiredDigest": {
                        "pattern": "^sha256:[0-9a-f]{64}$",
                        "type": "string"
                      },
                      "kind": {
                        "pattern": "^[A-Z][A-Za-z0-9]*$",
                        "type": "string"
                      },
                      "name": {
                        "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                        "type": "string"
                      },
                      "projectionContextDigest": {
                        "pattern": "^sha256:[0-9a-f]{64}$",
                        "type": "string"
                      },
                      "sourceProjectionDigest": {
                        "pattern": "^sha256:[0-9a-f]{64}$",
                        "type": "string"
                      },
                      "uid": {
                        "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                        "type": "string"
                      }
                    },
                    "required": [
                      "apiVersion",
                      "kind",
                      "name",
                      "uid",
                      "desiredDigest",
                      "sourceProjectionDigest",
                      "projectionContextDigest"
                    ],
                    "title": "StackProjectionUnitBinding",
                    "type": "object"
                  },
                  "propertyNames": {
                    "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                    "type": "string"
                  },
                  "type": "object"
                }
              },
              "required": [
                "sourceProjectionDigest",
                "projectionContextDigest",
                "units",
                "projectionDigest"
              ],
              "title": "StackActiveProjection",
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "artifactImports": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "apiVersion": {
                "pattern": "^[^/]+/[^/]+$",
                "type": "string"
              },
              "fromPromotion": {
                "additionalProperties": false,
                "properties": {
                  "stack": {
                    "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                    "type": "string"
                  }
                },
                "required": [
                  "stack"
                ],
                "title": "PromotionStackReference",
                "type": "object"
              },
              "kind": {
                "pattern": "^[A-Z][A-Za-z0-9]*$",
                "type": "string"
              },
              "name": {
                "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                "type": "string"
              },
              "unit": {
                "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                "type": "string"
              }
            },
            "required": [
              "unit",
              "name",
              "apiVersion",
              "kind",
              "fromPromotion"
            ],
            "title": "ArtifactImport",
            "type": "object"
          },
          "type": "array"
        },
        "parameters": {
          "type": "object"
        },
        "resolvedArtifactImports": {
          "anyOf": [
            {
              "additionalProperties": {
                "additionalProperties": false,
                "properties": {
                  "apiVersion": {
                    "pattern": "^[^/]+/[^/]+$",
                    "type": "string"
                  },
                  "artifactDigest": {
                    "pattern": "^[a-z0-9]+:[0-9a-f]{64}$",
                    "type": "string"
                  },
                  "artifactDocument": {
                    "type": "object"
                  },
                  "artifactName": {
                    "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                    "type": "string"
                  },
                  "kind": {
                    "pattern": "^[A-Z][A-Za-z0-9]*$",
                    "type": "string"
                  },
                  "receiptUnitBlob": {
                    "pattern": "^[0-9a-f]{40}$",
                    "type": "string"
                  },
                  "sourceDesiredRevision": {
                    "pattern": "^[0-9a-f]{40}$",
                    "type": "string"
                  },
                  "sourceObservedRevision": {
                    "pattern": "^[0-9a-f]{40}$",
                    "type": "string"
                  },
                  "sourceStack": {
                    "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                    "type": "string"
                  },
                  "sourceStackUid": {
                    "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                    "type": "string"
                  },
                  "sourceUnit": {
                    "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                    "type": "string"
                  },
                  "sourceUnitUid": {
                    "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                    "type": "string"
                  },
                  "targetStackUid": {
                    "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                    "type": "string"
                  }
                },
                "required": [
                  "sourceStack",
                  "sourceStackUid",
                  "sourceUnit",
                  "sourceUnitUid",
                  "sourceDesiredRevision",
                  "sourceObservedRevision",
                  "receiptUnitBlob",
                  "artifactName",
                  "apiVersion",
                  "kind",
                  "artifactDigest",
                  "targetStackUid",
                  "artifactDocument"
                ],
                "title": "ResolvedArtifactImport",
                "type": "object"
              },
              "propertyNames": {
                "type": "string"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "structuralProjection": {
          "additionalProperties": false,
          "properties": {
            "identity": {
              "additionalProperties": false,
              "properties": {
                "projectionContextDigest": {
                  "pattern": "^sha256:[0-9a-f]{64}$",
                  "type": "string"
                },
                "projectionDigest": {
                  "pattern": "^sha256:[0-9a-f]{64}$",
                  "type": "string"
                },
                "stackUid": {
                  "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                  "type": "string"
                },
                "templateContentDigest": {
                  "pattern": "^sha256:[0-9a-f]{64}$",
                  "type": "string"
                },
                "templateUid": {
                  "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                  "type": "string"
                }
              },
              "required": [
                "stackUid",
                "templateUid",
                "templateContentDigest",
                "projectionContextDigest",
                "projectionDigest"
              ],
              "title": "StackProjectionIdentity",
              "type": "object"
            },
            "units": {
              "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/ProjectionValue"
                    },
                    "propertyNames": {
                      "not": {
                        "enum": [
                          "fromArtifact",
                          "fromEnvironment",
                          "fromParameter",
                          "fromPromotion",
                          "fromReceipt"
                        ]
                      }
                    },
                    "type": "object"
                  }
                },
                "required": [
                  "apiVersion",
                  "kind",
                  "spec",
                  "dependsOn"
                ],
                "title": "StackProjectionUnit",
                "type": "object"
              },
              "propertyNames": {
                "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                "type": "string"
              },
              "type": "object"
            }
          },
          "required": [
            "identity",
            "units"
          ],
          "title": "StackProjection",
          "type": "object"
        },
        "templateRef": {
          "additionalProperties": false,
          "properties": {
            "contentDigest": {
              "pattern": "^sha256:[0-9a-f]{64}$",
              "type": "string"
            },
            "name": {
              "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
              "type": "string"
            },
            "uid": {
              "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
              "type": "string"
            }
          },
          "required": [
            "name",
            "uid",
            "contentDigest"
          ],
          "title": "StackTemplateReference",
          "type": "object"
        },
        "units": {
          "anyOf": [
            {
              "items": {
                "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "templateRef",
        "structuralProjection"
      ],
      "type": "object"
    }
  },
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "spec"
  ],
  "title": "Stack (gitopsctr.io/v1)",
  "type": "object"
}
