From e159884c49566d909209b25996ef73824bfe50a3 Mon Sep 17 00:00:00 2001 From: Mohammad Date: Fri, 21 Apr 2023 18:07:42 +0330 Subject: [PATCH] faet(terraform): impl new terraform --- pkg/terraform/terraform.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 pkg/terraform/terraform.go diff --git a/pkg/terraform/terraform.go b/pkg/terraform/terraform.go new file mode 100644 index 0000000..3c4b6f7 --- /dev/null +++ b/pkg/terraform/terraform.go @@ -0,0 +1,26 @@ +package terraform + +import ( + "fmt" + + "github.com/hashicorp/terraform-exec/tfexec" +) + +type Terraform struct { + WorkingDir string + ExecDir string + Exec *tfexec.Terraform +} + +func NewTerraform(workingDir string, execDir string) (*Terraform, error) { + tf, err := tfexec.NewTerraform(workingDir, execDir) + if err != nil { + return nil, fmt.Errorf("error new terraform: %w", err) + } + + return &Terraform{ + WorkingDir: workingDir, + ExecDir: execDir, + Exec: tf, + }, nil +}