tft

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Overview

Package tft provides a set of helpers to test Terraform modules/blueprints.

Index

Constants

This section is empty.

Variables

View Source
var (
	CommonRetryableErrors = map[string]string{

		".*FOLDER_TO_DELETE_NON_EMPTY_VIOLATION.*": "Failed to delete non empty folder.",

		".*SERVICE_DISABLED.*": "Required API not enabled.",
	}
)

Functions

func AutoDiscoverAndTest

func AutoDiscoverAndTest(t *gotest.T)

AutoDiscoverAndTest discovers TF config from examples/fixtures and runs tests.

func WithBackendConfig added in v0.1.0

func WithBackendConfig(backendConfig map[string]interface{}) tftOption

func WithEnvVars

func WithEnvVars(envVars map[string]string) tftOption

func WithFixtureName

func WithFixtureName(fixtureName string) tftOption

func WithLogger

func WithLogger(logger *logger.Logger) tftOption

func WithName

func WithName(name string) tftOption

func WithPolicyLibraryPath added in v0.2.0

func WithPolicyLibraryPath(policyLibraryPath, terraformVetProject string) tftOption

func WithRetryableTerraformErrors added in v0.2.0

func WithRetryableTerraformErrors(retryableTerraformErrors map[string]string, maxRetries int, timeBetweenRetries time.Duration) tftOption

func WithSensitiveLogger added in v0.11.0

func WithSensitiveLogger(logger *logger.Logger) tftOption

func WithSetupOutputs added in v0.9.0

func WithSetupOutputs(vars map[string]interface{}) tftOption

WithSetupOutputs overrides output values from the setup stage

func WithSetupPath

func WithSetupPath(setupPath string) tftOption

func WithSetupSaKey

func WithSetupSaKey(saKey string) tftOption

func WithTFDir

func WithTFDir(tfDir string) tftOption

func WithVars

func WithVars(vars map[string]interface{}) tftOption

Types

type TFBlueprintTest

type TFBlueprintTest struct {
	discovery.BlueprintTestConfig // additional blueprint test configs
	// contains filtered or unexported fields
}

TFBlueprintTest implements bpt.Blueprint and stores information associated with a Terraform blueprint test.

func NewTFBlueprintTest

func NewTFBlueprintTest(t testing.TB, opts ...tftOption) *TFBlueprintTest

NewTFBlueprintTest sets defaults, validates and returns a TFBlueprintTest.

func (*TFBlueprintTest) Apply

func (b *TFBlueprintTest) Apply(assert *assert.Assertions)

Apply runs the default or custom apply function for the blueprint.

func (*TFBlueprintTest) DefaultApply

func (b *TFBlueprintTest) DefaultApply(assert *assert.Assertions)

DefaultApply runs TF apply on a blueprint.

func (*TFBlueprintTest) DefaultInit

func (b *TFBlueprintTest) DefaultInit(assert *assert.Assertions)

DefaultInit runs TF init and validate on a blueprint.

func (*TFBlueprintTest) DefaultTeardown

func (b *TFBlueprintTest) DefaultTeardown(assert *assert.Assertions)

DefaultTeardown runs TF destroy on a blueprint.

func (*TFBlueprintTest) DefaultVerify

func (b *TFBlueprintTest) DefaultVerify(assert *assert.Assertions)

DefaultVerify asserts no resource changes exist after apply.

func (*TFBlueprintTest) DefineApply

func (b *TFBlueprintTest) DefineApply(apply func(*assert.Assertions))

DefineApply defines a custom apply function for the blueprint.

func (*TFBlueprintTest) DefineInit

func (b *TFBlueprintTest) DefineInit(init func(*assert.Assertions))

DefineInit defines a custom init function for the blueprint.

func (*TFBlueprintTest) DefinePlan added in v0.14.0

func (b *TFBlueprintTest) DefinePlan(plan func(*terraform.PlanStruct, *assert.Assertions))

DefinePlan defines a custom plan function for the blueprint.

func (*TFBlueprintTest) DefineTeardown

func (b *TFBlueprintTest) DefineTeardown(teardown func(*assert.Assertions))

DefineTeardown defines a custom teardown function for the blueprint.

func (*TFBlueprintTest) DefineVerify

func (b *TFBlueprintTest) DefineVerify(verify func(*assert.Assertions))

DefineVerify defines a custom verify function for the blueprint.

func (*TFBlueprintTest) GetStringOutput

func (b *TFBlueprintTest) GetStringOutput(name string) string

GetStringOutput returns TF output for a given key as string. It fails test if given key does not output a primitive.

func (*TFBlueprintTest) GetStringOutputList added in v0.13.0

func (b *TFBlueprintTest) GetStringOutputList(name string) []string

GetStringOutputList returns TF output for a given key as list. It fails test if given key does not output a primitive.

func (*TFBlueprintTest) GetTFOptions

func (b *TFBlueprintTest) GetTFOptions() *terraform.Options

GetTFOptions generates terraform.Options used by Terratest.

func (*TFBlueprintTest) GetTFSetupOutputListVal

func (b *TFBlueprintTest) GetTFSetupOutputListVal(key string) []string

GetTFSetupOutputListVal returns TF output from setup for a given key as list. It fails test if given key does not output a list type.

func (*TFBlueprintTest) GetTFSetupStringOutput added in v0.2.0

func (b *TFBlueprintTest) GetTFSetupStringOutput(key string) string

GetTFSetupStringOutput returns TF setup output for a given key as string. It fails test if given key does not output a primitive or if setupDir is not configured.

func (*TFBlueprintTest) Init

func (b *TFBlueprintTest) Init(assert *assert.Assertions)

Init runs the default or custom init function for the blueprint.

func (*TFBlueprintTest) Plan added in v0.14.0

func (b *TFBlueprintTest) Plan(assert *assert.Assertions)

Plan runs the custom plan function for the blueprint. If not custom plan function is defined, this stage is skipped.

func (*TFBlueprintTest) PlanAndShow added in v0.14.0

func (b *TFBlueprintTest) PlanAndShow() (string, *terraform.PlanStruct)

PlanAndShow performs a Terraform plan, show and returns the parsed plan output.

func (*TFBlueprintTest) RedeployTest added in v0.4.0

func (b *TFBlueprintTest) RedeployTest(n int, nVars map[int]map[string]interface{})

RedeployTest deploys the test n times in separate workspaces before teardown.

func (*TFBlueprintTest) ShouldSkip

func (b *TFBlueprintTest) ShouldSkip() bool

ShouldSkip checks if a test should be skipped

func (*TFBlueprintTest) Teardown

func (b *TFBlueprintTest) Teardown(assert *assert.Assertions)

Teardown runs the default or custom teardown function for the blueprint.

func (*TFBlueprintTest) Test

func (b *TFBlueprintTest) Test()

Test runs init, apply, verify, teardown in order for the blueprint.

func (*TFBlueprintTest) Verify

func (b *TFBlueprintTest) Verify(assert *assert.Assertions)

Verify runs the default or custom verify function for the blueprint.

func (*TFBlueprintTest) Vet added in v0.2.0

func (b *TFBlueprintTest) Vet(assert *assert.Assertions)

Vet runs TF plan, TF show, and gcloud terraform vet on a blueprint.

Jump to

Keyboard shortcuts

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