terraform

package
v1.208.1-test.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractBlocks

func ExtractBlocks(stdout string, blockType string) []string

ExtractBlocks extracts full blocks from terraform stdout.

func ExtractErrorBlocks

func ExtractErrorBlocks(stdout string) []string

ExtractErrorBlocks extracts full error blocks from terraform stdout.

func ExtractErrors

func ExtractErrors(stdout string) []string

ExtractErrors extracts error messages from terraform stdout. This is used when JSON parsing is not available or for runtime errors.

func ExtractWarningBlocks

func ExtractWarningBlocks(stdout string) []string

ExtractWarningBlocks extracts full warning blocks from terraform stdout.

func ExtractWarnings

func ExtractWarnings(stdout string) []string

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.

func (*Plugin) GetType

func (p *Plugin) GetType() string

GetType returns the component type.

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

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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