terraform

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package terraform provides programmatic Terraform execution using terraform-exec.

Index

Constants

This section is empty.

Variables

View Source
var LookPath = func(file string) (string, error) {
	return execLookPath(file)
}

LookPath is a variable to allow mocking in tests.

Functions

This section is empty.

Types

type Manager

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

Manager handles Terraform operations for pack simulations.

func NewManager

func NewManager(dataDir, requestedVersion string) (*Manager, error)

NewManager creates a new Terraform Manager rooted at dataDir. It downloads terraform to <dataDir>/bin/ if not already present, or falls back to local terraform. The terraform binary is downloaded once and cached for all subsequent Manager instances. requestedVersion may be empty to install the latest version.

func NewManagerWithBaseDir

func NewManagerWithBaseDir(baseDir string, terraformPath string) (*Manager, error)

NewManagerWithBaseDir creates a new Manager with a custom base directory.

func (*Manager) Apply

func (m *Manager) Apply(ctx context.Context, workDir string, envVars map[string]string) (map[string]string, error)

Apply runs terraform init + apply and returns the outputs as strings.

func (*Manager) Cleanup

func (m *Manager) Cleanup(workDir string) error

Cleanup removes the working directory.

func (*Manager) Destroy

func (m *Manager) Destroy(ctx context.Context, workDir string, envVars map[string]string) error

Destroy runs terraform destroy.

func (*Manager) Setup

func (m *Manager) Setup(ctx context.Context, executionID string, tfContentBase64 string) (string, error)

Setup creates a working directory and writes the Terraform files. tfContentBase64 is the base64-encoded Terraform file content from the pack manifest.

func (*Manager) WithLogFields

func (m *Manager) WithLogFields(fields logrus.Fields) *Manager

WithLogFields returns a copy of the Manager that includes extra fields in all log entries.

Jump to

Keyboard shortcuts

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