terraform

package
v0.60.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package terraform is a generated GoMock package.

Index

Constants

View Source
const (

	// DefaultStateLockTimeout is the default timeout for acquiring Terraform state locks
	DefaultStateLockTimeout = "10m"
)
View Source
const (

	// TerraformCredentialsTokenKey is the secret store key that holds the auth
	// token written into a credentials "host" {} block in the generated
	// .terraformrc. Documented on TerraformCredentialConfig.secret in TypeSpec.
	// Exported so the Terraform driver can request the same key when populating
	// the secret-store resolver map.
	TerraformCredentialsTokenKey = "token"
)

Variables

View Source
var (
	// ErrRecipeNameEmpty is the error when the recipe name is empty.
	ErrRecipeNameEmpty = errors.New("recipe name cannot be empty")
)

Functions

func GetProviderEnvSecretIDs added in v0.36.0

func GetProviderEnvSecretIDs(envConfig recipes.Configuration) map[string][]string

GetProviderEnvSecretIDs parses the envConfig to extract secret IDs configured in providers configuration and environment variables and returns a map of secret store IDs and corresponding slice of keys.

func Install

func Install(ctx context.Context, installer *install.Installer, opts InstallOptions) (*tfexec.Terraform, error)

Install installs Terraform using a global shared binary approach. It uses a global mutex to ensure thread-safe access to the shared Terraform binary. This approach prevents concurrent file system operations that were causing state lock errors.

func NewExecutor

func NewExecutor(ucpConn sdk.Connection, secretProvider *secretprovider.SecretProvider, kubernetesClients kubernetesclientprovider.KubernetesClientProvider) *executor

NewExecutor creates a new Executor with the given UCP connection and secret provider, to execute a Terraform recipe.

func NewTerraform

func NewTerraform(ctx context.Context, tfRootDir, execPath string) (*tfexec.Terraform, error)

NewTerraform creates a working directory for Terraform execution and new Terraform executor with Terraform logs enabled.

func TerraformVersion added in v0.57.1

func TerraformVersion() string

TerraformVersion returns the Terraform version Radius will install.

Types

type InstallOptions added in v0.53.0

type InstallOptions struct {
	// RootDir is the directory used to create the Terraform working directory for the caller.
	RootDir string

	// LogLevel controls the verbosity of Terraform execution logs.
	LogLevel string
}

InstallOptions configures how Terraform is installed and initialized.

type MockTerraformExecutor

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

MockTerraformExecutor is a mock of TerraformExecutor interface.

func NewMockTerraformExecutor

func NewMockTerraformExecutor(ctrl *gomock.Controller) *MockTerraformExecutor

NewMockTerraformExecutor creates a new mock instance.

func (*MockTerraformExecutor) Delete

func (m *MockTerraformExecutor) Delete(ctx context.Context, options Options) error

Delete mocks base method.

func (*MockTerraformExecutor) Deploy

func (m *MockTerraformExecutor) Deploy(ctx context.Context, options Options) (*tfjson.State, error)

Deploy mocks base method.

func (*MockTerraformExecutor) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTerraformExecutor) GetRecipeMetadata

func (m *MockTerraformExecutor) GetRecipeMetadata(ctx context.Context, options Options) (map[string]any, error)

GetRecipeMetadata mocks base method.

type MockTerraformExecutorDeleteCall added in v0.35.0

type MockTerraformExecutorDeleteCall struct {
	*gomock.Call
}

MockTerraformExecutorDeleteCall wrap *gomock.Call

func (*MockTerraformExecutorDeleteCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockTerraformExecutorDeleteCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockTerraformExecutorDeleteCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type MockTerraformExecutorDeployCall added in v0.35.0

type MockTerraformExecutorDeployCall struct {
	*gomock.Call
}

MockTerraformExecutorDeployCall wrap *gomock.Call

func (*MockTerraformExecutorDeployCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockTerraformExecutorDeployCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockTerraformExecutorDeployCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type MockTerraformExecutorGetRecipeMetadataCall added in v0.35.0

type MockTerraformExecutorGetRecipeMetadataCall struct {
	*gomock.Call
}

MockTerraformExecutorGetRecipeMetadataCall wrap *gomock.Call

func (*MockTerraformExecutorGetRecipeMetadataCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockTerraformExecutorGetRecipeMetadataCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockTerraformExecutorGetRecipeMetadataCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type MockTerraformExecutorMockRecorder

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

MockTerraformExecutorMockRecorder is the mock recorder for MockTerraformExecutor.

func (*MockTerraformExecutorMockRecorder) Delete

Delete indicates an expected call of Delete.

func (*MockTerraformExecutorMockRecorder) Deploy

Deploy indicates an expected call of Deploy.

func (*MockTerraformExecutorMockRecorder) GetRecipeMetadata

GetRecipeMetadata indicates an expected call of GetRecipeMetadata.

type Options

type Options struct {
	// RootDir is the root directory of where Terraform is installed and executed for a specific recipe deployment/deletion request.
	RootDir string

	// EnvConfig is the kubernetes runtime and cloud provider configuration for the Radius Environment in which the application consuming the terraform recipe will be deployed.
	EnvConfig *recipes.Configuration

	// EnvRecipe is the recipe metadata associated with the Radius Environment in which the application consuming the terraform recipe will be deployed.
	EnvRecipe *recipes.EnvironmentDefinition

	// ResourceRecipe is recipe metadata associated with the Radius resource deploying the Terraform recipe.
	ResourceRecipe *recipes.ResourceMetadata

	// Secrets represents a map of secrets required for recipe execution.
	// The map's key represents the secretStoreIDs while the value represents the secret data.
	Secrets map[string]recipes.SecretData

	// StateLockTimeout is the timeout duration for acquiring Terraform state locks.
	// If not specified, Terraform's default timeout will be used.
	StateLockTimeout string

	// LogLevel is the log level for Terraform execution (e.g., TRACE, DEBUG, INFO, WARN, ERROR).
	LogLevel string
}

Options represents the options required to build inputs to interact with Terraform.

type TerraformExecutor

type TerraformExecutor interface {
	// Deploy installs terraform and runs terraform init and apply on the terraform module referenced by the recipe using terraform-exec.
	Deploy(ctx context.Context, options Options) (*tfjson.State, error)

	// Delete installs terraform and runs terraform destroy on the terraform module referenced by the recipe using terraform-exec,
	// and deletes the Kubernetes secret created for terraform state store.
	Delete(ctx context.Context, options Options) error

	// GetRecipeMetadata installs terraform and runs terraform get to retrieve information on the terraform module
	GetRecipeMetadata(ctx context.Context, options Options) (map[string]any, error)
}

Directories

Path Synopsis
backends
Package backends is a generated GoMock package.
Package backends is a generated GoMock package.
providers
Package providers is a generated GoMock package.
Package providers is a generated GoMock package.

Jump to

Keyboard shortcuts

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