-
Notifications
You must be signed in to change notification settings - Fork 4
/
terraformer.go
38 lines (31 loc) · 955 Bytes
/
terraformer.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
38
package main
/*
* Driver implementation (Terraform executor integration)
* ------------------------------------------------------
*/
import (
"github.com/tintoy/docker-machine-driver-terraform/terraform"
)
// Ensure that the Terraform executor has been successfully configured.
func (driver *Driver) validateTerraformer() error {
_, err := driver.getTerraformer()
return err
}
// Get the Terraform executor for the driver's current configuration.
func (driver *Driver) getTerraformer() (*terraform.Terraformer, error) {
if driver.terraformer == nil {
err := driver.ensureConfigDirIsResolved()
if err != nil {
return nil, err
}
if driver.TerraformExecutablePath != "" {
driver.terraformer, err = terraform.NewWithExecutable(driver.TerraformExecutablePath, driver.ConfigDir)
} else {
driver.terraformer, err = terraform.New(driver.ConfigDir)
}
if err != nil {
return nil, err
}
}
return driver.terraformer, nil
}