Documentation
¶
Overview ¶
Package terramate provides Terramate execution capabilities for Day 2 operations. Terramate enables drift detection, change sets, and orchestrated deployments.
Index ¶
- func BinaryName() string
- func CreateRootConfig(projectName string) string
- func CreateStackConfig(path, name, description string) string
- func DefaultBinary() string
- func PackagedBinaryPath() (string, bool)
- type Change
- type DriftResult
- type Executor
- func (e *Executor) DetectDrift(ctx context.Context) (*DriftResult, error)
- func (e *Executor) Generate(ctx context.Context) (*Result, error)
- func (e *Executor) Init(ctx context.Context) (*Result, error)
- func (e *Executor) IsInstalled() bool
- func (e *Executor) List(ctx context.Context) ([]Stack, error)
- func (e *Executor) ListChanged(ctx context.Context) ([]Stack, error)
- func (e *Executor) ListRunOrder(ctx context.Context, tags string) ([]string, error)
- func (e *Executor) Output(ctx context.Context) (*Result, error)
- func (e *Executor) Refresh(ctx context.Context) (*Result, error)
- func (e *Executor) RunApply(ctx context.Context, autoApprove bool) (*Result, error)
- func (e *Executor) RunDestroy(ctx context.Context, autoApprove bool) (*Result, error)
- func (e *Executor) RunInit(ctx context.Context) (*Result, error)
- func (e *Executor) RunPlan(ctx context.Context) (*Result, error)
- func (e *Executor) RunStackTofu(ctx context.Context, tags string, args ...string) (*Result, error)
- func (e *Executor) Version(ctx context.Context) (string, error)
- type ExecutorOption
- func WithBinary(binary string) ExecutorOption
- func WithChangeDetection(enabled bool) ExecutorOption
- func WithEnv(values ...string) ExecutorOption
- func WithParallelism(p int) ExecutorOption
- func WithTimeout(timeout time.Duration) ExecutorOption
- func WithTofuBinary(binary string) ExecutorOption
- func WithWorkDir(dir string) ExecutorOption
- func WithoutInheritedEnv(names ...string) ExecutorOption
- type Result
- type Stack
- type StackDrift
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinaryName ¶
func BinaryName() string
BinaryName returns the Terramate executable name for the current platform.
func CreateRootConfig ¶
CreateRootConfig creates a root terramate.tm.hcl configuration
func CreateStackConfig ¶
CreateStackConfig creates a terramate.tm.hcl configuration file
func DefaultBinary ¶
func DefaultBinary() string
DefaultBinary resolves the Terramate binary used by regular execution. Missing release packaging resolves to an impossible path so host PATH cannot mask an incomplete StackKit package.
func PackagedBinaryPath ¶
PackagedBinaryPath returns the StackKit-packaged Terramate binary path. It intentionally does not fall back to PATH: advanced mode must prove the StackKit release package contains its own lifecycle toolchain.
Types ¶
type Change ¶
type Change struct {
ResourceType string `json:"resourceType"`
ResourceName string `json:"resourceName"`
Action string `json:"action"` // "create", "update", "delete", "no-op"
Details string `json:"details,omitempty"`
}
Change represents a detected change
type DriftResult ¶
type DriftResult struct {
HasDrift bool `json:"hasDrift"`
Stacks []StackDrift `json:"stacks"`
CheckedAt time.Time `json:"checkedAt"`
Duration time.Duration `json:"duration"`
}
DriftResult represents the result of drift detection
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor handles Terramate command execution
func NewExecutor ¶
func NewExecutor(opts ...ExecutorOption) *Executor
NewExecutor creates a new Terramate executor
func (*Executor) DetectDrift ¶
func (e *Executor) DetectDrift(ctx context.Context) (*DriftResult, error)
DetectDrift runs drift detection across all stacks
func (*Executor) IsInstalled ¶
IsInstalled checks if Terramate is installed
func (*Executor) ListChanged ¶
ListChanged lists stacks with changes (for change detection)
func (*Executor) ListRunOrder ¶ added in v0.46.5
ListRunOrder returns the stack directories, relative to the project root, that match tags in the order `terramate run` would execute them. It never consults Git change detection.
func (*Executor) RunDestroy ¶
RunDestroy runs tofu destroy on all stacks
func (*Executor) RunStackTofu ¶ added in v0.46.5
RunStackTofu runs `terramate run --no-recursive` in the working directory, which must be one stack directory, so exactly that stack runs the packaged OpenTofu binary with args. Terramate reports every failing command with exit code 1; the returned Result carries the exit code of the OpenTofu process itself (for example 2 from `plan -detailed-exitcode`). An error is returned only when Terramate failed without a command exit status.
type ExecutorOption ¶
type ExecutorOption func(*Executor)
ExecutorOption configures the Executor
func WithBinary ¶
func WithBinary(binary string) ExecutorOption
WithBinary sets the terramate binary path
func WithChangeDetection ¶
func WithChangeDetection(enabled bool) ExecutorOption
WithChangeDetection enables Git-based change detection
func WithEnv ¶ added in v0.46.5
func WithEnv(values ...string) ExecutorOption
WithEnv appends environment values for Terramate and the commands it runs. Later values win over inherited ones.
func WithParallelism ¶
func WithParallelism(p int) ExecutorOption
WithParallelism sets the parallelism level
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ExecutorOption
WithTimeout sets the execution timeout
func WithTofuBinary ¶
func WithTofuBinary(binary string) ExecutorOption
WithTofuBinary sets the OpenTofu binary for terramate run
func WithWorkDir ¶
func WithWorkDir(dir string) ExecutorOption
WithWorkDir sets the working directory
func WithoutInheritedEnv ¶ added in v0.46.5
func WithoutInheritedEnv(names ...string) ExecutorOption
WithoutInheritedEnv drops the named variables from the inherited process environment before WithEnv values are appended, so no host OpenTofu CLI override reaches a stack run.
type Result ¶
type Result struct {
Success bool `json:"success"`
ExitCode int `json:"exitCode"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
Duration time.Duration `json:"duration"`
}
Result represents the result of a terramate command