{
  "$defs": {
    "exactArtifact": {
      "additionalProperties": false,
      "properties": {
        "artifact_ref": {
          "pattern": "^cache://(?!(?:[Cc][Uu][Rr][Rr][Ee][Nn][Tt]|[Ll][Aa][Tt][Ee][Ss][Tt])(?:/|$))(?![^\\s]*/(?:[Cc][Uu][Rr][Rr][Ee][Nn][Tt]|[Ll][Aa][Tt][Ee][Ss][Tt])(?:/|$))[^\\s]+$",
          "type": "string"
        },
        "bytes": {
          "minimum": 1,
          "type": "integer"
        },
        "sha256": {
          "$ref": "#/$defs/sha256"
        }
      },
      "required": [
        "artifact_ref",
        "sha256",
        "bytes"
      ],
      "type": "object"
    },
    "identity": {
      "pattern": "^sha256:[0-9a-f]{64}$",
      "type": "string"
    },
    "mssqlAssetOutletProjection": {
      "additionalProperties": false,
      "properties": {
        "binding_set_ref": {
          "$ref": "#/$defs/identity"
        },
        "connection_registry_ref": {
          "$ref": "#/$defs/identity"
        },
        "entries": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "asset_ref": {
                "additionalProperties": false,
                "properties": {
                  "connection_ref": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "database": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "engine": {
                    "const": "mssql"
                  },
                  "schema": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "table": {
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "engine",
                  "connection_ref",
                  "database",
                  "schema",
                  "table"
                ],
                "type": "object"
              },
              "asset_ref_sha256": {
                "$ref": "#/$defs/identity"
              },
              "registry_connection_ref": {
                "minLength": 1,
                "type": "string"
              },
              "resolved_binding": {
                "additionalProperties": false,
                "properties": {
                  "registry_connection_ref": {
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "registry_connection_ref"
                ],
                "type": "object"
              },
              "uri": {
                "maxLength": 2048,
                "minLength": 1,
                "pattern": "^mssql://[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?:[1-9][0-9]{0,4}/(?:[A-Za-z0-9._~%-]+/){2,3}[A-Za-z0-9._~%-]+$",
                "type": "string"
              },
              "workload_ids": {
                "items": {
                  "minLength": 1,
                  "type": "string"
                },
                "maxItems": 1024,
                "minItems": 1,
                "type": "array",
                "uniqueItems": true
              }
            },
            "required": [
              "asset_ref",
              "asset_ref_sha256",
              "registry_connection_ref",
              "resolved_binding",
              "workload_ids",
              "uri"
            ],
            "type": "object"
          },
          "maxItems": 4096,
          "minItems": 1,
          "type": "array"
        },
        "environment": {
          "minLength": 1,
          "type": "string"
        },
        "projection_sha256": {
          "$ref": "#/$defs/identity"
        },
        "schema": {
          "const": "dpone.mssql-asset-outlet-projection.v1"
        }
      },
      "required": [
        "schema",
        "environment",
        "binding_set_ref",
        "connection_registry_ref",
        "entries",
        "projection_sha256"
      ],
      "type": "object"
    },
    "sha256": {
      "pattern": "^sha256:[0-9a-f]{64}$",
      "type": "string"
    }
  },
  "$id": "https://paulkov.github.io/dpone/schemas/gitops/deployment-set-v3.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "trust_tier": {
            "const": "production"
          }
        },
        "required": [
          "trust_tier"
        ]
      },
      "then": {
        "properties": {
          "runtime_artifact_delivery": {
            "properties": {
              "trust_tier": {
                "const": "production"
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "trust_tier": {
            "const": "non_production"
          }
        },
        "required": [
          "trust_tier"
        ]
      },
      "then": {
        "properties": {
          "runtime_artifact_delivery": {
            "properties": {
              "trust_tier": {
                "const": "non_production"
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "required": [
          "dev_evidence_delivery"
        ]
      },
      "then": {
        "properties": {
          "trust_tier": {
            "const": "non_production"
          }
        }
      }
    }
  ],
  "properties": {
    "airflow_bundle_ref": {
      "type": [
        "string",
        "null"
      ]
    },
    "binding_set": {
      "allOf": [
        {
          "$ref": "#/$defs/exactArtifact"
        },
        {
          "properties": {
            "artifact_ref": {
              "pattern": "^cache://runtime-connection-contexts/sha256-[0-9a-f]{64}/binding-set[.]json$"
            }
          }
        }
      ]
    },
    "binding_set_ref": {
      "$ref": "#/$defs/identity"
    },
    "connection_registry": {
      "allOf": [
        {
          "$ref": "#/$defs/exactArtifact"
        },
        {
          "properties": {
            "artifact_ref": {
              "pattern": "^cache://runtime-connection-contexts/sha256-[0-9a-f]{64}/connection-registry[.]json$"
            }
          }
        }
      ]
    },
    "connection_registry_ref": {
      "$ref": "#/$defs/identity"
    },
    "credential_runtime": {
      "allOf": [
        {
          "$ref": "#/$defs/exactArtifact"
        },
        {
          "properties": {
            "artifact_ref": {
              "pattern": "^cache://runtime-connection-contexts/sha256-[0-9a-f]{64}/credential-runtime[.]json$"
            }
          }
        }
      ]
    },
    "credential_runtime_ref": {
      "$ref": "#/$defs/identity"
    },
    "deployment_id": {
      "$ref": "#/$defs/identity"
    },
    "deployment_type": {
      "const": "environment"
    },
    "dev_evidence_delivery": {
      "additionalProperties": false,
      "properties": {
        "claim_name": {
          "maxLength": 63,
          "pattern": "^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$",
          "type": "string"
        },
        "mode": {
          "const": "shared_pvc"
        },
        "mount_path": {
          "const": "/var/lib/dpone/dev-evidence"
        },
        "worker_queue": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$",
          "type": "string"
        }
      },
      "required": [
        "mode",
        "claim_name",
        "mount_path",
        "worker_queue"
      ],
      "type": "object"
    },
    "environment": {
      "minLength": 1,
      "type": "string"
    },
    "mssql_asset_outlet_projection": {
      "$ref": "#/$defs/mssqlAssetOutletProjection"
    },
    "release_ref": {
      "$ref": "#/$defs/identity"
    },
    "runnable": {
      "const": true
    },
    "runtime_artifact_delivery": {
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "trust_tier": {
                "const": "production"
              }
            },
            "required": [
              "trust_tier"
            ]
          },
          "then": {
            "properties": {
              "verify": {
                "properties": {
                  "attestations": {
                    "const": "required_for_prod"
                  }
                }
              }
            },
            "required": [
              "trust_policy_ref"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "trust_tier": {
                "const": "non_production"
              }
            },
            "required": [
              "trust_tier"
            ]
          },
          "then": {
            "properties": {
              "verify": {
                "properties": {
                  "attestations": {
                    "const": "optional"
                  }
                }
              }
            }
          }
        }
      ],
      "properties": {
        "artifact_registry_ref": {
          "maxLength": 128,
          "pattern": "^(?=.{1,128}$)(?!(?:[Cc][Uu][Rr][Rr][Ee][Nn][Tt]|[Ll][Aa][Tt][Ee][Ss][Tt])$)(?!(?:sk_(?:live|test|prod)_[A-Za-z0-9_-]{8,}|sk-(?:proj|svcacct)-[A-Za-z0-9_-]{8,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|xox[baprs]-[A-Za-z0-9-]{16,})$)[A-Za-z0-9][A-Za-z0-9_.-]*$",
          "type": "string"
        },
        "identity": {
          "additionalProperties": false,
          "properties": {
            "method": {
              "enum": [
                "kubernetes_workload_identity"
              ]
            },
            "namespace": {
              "maxLength": 63,
              "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
              "type": "string"
            },
            "service_account": {
              "maxLength": 63,
              "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
              "type": "string"
            }
          },
          "required": [
            "method",
            "service_account",
            "namespace"
          ],
          "type": "object"
        },
        "mode": {
          "const": "init_fetch"
        },
        "registry_config_ref": {
          "additionalProperties": false,
          "properties": {
            "key": {
              "maxLength": 253,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,252}$",
              "type": "string"
            },
            "kind": {
              "const": "kubernetes_config_map"
            },
            "name": {
              "maxLength": 63,
              "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
              "type": "string"
            },
            "sha256": {
              "pattern": "^sha256:[0-9a-f]{64}$",
              "type": "string"
            }
          },
          "required": [
            "kind",
            "name",
            "key",
            "sha256"
          ],
          "type": "object"
        },
        "source": {
          "additionalProperties": false,
          "properties": {
            "artifact_registry_ref": {
              "maxLength": 128,
              "pattern": "^(?=.{1,128}$)(?!(?:[Cc][Uu][Rr][Rr][Ee][Nn][Tt]|[Ll][Aa][Tt][Ee][Ss][Tt])$)(?!(?:sk_(?:live|test|prod)_[A-Za-z0-9_-]{8,}|sk-(?:proj|svcacct)-[A-Za-z0-9_-]{8,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|xox[baprs]-[A-Za-z0-9-]{16,})$)[A-Za-z0-9][A-Za-z0-9_.-]*$",
              "type": "string"
            }
          },
          "required": [
            "artifact_registry_ref"
          ],
          "type": "object"
        },
        "trust_policy_ref": {
          "additionalProperties": false,
          "properties": {
            "key": {
              "maxLength": 253,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,252}$",
              "type": "string"
            },
            "kind": {
              "const": "kubernetes_config_map"
            },
            "name": {
              "maxLength": 63,
              "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
              "type": "string"
            },
            "sha256": {
              "pattern": "^sha256:[0-9a-f]{64}$",
              "type": "string"
            }
          },
          "required": [
            "kind",
            "name",
            "key",
            "sha256"
          ],
          "type": "object"
        },
        "trust_tier": {
          "enum": [
            "production",
            "non_production"
          ]
        },
        "verify": {
          "additionalProperties": false,
          "properties": {
            "attestations": {
              "enum": [
                "optional",
                "required_for_prod"
              ]
            },
            "checksums": {
              "enum": [
                "required"
              ]
            }
          },
          "required": [
            "checksums",
            "attestations"
          ],
          "type": "object"
        }
      },
      "required": [
        "mode",
        "trust_tier",
        "artifact_registry_ref",
        "identity",
        "registry_config_ref",
        "source",
        "verify"
      ],
      "type": "object"
    },
    "runtime_image_digest": {
      "$ref": "#/$defs/identity"
    },
    "runtime_image_ref": {
      "pattern": "^(?!.*(?:\\s|://|\\?|#|=))[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?::(?!0+/)(?:[0-9]{1,4}|[0-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?/[a-z0-9]+(?:[._/-][a-z0-9]+)*@sha256:[0-9a-f]{64}$",
      "type": "string"
    },
    "schema": {
      "const": "dpone.deployment-set.v3"
    },
    "trust_tier": {
      "enum": [
        "production",
        "non_production"
      ]
    },
    "workloads": {
      "items": {
        "additionalProperties": false,
        "properties": {
          "id": {
            "minLength": 1,
            "type": "string"
          },
          "pack_fingerprint": {
            "$ref": "#/$defs/identity"
          },
          "sha256": {
            "$ref": "#/$defs/identity"
          }
        },
        "required": [
          "id",
          "sha256",
          "pack_fingerprint"
        ],
        "type": "object"
      },
      "minItems": 1,
      "type": "array"
    }
  },
  "required": [
    "schema",
    "deployment_id",
    "deployment_type",
    "runnable",
    "environment",
    "trust_tier",
    "release_ref",
    "binding_set_ref",
    "connection_registry_ref",
    "credential_runtime_ref",
    "binding_set",
    "connection_registry",
    "credential_runtime",
    "runtime_image_ref",
    "runtime_image_digest",
    "airflow_bundle_ref",
    "runtime_artifact_delivery",
    "workloads",
    "mssql_asset_outlet_projection"
  ],
  "title": "dpone GitOps executable deployment-set v3",
  "type": "object"
}
