Documentation
¶
Overview ¶
Package tft provides a set of helpers to test Terraform modules/blueprints.
Index ¶
- Variables
- func AutoDiscoverAndTest(t *gotest.T)
- func WithBackendConfig(backendConfig map[string]interface{}) tftOption
- func WithEnvVars(envVars map[string]string) tftOption
- func WithFixtureName(fixtureName string) tftOption
- func WithLogger(logger *logger.Logger) tftOption
- func WithName(name string) tftOption
- func WithPolicyLibraryPath(policyLibraryPath, terraformVetProject string) tftOption
- func WithRetryableTerraformErrors(retryableTerraformErrors map[string]string, maxRetries int, ...) tftOption
- func WithSetupPath(setupPath string) tftOption
- func WithSetupSaKey(saKey string) tftOption
- func WithTFDir(tfDir string) tftOption
- func WithVars(vars map[string]interface{}) tftOption
- type TFBlueprintTest
- func (b *TFBlueprintTest) Apply(assert *assert.Assertions)
- func (b *TFBlueprintTest) DefaultApply(assert *assert.Assertions)
- func (b *TFBlueprintTest) DefaultInit(assert *assert.Assertions)
- func (b *TFBlueprintTest) DefaultTeardown(assert *assert.Assertions)
- func (b *TFBlueprintTest) DefaultVerify(assert *assert.Assertions)
- func (b *TFBlueprintTest) DefineApply(apply func(*assert.Assertions))
- func (b *TFBlueprintTest) DefineInit(init func(*assert.Assertions))
- func (b *TFBlueprintTest) DefineTeardown(teardown func(*assert.Assertions))
- func (b *TFBlueprintTest) DefineVerify(verify func(*assert.Assertions))
- func (b *TFBlueprintTest) GetStringOutput(name string) string
- func (b *TFBlueprintTest) GetTFOptions() *terraform.Options
- func (b *TFBlueprintTest) GetTFSetupOutputListVal(key string) []string
- func (b *TFBlueprintTest) GetTFSetupStringOutput(key string) string
- func (b *TFBlueprintTest) Init(assert *assert.Assertions)
- func (b *TFBlueprintTest) RedeployTest(n int, nVars map[int]map[string]interface{})
- func (b *TFBlueprintTest) ShouldSkip() bool
- func (b *TFBlueprintTest) Teardown(assert *assert.Assertions)
- func (b *TFBlueprintTest) Test()
- func (b *TFBlueprintTest) Verify(assert *assert.Assertions)
- func (b *TFBlueprintTest) Vet(assert *assert.Assertions)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 WithFixtureName ¶
func WithFixtureName(fixtureName string) tftOption
func WithLogger ¶
func WithPolicyLibraryPath ¶ added in v0.2.0
func WithPolicyLibraryPath(policyLibraryPath, terraformVetProject string) tftOption
func WithRetryableTerraformErrors ¶ added in v0.2.0
func WithSetupPath ¶
func WithSetupPath(setupPath string) tftOption
func WithSetupSaKey ¶
func WithSetupSaKey(saKey string) 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) 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) 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) 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.