/
plan.go
37 lines (31 loc) · 1.14 KB
/
plan.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package terraform
import (
"testing"
)
// InitAndPlan runs terraform init and plan with the given options and return stdout/stderr from the apply command.
func InitAndPlan(t *testing.T, options *Options) int {
exitCode, err := InitAndPlanE(t, options)
if err != nil {
t.Fatal(err)
}
return exitCode
}
// InitAndPlanE runs terraform init and plan with the given options and return stdout/stderr from the apply command.
func InitAndPlanE(t *testing.T, options *Options) (int, error) {
if _, err := InitE(t, options); err != nil {
return DefaultErrorExitCode, err
}
return PlanExitCodeE(t, options)
}
// PlanExitCode runs terraform apply with the given options and returns the detailed exitcode.
func PlanExitCode(t *testing.T, options *Options) int {
exitCode, err := PlanExitCodeE(t, options)
if err != nil {
t.Fatal(err)
}
return exitCode
}
// PlanExitCodeE runs terraform apply with the given options and returns the detailed exitcode.
func PlanExitCodeE(t *testing.T, options *Options) (int, error) {
return GetExitCodeForTerraformCommandE(t, options, FormatArgs(options.Vars, "plan", "-input=false", "-lock=true", "-detailed-exitcode")...)
}