|
@ -58,6 +58,7 @@ func (p Plugin) Exec() error { |
|
|
commands = append(commands, remoteConfigCommand(remote)) |
|
|
commands = append(commands, remoteConfigCommand(remote)) |
|
|
} |
|
|
} |
|
|
commands = append(commands, getModules()) |
|
|
commands = append(commands, getModules()) |
|
|
|
|
|
commands = append(commands, initCommand()) |
|
|
commands = append(commands, validateCommand()) |
|
|
commands = append(commands, validateCommand()) |
|
|
commands = append(commands, planCommand(p.Config.Vars, p.Config.Secrets, p.Config.Parallelism, p.Config.Targets)) |
|
|
commands = append(commands, planCommand(p.Config.Vars, p.Config.Secrets, p.Config.Parallelism, p.Config.Targets)) |
|
|
if !p.Config.Plan { |
|
|
if !p.Config.Plan { |
|
@ -102,7 +103,7 @@ func installCaCert(cacert string) *exec.Cmd { |
|
|
|
|
|
|
|
|
func exportSecrets(secrets map[string]string) { |
|
|
func exportSecrets(secrets map[string]string) { |
|
|
for k, v := range secrets { |
|
|
for k, v := range secrets { |
|
|
os.Setenv(fmt.Sprintf("%s", k), fmt.Sprintf("%s", os.Getenv(v))) |
|
|
os.Setenv(k, v) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -146,7 +147,13 @@ func validateCommand() *exec.Cmd { |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func initCommand() * exec.Cmd { |
|
|
|
|
|
return exec.Command("terraform", "init",) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func planCommand(variables map[string]string, secrets map[string]string, parallelism int, targets []string) *exec.Cmd { |
|
|
func planCommand(variables map[string]string, secrets map[string]string, parallelism int, targets []string) *exec.Cmd { |
|
|
|
|
|
exportSecrets(secrets) |
|
|
args := []string{ |
|
|
args := []string{ |
|
|
"plan", |
|
|
"plan", |
|
|
"-out=plan.tfout", |
|
|
"-out=plan.tfout", |
|
@ -158,10 +165,6 @@ func planCommand(variables map[string]string, secrets map[string]string, paralle |
|
|
args = append(args, "-var") |
|
|
args = append(args, "-var") |
|
|
args = append(args, fmt.Sprintf("%s=%s", k, v)) |
|
|
args = append(args, fmt.Sprintf("%s=%s", k, v)) |
|
|
} |
|
|
} |
|
|
for k, v := range secrets { |
|
|
|
|
|
args = append(args, "-var") |
|
|
|
|
|
args = append(args, fmt.Sprintf("%s=%s", k, os.Getenv(v))) |
|
|
|
|
|
} |
|
|
|
|
|
if parallelism > 0 { |
|
|
if parallelism > 0 { |
|
|
args = append(args, fmt.Sprintf("-parallelism=%d", parallelism)) |
|
|
args = append(args, fmt.Sprintf("-parallelism=%d", parallelism)) |
|
|
} |
|
|
} |
|
|