|
|
@ -32,6 +32,7 @@ type ( |
|
|
|
Parallelism int |
|
|
|
Targets []string |
|
|
|
VarFiles []string |
|
|
|
PluginDir bool |
|
|
|
} |
|
|
|
|
|
|
|
Netrc struct { |
|
|
@ -45,6 +46,7 @@ type ( |
|
|
|
BackendConfig []string `json:"backend-config"` |
|
|
|
Lock *bool `json:"lock"` |
|
|
|
LockTimeout string `json:"lock-timeout"` |
|
|
|
PluginPath string `json:"plugin-path` |
|
|
|
} |
|
|
|
|
|
|
|
// Plugin represents the plugin instance to be executed
|
|
|
@ -87,7 +89,7 @@ func (p Plugin) Exec() error { |
|
|
|
} |
|
|
|
|
|
|
|
commands = append(commands, deleteCache()) |
|
|
|
commands = append(commands, initCommand(p.Config.InitOptions)) |
|
|
|
commands = append(commands, initCommand(p.Config)) |
|
|
|
commands = append(commands, getModules()) |
|
|
|
|
|
|
|
// Add commands listed from Actions
|
|
|
@ -186,23 +188,29 @@ func getModules() *exec.Cmd { |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
func initCommand(config InitOptions) *exec.Cmd { |
|
|
|
func initCommand(config Config) *exec.Cmd { |
|
|
|
args := []string{ |
|
|
|
"init", |
|
|
|
} |
|
|
|
|
|
|
|
for _, v := range config.BackendConfig { |
|
|
|
for _, v := range config.InitOptions.BackendConfig { |
|
|
|
args = append(args, fmt.Sprintf("-backend-config=%s", v)) |
|
|
|
} |
|
|
|
|
|
|
|
// True is default in TF
|
|
|
|
if config.Lock != nil { |
|
|
|
args = append(args, fmt.Sprintf("-lock=%t", *config.Lock)) |
|
|
|
if config.InitOptions.Lock != nil { |
|
|
|
args = append(args, fmt.Sprintf("-lock=%t", *config.InitOptions.Lock)) |
|
|
|
} |
|
|
|
|
|
|
|
// "0s" is default in TF
|
|
|
|
if config.LockTimeout != "" { |
|
|
|
args = append(args, fmt.Sprintf("-lock-timeout=%s", config.LockTimeout)) |
|
|
|
if config.InitOptions.LockTimeout != "" { |
|
|
|
args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout)) |
|
|
|
} |
|
|
|
|
|
|
|
if config.PluginDir == true { |
|
|
|
if config.InitOptions.PluginPath != "" { |
|
|
|
args = append(args, fmt.Sprintf("-plugin-dir=%s", config.InitOptions.PluginPath)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Fail Terraform execution on prompt
|
|
|
|