Skip to content

Add maru-runner JSON schema #4803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/api/json/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -3573,6 +3573,12 @@
"fileMatch": [".map.yml", ".map.yaml", ".map.json"],
"url": "https://json.schemastore.org/mapehr.json"
},
{
"name": "Maru Runner",
"description": "The Unicorn Task Runner",
"fileMatch": ["tasks.yaml"],
"url": "https://www.schemastore.org/maru-runner.json"
},
{
"name": "A micro editor config",
"description": "A micro editor config",
Expand Down
3 changes: 2 additions & 1 deletion src/schema-validation.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@
"openweather.current.json",
"openweather.roadrisk.json",
"specif-1.1.json",
"ctfd.json"
"ctfd.json",
"maru-runner.json"
],
"missingCatalogUrl": [
// Below this line are subschemas that are included from other schema
Expand Down
319 changes: 319 additions & 0 deletions src/schemas/json/maru-runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/defenseunicorns/maru-runner/src/types/tasks-file",
"$ref": "#/$defs/TasksFile",
"$defs": {
"Action": {
"properties": {
"description": {
"type": "string",
"description": "Description of the action to be displayed during package execution instead of the command"
},
"cmd": {
"type": "string",
"description": "The command to run. Must specify either cmd or wait for the action to do anything."
},
"wait": {
"$ref": "#/$defs/ActionWait",
"description": "Wait for a condition to be met before continuing. Must specify either cmd or wait for the action."
},
"env": {
"items": {
"type": "string"
},
"type": "array",
"description": "Additional environment variables to set for the command"
},
"mute": {
"type": "boolean",
"description": "Hide the output of the command during package deployment (default false)"
},
"maxTotalSeconds": {
"type": "integer",
"description": "Timeout in seconds for the command (default to 0"
},
"maxRetries": {
"type": "integer",
"description": "Retry the command if it fails up to given number of times (default 0)"
},
"dir": {
"type": "string",
"description": "The working directory to run the command in (default is CWD)"
},
"shell": {
"$ref": "#/$defs/ShellPreference",
"description": "(cmd only) Indicates a preference for a shell for the provided cmd to be executed in on supported operating systems"
},
"setVariables": {
"items": {
"$ref": "#/$defs/Variable"
},
"type": "array",
"description": "(onDeploy/cmd only) An array of variables to update with the output of the command. These variables will be available to all remaining actions and components in the package."
},
"task": {
"type": "string",
"description": "The task to run"
},
"with": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"description": "Input parameters to pass to the task"
},
"if": {
"type": "string",
"description": "Conditional to determine if the action should run"
}
},
"additionalProperties": false,
"type": "object",
"patternProperties": {
"^x-": {}
}
},
"ActionWait": {
"properties": {
"cluster": {
"$ref": "#/$defs/ActionWaitCluster",
"description": "Wait for a condition to be met in the cluster before continuing. Only one of cluster or network can be specified."
},
"network": {
"$ref": "#/$defs/ActionWaitNetwork",
"description": "Wait for a condition to be met on the network before continuing. Only one of cluster or network can be specified."
}
},
"additionalProperties": false,
"type": "object",
"patternProperties": {
"^x-": {}
}
},
"ActionWaitCluster": {
"properties": {
"kind": {
"type": "string",
"description": "The kind of resource to wait for",
"examples": ["Pod", "Deployment)"]
},
"name": {
"type": "string",
"description": "The name of the resource or selector to wait for",
"examples": ["podinfo", "app=podinfo"]
},
"namespace": {
"type": "string",
"description": "The namespace of the resource to wait for"
},
"condition": {
"type": "string",
"description": "The condition or jsonpath state to wait for; defaults to exist",
"examples": ["Ready", "Available"]
}
},
"additionalProperties": false,
"type": "object",
"required": ["kind", "name"],
"patternProperties": {
"^x-": {}
}
},
"ActionWaitNetwork": {
"properties": {
"protocol": {
"type": "string",
"enum": ["tcp", "http", "https"],
"description": "The protocol to wait for"
},
"address": {
"type": "string",
"description": "The address to wait for",
"examples": ["localhost:8080", "1.1.1.1"]
},
"code": {
"type": "integer",
"description": "The HTTP status code to wait for if using http or https",
"examples": [200, 404]
}
},
"additionalProperties": false,
"type": "object",
"required": ["protocol", "address"],
"patternProperties": {
"^x-": {}
}
},
"InputParameter": {
"properties": {
"description": {
"type": "string",
"description": "Description of the parameter"
},
"deprecatedMessage": {
"type": "string",
"description": "Message to display when the parameter is deprecated"
},
"required": {
"type": "boolean",
"description": "Whether the parameter is required",
"default": true
},
"default": {
"type": "string",
"description": "Default value for the parameter"
}
},
"additionalProperties": false,
"type": "object",
"required": ["description"],
"patternProperties": {
"^x-": {}
}
},
"InteractiveVariable": {
"properties": {
"name": {
"type": "string",
"pattern": "^[A-Z0-9_]+$",
"description": "The name to be used for the variable"
},
"pattern": {
"type": "string",
"description": "An optional regex pattern that a variable value must match before a package deployment can continue."
},
"description": {
"type": "string",
"description": "A description of the variable to be used when prompting the user a value"
},
"default": {
"type": "string",
"description": "The default value to use for the variable"
},
"prompt": {
"type": "boolean",
"description": "Whether to prompt the user for input for this variable"
}
},
"additionalProperties": false,
"type": "object",
"required": ["name"],
"patternProperties": {
"^x-": {}
}
},
"ShellPreference": {
"properties": {
"windows": {
"type": "string",
"description": "(default 'powershell') Indicates a preference for the shell to use on Windows systems (note that choosing 'cmd' will turn off migrations like touch -> New-Item)",
"examples": ["powershell", "cmd", "pwsh", "sh", "bash", "gsh"]
},
"linux": {
"type": "string",
"description": "(default 'sh') Indicates a preference for the shell to use on Linux systems",
"examples": ["sh", "bash", "fish", "zsh", "pwsh"]
},
"darwin": {
"type": "string",
"description": "(default 'sh') Indicates a preference for the shell to use on macOS systems",
"examples": ["sh", "bash", "fish", "zsh", "pwsh"]
}
},
"additionalProperties": false,
"type": "object",
"patternProperties": {
"^x-": {}
}
},
"Task": {
"properties": {
"name": {
"type": "string",
"description": "Name of the task"
},
"description": {
"type": "string",
"description": "Description of the task"
},
"actions": {
"items": {
"$ref": "#/$defs/Action"
},
"type": "array",
"description": "Actions to take when running the task"
},
"inputs": {
"additionalProperties": {
"$ref": "#/$defs/InputParameter"
},
"type": "object",
"description": "Input parameters for the task"
},
"envPath": {
"type": "string",
"description": "Path to file containing environment variables"
}
},
"additionalProperties": false,
"type": "object",
"required": ["name"],
"patternProperties": {
"^x-": {}
}
},
"TasksFile": {
"properties": {
"includes": {
"items": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"type": "array",
"description": "List of local task files to include"
},
"variables": {
"items": {
"$ref": "#/$defs/InteractiveVariable"
},
"type": "array",
"description": "Definitions and default values for variables used in run.yaml"
},
"tasks": {
"items": {
"$ref": "#/$defs/Task"
},
"type": "array",
"description": "The list of tasks that can be run"
}
},
"additionalProperties": false,
"type": "object",
"required": ["tasks"],
"patternProperties": {
"^x-": {}
}
},
"Variable": {
"properties": {
"name": {
"type": "string",
"pattern": "^[A-Z0-9_]+$",
"description": "The name to be used for the variable"
},
"pattern": {
"type": "string",
"description": "An optional regex pattern that a variable value must match before a package deployment can continue."
}
},
"additionalProperties": false,
"type": "object",
"required": ["name"],
"patternProperties": {
"^x-": {}
}
}
}
}
Loading