runner

package
v1.204.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownTaskType is returned when a task has an unknown type.
	ErrUnknownTaskType = errors.New("unknown task type")
)

Sentinel errors for task execution.

Functions

func Run

func Run(ctx context.Context, task *Task, runner CommandRunner, opts Options) error

Run executes a single task with the given options. It handles timeout enforcement via context and delegates to the appropriate executor method based on task type.

func RunAll

func RunAll(ctx context.Context, tasks Tasks, runner CommandRunner, opts Options) error

RunAll executes multiple tasks sequentially. It stops at the first error and returns it.

Types

type AtmosExecParams

type AtmosExecParams struct {
	// AtmosConfig is the atmos configuration.
	AtmosConfig *schema.AtmosConfiguration
	// Args are command arguments (e.g., ["terraform", "plan", "vpc"]).
	Args []string
	// Dir is the working directory for the command.
	Dir string
	// Env are environment variables for the command.
	Env []string
	// DryRun if true, don't actually execute the command.
	DryRun bool
}

AtmosExecParams holds parameters for executing an atmos command.

type CommandRunner

type CommandRunner interface {
	// RunShell executes a shell command with the given parameters.
	// Parameters:
	//   - ctx: Context for cancellation and timeout
	//   - command: The shell command to execute
	//   - name: A name for the command (for logging/identification)
	//   - dir: Working directory for the command
	//   - env: Environment variables for the command
	//   - dryRun: If true, don't actually execute the command
	// Returns an error if the command fails.
	RunShell(ctx context.Context, command, name, dir string, env []string, dryRun bool) error

	// RunAtmos executes an atmos command with the given parameters.
	// Returns an error if the command fails.
	RunAtmos(ctx context.Context, params *AtmosExecParams) error
}

CommandRunner abstracts the execution of shell and atmos commands. This interface enables testing task execution without spawning real processes. It is designed to be compatible with pkg/workflow.CommandRunner.

type Options

type Options struct {
	// DryRun if true, commands are not actually executed.
	DryRun bool
	// Env are additional environment variables for the command.
	Env []string
	// Dir is the default working directory. Overridden by Task.WorkingDirectory.
	Dir string
	// AtmosConfig is the atmos configuration.
	AtmosConfig *schema.AtmosConfiguration
	// Stack overrides the task's stack setting (for command-line override).
	Stack string
}

Options configures task execution.

type Task

type Task = schema.Task

Task is an alias for schema.Task. It represents a unit of work that the runner executes.

type Tasks

type Tasks = schema.Tasks

Tasks is an alias for schema.Tasks. It supports flexible YAML parsing - both strings and structs.

Jump to

Keyboard shortcuts

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