Documentation
¶
Overview ¶
Package terraform provides the CI provider implementation for Terraform.
Package terraform provides the CI provider implementation for Terraform.
Package terraform provides the CI Plugin implementation for Terraform.
Index ¶
- func ExtractErrors(stdout string) []string
- func ExtractWarnings(stdout string) []string
- func ParseApplyOutput(output string) *plugin.OutputResult
- func ParseOutput(output string, command string) *plugin.OutputResult
- func ParseOutputJSON(jsonData []byte) (map[string]plugin.TerraformOutput, error)
- func ParsePlanJSON(jsonData []byte) (*plugin.OutputResult, error)
- func ParsePlanOutput(output string) *plugin.OutputResult
- type OutputJSON
- type OutputValue
- type Plugin
- func (p *Plugin) BuildTemplateContext(info *schema.ConfigAndStacksInfo, ciCtx *provider.Context, output string, ...) (any, error)
- func (p *Plugin) GetArtifactKey(info *schema.ConfigAndStacksInfo, command string) string
- func (p *Plugin) GetDefaultTemplates() embed.FS
- func (p *Plugin) GetHookBindings() []plugin.HookBinding
- func (p *Plugin) GetOutputVariables(result *plugin.OutputResult, command string) map[string]string
- func (p *Plugin) GetType() string
- func (p *Plugin) ParseOutput(output string, command string) (*plugin.OutputResult, error)
- func (p *Plugin) ResolveComponentPlanfilePath(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo) (string, error)
- type TerraformTemplateContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractErrors ¶
ExtractErrors extracts error messages from terraform stdout. This is used when JSON parsing is not available or for runtime errors.
func ExtractWarnings ¶
ExtractWarnings extracts warning messages from terraform stdout.
func ParseApplyOutput ¶
func ParseApplyOutput(output string) *plugin.OutputResult
ParseApplyOutput parses terraform apply stdout.
func ParseOutput ¶
func ParseOutput(output string, command string) *plugin.OutputResult
ParseOutput parses terraform output for a given command (fallback when JSON not available). Prefer ParsePlanJSON + ParseOutputJSON for structured data.
func ParseOutputJSON ¶
func ParseOutputJSON(jsonData []byte) (map[string]plugin.TerraformOutput, error)
ParseOutputJSON parses terraform output JSON from `terraform output -json`. Returns a map of output name to TerraformOutput.
func ParsePlanJSON ¶
func ParsePlanJSON(jsonData []byte) (*plugin.OutputResult, error)
ParsePlanJSON parses terraform plan JSON from `terraform show -json <planfile>`. This is the preferred method for parsing plan data as it provides structured data.
func ParsePlanOutput ¶
func ParsePlanOutput(output string) *plugin.OutputResult
ParsePlanOutput parses terraform plan stdout (fallback when JSON not available). Prefer ParsePlanJSON when a planfile is available.
Types ¶
type OutputJSON ¶
type OutputJSON map[string]OutputValue
OutputJSON represents the structure of `terraform output -json`.
type OutputValue ¶
type OutputValue struct {
Sensitive bool `json:"sensitive"`
Type any `json:"type"`
Value any `json:"value"`
}
OutputValue represents a single output value from `terraform output -json`.
type Plugin ¶
type Plugin struct{}
Plugin implements plugin.Plugin for Terraform.
func (*Plugin) BuildTemplateContext ¶
func (p *Plugin) BuildTemplateContext( info *schema.ConfigAndStacksInfo, ciCtx *provider.Context, output string, command string, ) (any, error)
BuildTemplateContext creates a TerraformTemplateContext from execution results. Returns an extended context with terraform-specific fields for template rendering.
func (*Plugin) GetArtifactKey ¶
func (p *Plugin) GetArtifactKey(info *schema.ConfigAndStacksInfo, command string) string
GetArtifactKey generates the artifact storage key for a command. TODO: Consider changing Plugin interface to return (string, error) to align with planfile.GenerateKey validation pattern. Currently uses defensive placeholders since the key is only used for debug logging.
func (*Plugin) GetDefaultTemplates ¶
GetDefaultTemplates returns the embedded default templates.
func (*Plugin) GetHookBindings ¶
func (p *Plugin) GetHookBindings() []plugin.HookBinding
GetHookBindings returns the hook bindings for Terraform CI integration.
func (*Plugin) GetOutputVariables ¶
GetOutputVariables returns CI output variables for a command.
func (*Plugin) ParseOutput ¶
ParseOutput parses terraform command output.
func (*Plugin) ResolveComponentPlanfilePath ¶
func (p *Plugin) ResolveComponentPlanfilePath(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo) (string, error)
ResolveArtifactPath derives the planfile path from component and stack information. During `terraform plan`, the planfile path is generated internally but not propagated to PostRunE hooks. This method reconstructs it so CI hooks can find and upload the planfile. It also populates resolved fields on info needed for metadata (ContextPrefix, Component, etc.).
type TerraformTemplateContext ¶
type TerraformTemplateContext struct {
*plugin.TemplateContext
// Resources contains resource change counts.
Resources plugin.ResourceCounts
// CreatedResources contains addresses of resources to be created.
CreatedResources []string
// UpdatedResources contains addresses of resources to be updated.
UpdatedResources []string
// ReplacedResources contains addresses of resources to be replaced.
ReplacedResources []string
// DeletedResources contains addresses of resources to be destroyed.
DeletedResources []string
// MovedResources contains resources that have been moved.
MovedResources []plugin.MovedResource
// ImportedResources contains addresses of resources to be imported.
ImportedResources []string
// Outputs contains terraform output values (after apply).
Outputs map[string]plugin.TerraformOutput
// ChangedResult contains the plan summary text.
ChangedResult string
// HasDestroy indicates if there are resources to be destroyed.
HasDestroy bool
}
TerraformTemplateContext extends the base TemplateContext with terraform-specific fields. Templates access fields directly (e.g., {{ .Resources.Create }}) instead of through Result.Data.
func NewTemplateContext ¶
func NewTemplateContext(base *plugin.TemplateContext, data *plugin.TerraformOutputData) *TerraformTemplateContext
NewTemplateContext creates a TerraformTemplateContext from a base context and parsed output.
func (*TerraformTemplateContext) HasChanges ¶
func (c *TerraformTemplateContext) HasChanges() bool
HasChanges returns true if there are any resource changes.
func (*TerraformTemplateContext) Target ¶
func (c *TerraformTemplateContext) Target() string
Target returns the stack-component slug for anchor IDs.
func (*TerraformTemplateContext) TotalChanges ¶
func (c *TerraformTemplateContext) TotalChanges() int
TotalChanges returns the total number of resource changes.