Help us shape the future of Go! Take the 2026 Go Developer Survey

iac

package
v0.53.17 Latest Latest
Warning

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

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

Documentation

Overview

Package iac provides a unified interface for IaC execution. It supports both Day 1 operations (OpenTofu only) and Day 1+2 operations (Terramate).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	WorkDir     string
	Mode        ExecutionMode
	Timeout     time.Duration
	Parallelism int
	AutoApprove bool
}

Config holds configuration for the executor

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

type DriftResult

type DriftResult struct {
	HasDrift  bool
	Resources []DriftedResource
	CheckedAt time.Time
	Duration  time.Duration
}

DriftResult represents the result of drift detection

type DriftedResource

type DriftedResource struct {
	Type    string
	Name    string
	Address string
	Action  string
	Details string
}

DriftedResource represents a resource with drift

type ExecResult

type ExecResult struct {
	Success  bool
	Stdout   string
	Stderr   string
	ExitCode int
	Duration time.Duration
}

ExecResult represents the result of an IaC command execution.

type ExecutionMode

type ExecutionMode string

ExecutionMode represents the IaC execution mode

const (
	// ModeOpenTofu uses OpenTofu directly (Day 1 only)
	ModeOpenTofu ExecutionMode = "opentofu"
	// ModeTerramate uses Terramate for orchestration (Day 1 + Day 2)
	ModeTerramate ExecutionMode = "terramate"
)

type Executor

type Executor interface {
	// Core operations
	Init(ctx context.Context) error
	Plan(ctx context.Context, outFile string, destroy bool) (*PlanResult, error)
	Apply(ctx context.Context, autoApprove bool, planFile string) (*ExecResult, error)
	Destroy(ctx context.Context, autoApprove bool) (*ExecResult, error)
	Validate(ctx context.Context) (*ExecResult, error)
	Output(ctx context.Context) (string, error)

	// Day 2 operations (may not be supported in all modes)
	DetectDrift(ctx context.Context) (*DriftResult, error)
	Refresh(ctx context.Context) error

	// Metadata
	Mode() ExecutionMode
	IsInstalled() bool
	Version(ctx context.Context) (string, error)
}

Executor provides a unified interface for IaC operations

func NewExecutor

func NewExecutor(cfg *Config) (Executor, error)

NewExecutor creates a new IaC executor based on the mode

func NewExecutorFromSpec

func NewExecutorFromSpec(spec *models.StackSpec, workDir string) (Executor, error)

NewExecutorFromSpec creates an executor based on the stack spec

type OpenTofuExecutor

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

OpenTofuExecutor implements Executor using OpenTofu directly

func (*OpenTofuExecutor) Apply

func (e *OpenTofuExecutor) Apply(ctx context.Context, autoApprove bool, planFile string) (*ExecResult, error)

func (*OpenTofuExecutor) Destroy

func (e *OpenTofuExecutor) Destroy(ctx context.Context, autoApprove bool) (*ExecResult, error)

func (*OpenTofuExecutor) DetectDrift

func (e *OpenTofuExecutor) DetectDrift(ctx context.Context) (*DriftResult, error)

func (*OpenTofuExecutor) Init

func (e *OpenTofuExecutor) Init(ctx context.Context) error

func (*OpenTofuExecutor) IsInstalled

func (e *OpenTofuExecutor) IsInstalled() bool

func (*OpenTofuExecutor) Mode

func (e *OpenTofuExecutor) Mode() ExecutionMode

func (*OpenTofuExecutor) Output

func (e *OpenTofuExecutor) Output(ctx context.Context) (string, error)

func (*OpenTofuExecutor) Plan

func (e *OpenTofuExecutor) Plan(ctx context.Context, outFile string, destroy bool) (*PlanResult, error)

func (*OpenTofuExecutor) Refresh

func (e *OpenTofuExecutor) Refresh(ctx context.Context) error

func (*OpenTofuExecutor) Validate

func (e *OpenTofuExecutor) Validate(ctx context.Context) (*ExecResult, error)

func (*OpenTofuExecutor) Version

func (e *OpenTofuExecutor) Version(ctx context.Context) (string, error)

type PlanResult

type PlanResult struct {
	HasChanges bool
	Add        int
	Change     int
	Destroy    int
	Output     string
	Duration   time.Duration
}

PlanResult represents the result of a plan operation

type TerramateExecutor

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

TerramateExecutor implements Executor using Terramate

func (*TerramateExecutor) Apply

func (e *TerramateExecutor) Apply(ctx context.Context, autoApprove bool, planFile string) (*ExecResult, error)

func (*TerramateExecutor) Destroy

func (e *TerramateExecutor) Destroy(ctx context.Context, autoApprove bool) (*ExecResult, error)

func (*TerramateExecutor) DetectDrift

func (e *TerramateExecutor) DetectDrift(ctx context.Context) (*DriftResult, error)

func (*TerramateExecutor) Init

func (e *TerramateExecutor) Init(ctx context.Context) error

func (*TerramateExecutor) IsInstalled

func (e *TerramateExecutor) IsInstalled() bool

func (*TerramateExecutor) Mode

func (e *TerramateExecutor) Mode() ExecutionMode

func (*TerramateExecutor) Output

func (e *TerramateExecutor) Output(ctx context.Context) (string, error)

func (*TerramateExecutor) Plan

func (e *TerramateExecutor) Plan(ctx context.Context, outFile string, destroy bool) (*PlanResult, error)

func (*TerramateExecutor) Refresh

func (e *TerramateExecutor) Refresh(ctx context.Context) error

func (*TerramateExecutor) Validate

func (e *TerramateExecutor) Validate(ctx context.Context) (*ExecResult, error)

func (*TerramateExecutor) Version

func (e *TerramateExecutor) Version(ctx context.Context) (string, error)

Jump to

Keyboard shortcuts

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