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 ExtractBlocks(stdout string, blockType string) []string
- func ExtractErrorBlocks(stdout string) []string
- func ExtractErrors(stdout string) []string
- func ExtractWarningBlocks(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
- type TerraformTemplateContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractBlocks ¶
ExtractBlocks extracts full blocks from terraform stdout.
func ExtractErrorBlocks ¶
ExtractErrorBlocks extracts full error blocks from terraform stdout.
func ExtractErrors ¶
ExtractErrors extracts error messages from terraform stdout. This is used when JSON parsing is not available or for runtime errors.
func ExtractWarningBlocks ¶
ExtractWarningBlocks extracts full warning blocks from terraform stdout.
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) GetHookBindings ¶
func (p *Plugin) GetHookBindings() []plugin.HookBinding
GetHookBindings returns the hook bindings for Terraform CI integration. Each binding has a Handler callback that owns all action logic for the event.
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
// Warnings contains full warning block text extracted from terraform output.
Warnings []string
}
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. Slashes in component names are replaced with underscores for valid HTML anchor IDs.
func (*TerraformTemplateContext) TotalChanges ¶
func (c *TerraformTemplateContext) TotalChanges() int
TotalChanges returns the total number of resource changes.