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 ¶
- type Config
- type DriftResult
- type DriftedResource
- type ExecResult
- type ExecutionMode
- type Executor
- type OpenTofuExecutor
- func (e *OpenTofuExecutor) Apply(ctx context.Context, autoApprove bool, planFile string) (*ExecResult, error)
- func (e *OpenTofuExecutor) Destroy(ctx context.Context, autoApprove bool) (*ExecResult, error)
- func (e *OpenTofuExecutor) DetectDrift(ctx context.Context) (*DriftResult, error)
- func (e *OpenTofuExecutor) Init(ctx context.Context) error
- func (e *OpenTofuExecutor) IsInstalled() bool
- func (e *OpenTofuExecutor) Mode() ExecutionMode
- func (e *OpenTofuExecutor) Output(ctx context.Context) (string, error)
- func (e *OpenTofuExecutor) Plan(ctx context.Context, outFile string, destroy bool) (*PlanResult, error)
- func (e *OpenTofuExecutor) Refresh(ctx context.Context) error
- func (e *OpenTofuExecutor) Validate(ctx context.Context) (*ExecResult, error)
- func (e *OpenTofuExecutor) Version(ctx context.Context) (string, error)
- type PlanResult
- type TerramateExecutor
- func (e *TerramateExecutor) Apply(ctx context.Context, autoApprove bool, planFile string) (*ExecResult, error)
- func (e *TerramateExecutor) Destroy(ctx context.Context, autoApprove bool) (*ExecResult, error)
- func (e *TerramateExecutor) DetectDrift(ctx context.Context) (*DriftResult, error)
- func (e *TerramateExecutor) Init(ctx context.Context) error
- func (e *TerramateExecutor) IsInstalled() bool
- func (e *TerramateExecutor) Mode() ExecutionMode
- func (e *TerramateExecutor) Output(ctx context.Context) (string, error)
- func (e *TerramateExecutor) Plan(ctx context.Context, outFile string, destroy bool) (*PlanResult, error)
- func (e *TerramateExecutor) Refresh(ctx context.Context) error
- func (e *TerramateExecutor) Validate(ctx context.Context) (*ExecResult, error)
- func (e *TerramateExecutor) Version(ctx context.Context) (string, error)
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
type DriftResult ¶
type DriftResult struct {
HasDrift bool
Resources []DriftedResource
CheckedAt time.Time
Duration time.Duration
}
DriftResult represents the result of drift detection
type DriftedResource ¶
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 ¶
NewExecutor creates a new IaC executor based on the mode
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) 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) Validate ¶
func (e *OpenTofuExecutor) Validate(ctx context.Context) (*ExecResult, 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) 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) Validate ¶
func (e *TerramateExecutor) Validate(ctx context.Context) (*ExecResult, error)