core

package
v0.6.0-6a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package core hosts the built-in actions, functions, state backend, and encrypters that ship with every compiled factory binary.

Built-in actions:

  • core.command - exec a process, capture stdout/stderr/exit
  • core.http - HTTP request, return body/status
  • core.wait-for - poll a predicate until true or timeout
  • core.script - multi-line script (uses triple-quoted multilines)

Built-in functions: core.format, core.b64-encode, core.b64-decode, core.range, and core.length. State backend core.local writes snapshots to the local filesystem; the core.env-key and core.noop encrypters cover encrypted and plaintext state.

Actions implement the standard action interface: triggered (hash-based re-run), with @lock cross-DAG serialization, @timeout, and @sensitive redaction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Library

func Library() *runtime.Library

Library returns the registration record for the builtin `core` library. Stacks reach its actions as `actions: { core: { command: { ... } } }` and its functions as `core.format(...)`.

Types

type CommandAction

type CommandAction struct {
	Argv        []string
	Environment map[string]string
	WorkingDir  string
}

CommandAction execs a single process and captures its output.

func (CommandAction) Defaults

func (a CommandAction) Defaults() []defaults.Default

Defaults declares the inputs a body may leave out: an absent environment adds nothing to the parent's, and an absent working-dir inherits the process directory.

func (*CommandAction) Run

Run execs argv[0] with argv[1:] as arguments. Environment is merged with the parent, with user-supplied variables taking precedence.

type CommandActionOutput

type CommandActionOutput struct {
	Stdout   string
	Stderr   string
	ExitCode int
	Duration time.Duration
}

CommandActionOutput carries the captured output of a command run. Run returns an error when the process fails to start or the context is canceled.

type HTTPAction

type HTTPAction struct {
	URL     string
	Method  string
	Headers map[string]string
	Body    string
	Timeout time.Duration
}

HTTPAction issues an HTTP request and captures the response.

func (HTTPAction) Defaults

func (a HTTPAction) Defaults() []defaults.Default

Defaults declares the inputs a body may leave out: the method defaults to GET; absent headers and body send nothing extra, and an absent timeout leaves the round trip unbounded.

func (*HTTPAction) Run

func (a *HTTPAction) Run(ctx context.Context, _ any) (*HTTPActionOutput, error)

Run issues the request. Method defaults to GET. Timeout applies to the whole round trip including reading the response body.

type HTTPActionOutput

type HTTPActionOutput struct {
	Status     int
	StatusText string
	Headers    map[string][]string
	Body       string
	Duration   time.Duration
}

HTTPActionOutput is the captured response. The action returns an error only when the request can't be built or the transport fails, not on HTTP error status codes. HTTP status codes are returned as data in Status.

type ScriptAction

type ScriptAction struct {
	Script      string
	Shell       string
	Environment map[string]string
	WorkingDir  string
}

ScriptAction runs a shell script via `<shell> -c <script>`. Shell defaults to `sh`; set it to `bash`, `python3`, or any other interpreter that accepts `-c`.

func (ScriptAction) Defaults

func (a ScriptAction) Defaults() []defaults.Default

Defaults declares the inputs a body may leave out: the shell defaults to sh, an absent environment adds nothing to the parent's, and an absent working-dir inherits the process directory.

func (*ScriptAction) Run

Run invokes the configured shell with the script. Output mirrors what CommandAction returns.

type ScriptActionOutput

type ScriptActionOutput = CommandActionOutput

ScriptActionOutput is the captured output of a script run. It is the same shape as the command action's output because both reduce to a process exec; the alias keeps the convention that every action type has a sibling type named `<GoName>Output`.

type WaitForAction

type WaitForAction struct {
	Argv        []string
	Interval    time.Duration
	Timeout     time.Duration
	Environment map[string]string
	WorkingDir  string
}

WaitForAction polls a command until it exits 0 or the deadline is reached. The command runs at most once per Interval (default 1s) and the whole poll loop runs for at most Timeout (default 5m).

func (WaitForAction) Defaults

func (a WaitForAction) Defaults() []defaults.Default

Defaults declares the inputs a body may leave out: one attempt per second for up to five minutes, an absent environment adding nothing to the parent's, and an absent working-dir inheriting the process directory.

func (*WaitForAction) Run

Run polls until the command exits 0, the timeout fires, or the context is cancelled. A nonzero exit triggers another attempt, and an error is returned if the process fails to start.

type WaitForActionOutput

type WaitForActionOutput struct {
	Attempts int
	Duration time.Duration
	Stdout   string
	Stderr   string
}

WaitForActionOutput records how many attempts ran, the elapsed time, and the stdout/stderr of the successful attempt.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL