terraform

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetInstance

func ResetInstance()

ResetInstance resets the singleton instance of the TerraformClient. This is useful for testing to ensure a fresh client is created.

Types

type TerraformClient

type TerraformClient struct {
	// contains filtered or unexported fields
}

TerraformClient is a wrapper for the Terraform CLI, providing functionality for managing Terraform operations.

func Instance

func Instance(ctx context.Context, cfg config.Settings) *TerraformClient

Instance returns a singleton instance of the TerraformClient. It initializes the client if it has not been created already.

func NewTerraformClient

func NewTerraformClient(ctx context.Context, cfg config.Settings) (TerraformClient, error)

NewTerraformClient creates a new TerraformClient instance and ensures the Terraform CLI is available.

func (*TerraformClient) Apply

func (c *TerraformClient) Apply(ctx context.Context, stage schema.StageConfig) error

Apply applies the Terraform configuration for the specified stage. It runs `terraform apply` with the configured input variables.

func (*TerraformClient) Cleanup

func (c *TerraformClient) Cleanup(ctx context.Context) error

Cleanup removes the downloaded Terraform CLI from the file system.

func (*TerraformClient) Destroy

func (c *TerraformClient) Destroy(ctx context.Context, stage schema.StageConfig) error

Destroy destroys the Terraform-managed infrastructure for the specified stage. It runs `terraform destroy` with the configured input variables and targets.

func (*TerraformClient) Format

func (c *TerraformClient) Format(ctx context.Context, stage schema.StageConfig) error

Format formats the Terraform configuration files in the specified stage directory. It runs `terraform fmt -recursive`.

func (*TerraformClient) Init

Init initializes the Terraform working directory for the specified stage. It runs `terraform init -upgrade -reconfigure` with the provided backend configuration options.

func (*TerraformClient) Output

func (c *TerraformClient) Output(ctx context.Context, stage schema.StageConfig) (map[string][]byte, error)

Output retrieves the Terraform output for the specified stage directory. It returns a map of output variable names to their values in JSON format.

func (*TerraformClient) Plan

func (c *TerraformClient) Plan(ctx context.Context, stage schema.StageConfig) (bool, error)

Plan creates an execution plan for the specified stage. It runs `terraform plan` with the configured input variables and returns whether changes are required.

func (*TerraformClient) Refresh

func (c *TerraformClient) Refresh(ctx context.Context, stage schema.StageConfig) error

Refresh updates the Terraform state for the specified stage. It runs `terraform refresh` with the configured input variables.

func (*TerraformClient) Validate

Validate validates the Terraform configuration for the specified stage. It runs `terraform validate` and returns the validation output.

func (*TerraformClient) Version

func (c *TerraformClient) Version(ctx context.Context) (string, error)

Version retrieves the version of the Terraform CLI. It runs the `terraform version` command and returns the version string.

type TerraformInitOpts

type TerraformInitOpts struct {
	BackendConfig []string // The backend configuration options.
}

TerraformInitOpts represents options for initializing Terraform with backend configuration.

type TfExecTerraformLogger

type TfExecTerraformLogger interface {
	SetLogPath(string) error // Sets the log file path.
	SetLog(string) error     // Sets the log level.
}

TfExecTerraformLogger defines the interface for configuring Terraform logging.

type TfOpts

type TfOpts struct {
	// contains filtered or unexported fields
}

TfOpts represents options for configuring a Terraform instance.

Jump to

Keyboard shortcuts

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