Browse Source

updates to work with terraform 0.9.4

pull/40/head
Joachim Hill-Grannec 8 years ago
parent
commit
1847409c8d
  1. 2
      Dockerfile
  2. 13
      plugin.go

2
Dockerfile

@ -10,7 +10,7 @@ RUN apk -U add \
wget && \ wget && \
rm -rf /var/cache/apk/* rm -rf /var/cache/apk/*
ENV TERRAFORM_VERSION 0.9.2 ENV TERRAFORM_VERSION 0.9.4
RUN wget -q https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -O terraform.zip && \ RUN wget -q https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -O terraform.zip && \
unzip terraform.zip -d /bin && \ unzip terraform.zip -d /bin && \
rm -f terraform.zip rm -f terraform.zip

13
plugin.go

@ -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))
} }

Loading…
Cancel
Save