schema/toolchain-project.schema.json

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://allsagetech.com/toolchain/schemas/project-v1.json",
  "title": "Toolchain project and deployment manifest",
  "type": "object",
  "additionalProperties": false,
  "anyOf": [
    { "required": ["packages"] },
    { "required": ["deployment"] },
    { "required": ["components"] }
  ],
  "properties": {
    "schemaVersion": { "const": 1 },
    "apiVersion": { "const": "toolchain.allsagetech.com/v1alpha1" },
    "kind": { "const": "ToolchainPackageConfig" },
    "metadata": { "$ref": "#/$defs/metadata" },
    "packages": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/package" } },
    "deployment": { "$ref": "#/$defs/deployment" },
    "components": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/component" } },
    "values": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "files": { "type": "array", "items": { "type": "string", "minLength": 1 } },
        "schema": { "type": "string", "minLength": 1 }
      }
    },
    "documentation": { "type": "object", "additionalProperties": { "type": "string", "minLength": 1 } },
    "constants": { "type": "array" },
    "variables": { "type": "array", "items": { "$ref": "#/$defs/variable" } },
    "build": { "type": "object" }
  },
  "$defs": {
    "metadata": {
      "type": "object",
      "required": ["name", "version"],
      "properties": {
        "name": { "type": "string", "pattern": "^[a-z0-9](?:[-a-z0-9.]*[a-z0-9])?$" },
        "version": { "type": ["string", "number"] },
        "description": { "type": "string" },
        "url": { "type": "string" },
        "image": { "type": "string" },
        "uncompressed": { "type": "boolean" },
        "architecture": { "enum": ["amd64", "arm64"] },
        "yolo": { "type": "boolean" },
        "authors": { "type": "string" },
        "documentation": { "type": "string" },
        "source": { "type": "string" },
        "vendor": { "type": "string" },
        "aggregateChecksum": { "type": "string" },
        "annotations": { "type": "object" },
        "allowNamespaceOverride": { "type": "boolean" }
      }
    },
    "package": {
      "oneOf": [
        { "type": "string", "minLength": 1 },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["name"],
          "properties": {
            "name": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$" },
            "version": { "type": ["string", "number"] },
            "configuration": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$" },
            "dependencies": { "type": "array", "items": { "$ref": "#/$defs/package" } },
            "dependsOn": { "type": "array", "items": { "$ref": "#/$defs/package" } }
          }
        }
      ]
    },
    "chart": {
      "oneOf": [
        { "type": "string", "minLength": 1 },
        {
          "type": "object",
          "additionalProperties": false,
          "anyOf": [{ "required": ["path"] }, { "required": ["localPath"] }, { "required": ["url", "name", "version"] }],
          "properties": {
            "path": { "type": "string", "minLength": 1 },
            "release": { "type": "string" },
            "values": { "type": "array", "items": { "type": "string", "minLength": 1 } },
            "name": { "type": "string" },
            "version": { "type": ["string", "number"] },
            "url": { "type": "string", "pattern": "^(https?|oci)://", "minLength": 1 },
            "repoName": { "type": "string" },
            "gitPath": { "type": "string" },
            "localPath": { "type": "string", "minLength": 1 },
            "namespace": { "type": "string" },
            "releaseName": { "type": "string" },
            "noWait": { "type": "boolean" },
            "valuesFiles": { "type": "array", "items": { "type": "string", "minLength": 1 } },
            "variables": { "type": "array", "items": { "$ref": "#/$defs/chartVariable" } },
            "schemaValidation": { "type": "boolean" },
            "serverSideApply": { "enum": ["auto", "true", "false"] }
          }
        }
      ]
    },
    "variable": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name"],
      "properties": {
        "name": { "type": "string", "pattern": "^[A-Z0-9_]+$" },
        "description": { "type": "string" },
        "default": { "type": ["string", "number", "boolean", "null"] },
        "prompt": { "type": "boolean" },
        "sensitive": { "type": "boolean" },
        "autoIndent": { "type": "boolean" },
        "pattern": { "type": "string" },
        "type": { "enum": ["raw", "file"] }
      }
    },
    "chartVariable": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "path"],
      "properties": {
        "name": { "type": "string", "pattern": "^[A-Z0-9_]+$" },
        "path": { "type": "string", "pattern": "^[A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)*$" },
        "description": { "type": "string" }
      }
    },
    "actionShell": {
      "oneOf": [
        { "enum": ["sh", "bash", "powershell", "pwsh", "cmd"] },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "windows": { "enum": ["powershell", "pwsh", "cmd", "sh", "bash"] },
            "linux": { "enum": ["sh", "bash", "pwsh", "powershell"] },
            "darwin": { "enum": ["sh", "bash", "pwsh", "powershell"] }
          }
        }
      ]
    },
    "actionVariable": {
      "oneOf": [
        { "type": "string", "pattern": "^[A-Z0-9_]+$" },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["name"],
          "properties": {
            "name": { "type": "string", "pattern": "^[A-Z0-9_]+$" },
            "sensitive": { "type": "boolean" },
            "autoIndent": { "type": "boolean" },
            "pattern": { "type": "string" },
            "type": { "enum": ["raw", "file"] }
          }
        }
      ]
    },
    "actionWait": {
      "type": "object",
      "additionalProperties": false,
      "oneOf": [{ "required": ["cluster"] }, { "required": ["network"] }],
      "properties": {
        "cluster": {
          "type": "object",
          "additionalProperties": false,
          "required": ["kind", "name"],
          "properties": {
            "kind": { "type": "string", "minLength": 1 },
            "name": { "type": "string", "minLength": 1 },
            "namespace": { "type": "string" },
            "condition": { "type": "string" }
          }
        },
        "network": {
          "type": "object",
          "additionalProperties": false,
          "required": ["protocol", "address"],
          "properties": {
            "protocol": { "enum": ["tcp", "http", "https"] },
            "address": { "type": "string", "minLength": 1 },
            "code": { "type": "integer", "minimum": 100, "maximum": 599 }
          }
        }
      }
    },
    "actionDefaults": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mute": { "type": "boolean" },
        "maxTotalSeconds": { "type": "integer", "minimum": 0, "maximum": 86400 },
        "maxRetries": { "type": "integer", "minimum": 0, "maximum": 10 },
        "dir": { "type": "string" },
        "env": { "type": "array", "items": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*=" } },
        "shell": { "$ref": "#/$defs/actionShell" }
      }
    },
    "action": {
      "type": "object",
      "additionalProperties": false,
      "oneOf": [{ "required": ["cmd"] }, { "required": ["wait"] }],
      "properties": {
        "mute": { "type": "boolean" },
        "maxTotalSeconds": { "type": "integer", "minimum": 0, "maximum": 86400 },
        "maxRetries": { "type": "integer", "minimum": 0, "maximum": 10 },
        "dir": { "type": "string" },
        "env": { "type": "array", "items": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*=" } },
        "cmd": { "type": "string", "minLength": 1 },
        "shell": { "$ref": "#/$defs/actionShell" },
        "setVariable": { "type": "string", "pattern": "^[A-Z0-9_]+$" },
        "setVariables": { "type": "array", "items": { "$ref": "#/$defs/actionVariable" } },
        "description": { "type": "string" },
        "wait": { "$ref": "#/$defs/actionWait" }
      }
    },
    "actionSet": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "defaults": { "$ref": "#/$defs/actionDefaults" },
        "before": { "type": "array", "items": { "$ref": "#/$defs/action" } },
        "after": { "type": "array", "items": { "$ref": "#/$defs/action" } },
        "onSuccess": { "type": "array", "items": { "$ref": "#/$defs/action" } },
        "onFailure": { "type": "array", "items": { "$ref": "#/$defs/action" } }
      }
    },
    "actions": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "onCreate": { "$ref": "#/$defs/actionSet" },
        "onDeploy": { "$ref": "#/$defs/actionSet" },
        "onRemove": { "$ref": "#/$defs/actionSet" }
      }
    },
    "manifest": {
      "oneOf": [
        { "type": "string", "minLength": 1 },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["name", "files"],
          "properties": {
            "name": { "type": "string", "minLength": 1 },
            "namespace": { "type": "string" },
            "files": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
            "kustomizations": { "type": "array", "items": { "type": "string" } },
            "kustomizeAllowAnyDirectory": { "type": "boolean" },
            "enableKustomizePlugins": { "type": "boolean" },
            "noWait": { "type": "boolean" },
            "serverSideApply": { "enum": ["auto", "true", "false"] },
            "template": { "type": "boolean" }
          }
        }
      ]
    },
    "component": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name"],
      "properties": {
        "name": { "type": "string", "pattern": "^[a-z0-9](?:[-a-z0-9.]*[a-z0-9])?$" },
        "description": { "type": "string" },
        "default": { "type": "boolean" },
        "required": { "type": "boolean" },
        "charts": { "type": "array", "items": { "$ref": "#/$defs/chart" } },
        "manifests": { "type": "array", "items": { "$ref": "#/$defs/manifest" } },
        "only": { "type": "object" },
        "group": { "type": "string" },
        "import": { "type": "object" },
        "images": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1024,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/@-]*$"
          }
        },
        "imageArchives": { "type": "array" },
        "repos": { "type": "array" },
        "files": { "type": "array" },
        "dataInjections": { "type": "array" },
        "actions": { "$ref": "#/$defs/actions" },
        "scripts": { "type": "object" },
        "healthChecks": { "type": "array" }
      }
    },
    "deployment": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "version"],
      "properties": {
        "name": { "type": "string", "pattern": "^[a-z0-9](?:[-a-z0-9.]*[a-z0-9])?$" },
        "version": { "type": ["string", "number"] },
        "description": { "type": "string" },
        "namespace": { "type": "string" },
        "charts": { "type": "array", "items": { "$ref": "#/$defs/chart" } },
        "manifests": { "type": "array", "items": { "$ref": "#/$defs/manifest" } }
      }
    }
  }
}