Documentation
¶
Overview ¶
Package v0 is the v0 (alpha) schema for maru2,
Breaking changes are to be expected without any migration pathway.
Index ¶
Constants ¶
const SchemaVersion = "v0"
SchemaVersion is the current schema version for workflows
Variables ¶
var EnvVariablePattern = regexp.MustCompile("^[a-zA-Z_]+[a-zA-Z0-9_]*$")
EnvVariablePattern is a regular expression for valid environment variable names
var InputNamePattern = TaskNamePattern // regexp.MustCompile("^\\$[A-Z_]+[A-Z0-9_]*$")
InputNamePattern is a regular expression for valid input names
var TaskNamePattern = regexp.MustCompile("^[_a-zA-Z][a-zA-Z0-9_-]*$")
TaskNamePattern is a regular expression for valid task names, it is also used for step IDs
Functions ¶
func SupportedSchemes ¶
func SupportedSchemes() []string
SupportedSchemes returns a list of supported schemes
func WorkFlowSchema ¶
func WorkFlowSchema() *jsonschema.Schema
WorkFlowSchema returns a JSON schema for a maru2 workflow
Types ¶
type Alias ¶
type Alias struct {
Type string `json:"type"`
Base string `json:"base,omitempty"`
TokenFromEnv string `json:"token-from-env,omitempty"`
}
Alias defines how an alias should be resolved
func (Alias) JSONSchemaExtend ¶
func (Alias) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend extends the JSON schema for an alias
type AliasMap ¶
AliasMap is a map of aliases
func (AliasMap) JSONSchemaExtend ¶
func (AliasMap) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend extends the JSON schema for an alias map
type InputMap ¶
type InputMap map[string]InputParameter
InputMap is a map of input parameters for a workflow
func (InputMap) JSONSchemaExtend ¶
func (InputMap) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend extends the JSON schema for an input map
type InputParameter ¶
type InputParameter struct {
// Description of the input parameter
Description string `json:"description"`
// Message to display when the parameter is deprecated
DeprecatedMessage string `json:"deprecated-message,omitempty"`
// Whether the parameter is required, defaults to true
Required *bool `json:"required,omitempty"`
// Default value for the parameter, can be a string or a primitive type
Default any `json:"default,omitempty"`
// Environment variable to use as default value for the parameter
DefaultFromEnv string `json:"default-from-env,omitempty"`
// Regular expression to validate the value of the parameter
Validate string `json:"validate,omitempty"`
}
InputParameter represents a single input parameter for a workflow, to be used w/ `with`
func (InputParameter) JSONSchemaExtend ¶
func (InputParameter) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend extends the JSON schema for a step
type Step ¶
type Step struct {
// Run is the command/script to run
Run string `json:"run,omitempty"`
// Env is a map of environment variables
Env schema.Env `json:"env,omitempty"`
// Uses is a reference to another task
Uses string `json:"uses,omitempty"`
// With is a map of additional parameters for the step/task call
With schema.With `json:"with,omitempty"`
// ID is a unique identifier for the step
ID string `json:"id,omitempty"`
// Name is a human-readable name for the step, pure sugar
Name string `json:"name,omitempty"`
// If controls whether the step is executed
If string `json:"if,omitempty"`
// Dir is the directory to run the step in
Dir string `json:"dir,omitempty"`
// Set the shell to execute run with (default: sh)
Shell string `json:"shell,omitempty"`
// Set how long to run the command before timing out
Timeout string `json:"timeout,omitempty"`
// Mute controls whether the rendered script, STDOUT and STDERR are printed
//
// it is similar to set +x and 2>&1 >/dev/null
Mute bool `json:"mute,omitempty"`
}
Step is a single step in a task
While a step can have any combination of `run`, and `uses` fields, only one of them should be set at a time.
This is enforced by JSON schema validation.
func (Step) JSONSchemaExtend ¶
func (Step) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend extends the JSON schema for a step
type Task ¶
type Task []Step
Task is a list of steps
func (Task) JSONSchemaExtend ¶
func (Task) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend extends the JSON schema for a task
type TaskMap ¶
TaskMap is a map of tasks, where the key is the task name
func (TaskMap) JSONSchemaExtend ¶
func (TaskMap) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend extends the JSON schema for a task map
func (TaskMap) OrderedTaskNames ¶
OrderedTaskNames returns a list of task names in alphabetical order
The default task is always first
type Workflow ¶
type Workflow struct {
SchemaVersion string `json:"schema-version"`
Inputs InputMap `json:"inputs,omitempty"`
Tasks TaskMap `json:"tasks,omitempty"`
Aliases AliasMap `json:"aliases,omitempty"`
}
Workflow is a wrapper struct around the input map and task map
It represents a "tasks.yaml" file
func ReadAndValidate ¶
ReadAndValidate reads and validates a workflow
func (Workflow) JSONSchemaExtend ¶
func (Workflow) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend extends the JSON schema for a workflow