apply

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecutionResult

type ExecutionResult struct {
	Prepare  StageResult
	Apply    StageResult
	Rollback StageResult
	Err      error
}

type FailurePolicy

type FailurePolicy int

FailurePolicy controls how the runner behaves when a step fails.

const (
	// StopOnError stops execution at the first failed step (default).
	StopOnError FailurePolicy = iota
	// ContinueOnError continues executing remaining steps, collecting all errors.
	ContinueOnError
)

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

func NewOrchestrator

func NewOrchestrator(policy RollbackPolicy, opts ...OrchestratorOption) *Orchestrator

func (*Orchestrator) Execute

func (o *Orchestrator) Execute(plan StagePlan) ExecutionResult

type OrchestratorOption

type OrchestratorOption func(*Orchestrator)

OrchestratorOption configures the orchestrator.

func WithFailurePolicy

func WithFailurePolicy(policy FailurePolicy) OrchestratorOption

WithFailurePolicy sets the failure policy for the apply stage runner.

func WithProgressFunc

func WithProgressFunc(fn ProgressFunc) OrchestratorOption

WithProgressFunc sets a callback that receives progress events during execution.

type ProgressEvent

type ProgressEvent struct {
	StepID string
	Stage  Stage
	Status StepStatus
	Err    error
}

ProgressEvent is emitted by the runner as each step starts and completes.

type ProgressFunc

type ProgressFunc func(ProgressEvent)

ProgressFunc is a callback invoked for every step lifecycle event.

type RollbackPolicy

type RollbackPolicy struct {
	OnApplyFailure bool
}

func DefaultRollbackPolicy

func DefaultRollbackPolicy() RollbackPolicy

func (RollbackPolicy) ShouldRollback

func (p RollbackPolicy) ShouldRollback(stage Stage, err error) bool

type RollbackStep

type RollbackStep interface {
	Step
	Rollback() error
}

type Runner

type Runner struct {
	FailurePolicy FailurePolicy
	OnProgress    ProgressFunc
}

Runner executes a list of steps for a given stage.

func (Runner) Run

func (r Runner) Run(stage Stage, steps []Step) StageResult

type Stage

type Stage string
const (
	StagePrepare  Stage = "prepare"
	StageApply    Stage = "apply"
	StageRollback Stage = "rollback"
)

type StagePlan

type StagePlan struct {
	Prepare []Step
	Apply   []Step
}

type StageResult

type StageResult struct {
	Stage   Stage
	Steps   []StepResult
	Success bool
	Err     error
}

func ExecuteRollback

func ExecuteRollback(steps []StepResult, stepIndex map[string]Step) StageResult

type Step

type Step interface {
	ID() string
	Run() error
}

type StepResult

type StepResult struct {
	StepID     string
	Status     StepStatus
	StartedAt  time.Time
	FinishedAt time.Time
	Err        error
}

type StepStatus

type StepStatus string
const (
	StepStatusPending    StepStatus = "pending"
	StepStatusRunning    StepStatus = "running"
	StepStatusSucceeded  StepStatus = "succeeded"
	StepStatusFailed     StepStatus = "failed"
	StepStatusRolledBack StepStatus = "rolled-back"
	StepStatusSkipped    StepStatus = "skipped"
)

Jump to

Keyboard shortcuts

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