Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

Commit 1a908db

Browse files
authored
Update Terraform to 0.13.4 (#67)
* Update Terraform to 0.13.4 Terraform 0.13.1 have kubernetes backend support. Signed-off-by: Dinar Valeev <[email protected]> * Drop key var from varFile Signed-off-by: Dinar Valeev <[email protected]>
1 parent bd7e925 commit 1a908db

File tree

7 files changed

+15
-18
lines changed

7 files changed

+15
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
**NOTE:** We are actively experimenting with this in the open. Consider this ALPHA software and subject to change.
77

8-
Terraform-controller - This is a low level tool to run Git controlled Terraform modules in Kubernetes. The controller manages the TF state file using Kubernetes as a remote statefile backend! [Backend upstream PR](https://github.com/hashicorp/terraform/pull/19525) You can have changes auto-applied or wait for an explicit "OK" before running.
8+
Terraform-controller - This is a low level tool to run Git controlled Terraform modules in Kubernetes. The controller manages the TF state file using Kubernetes as a remote statefile backend (requires Terraform 0.13.4)! You can have changes auto-applied or wait for an explicit "OK" before running.
99

1010
There are two parts to the stack, the controller and the executor.
1111

e2e/e2e_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ func TestTerraState(t *testing.T) {
173173
assert := assert.New(t)
174174

175175
ts, err := e.cs.CoreV1().Secrets(e.namespace).List(v13.ListOptions{
176-
LabelSelector: "terraKey=" + e.generateStateName(),
176+
LabelSelector: "tfstateSecretSuffix=" + e.generateStateName(),
177177
})
178178

179179
assert.Nil(err)
180180
assert.Equal(len(ts.Items), 1)
181-
assert.NotEmpty(ts.Items[0].Data["terrastate"])
181+
assert.NotEmpty(ts.Items[0].Data["tfstate"])
182182
assert.Empty(ts.Items[0].Data["lockInfo"])
183183
}
184184

package/Dockerfile.executor

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ FROM alpine
33
# Need to grab terraform binary
44

55
RUN apk add --no-cache curl git openssh unzip
6-
# This is the real url we will eventually need to pull the zip from
7-
# https://releases.hashicorp.com/terraform/0.11.11/terraform_0.11.11_linux_amd64.zip
8-
RUN curl -sLf https://github.com/dramich/terraform/releases/download/testing/linux_amd64.zip -o terraform_0.11.11_linux_amd64.zip && \
9-
unzip terraform_0.11.11_linux_amd64.zip -d /usr/bin && \
6+
RUN curl -sLf https://releases.hashicorp.com/terraform/0.13.4/terraform_0.13.4_linux_amd64.zip -o terraform_0.13.4_linux_amd64.zip && \
7+
unzip terraform_0.13.4_linux_amd64.zip -d /usr/bin && \
108
chmod +x /usr/bin/terraform && \
11-
rm terraform_0.11.11_linux_amd64.zip
9+
rm terraform_0.13.4_linux_amd64.zip
1210

1311
COPY terraform-executor /usr/bin/
1412

pkg/cli/cmds/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type controllers struct {
2626
}
2727

2828
const (
29-
terraState = "terrastate"
30-
terraKey = "terraKey"
29+
terraState = "tfstate"
30+
terraKey = "tfstateSecretSuffix"
3131
)
3232

3333
var controllerCache *controllers

pkg/executor/runner/backend.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type Terraform struct {
99
}
1010

1111
type Backend struct {
12-
Namespace string `json:"namespace,omitempty"`
13-
Key string `json:"key,omitempty"`
14-
ServiceAccount string `json:"service_account,omitempty"`
12+
Namespace string `json:"namespace,omitempty"`
13+
SecretSuffix string `json:"secret_suffix,omitempty"`
14+
InClusterConfig string `json:"in_cluster_config,omitempty"`
1515
}

pkg/executor/runner/runner.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ func (r *Runner) WriteConfigFile() error {
290290
Terraform: Terraform{
291291
Backend: map[string]*Backend{
292292
"kubernetes": {
293-
Key: r.Execution.Spec.ExecutionName,
294-
Namespace: r.Execution.Namespace,
295-
ServiceAccount: "true",
293+
SecretSuffix: r.Execution.Spec.ExecutionName,
294+
Namespace: r.Execution.Namespace,
295+
InClusterConfig: "true",
296296
},
297297
},
298298
},
@@ -316,7 +316,7 @@ func (r *Runner) WriteVarFile() error {
316316
if !ok {
317317
return fmt.Errorf("no varFile data found in secret %v", r.VarSecret.Name)
318318
}
319-
err := writer.Write(vars, fmt.Sprintf("/root/module/%v.auto.tfvars", r.Execution.Name))
319+
err := writer.Write(vars, fmt.Sprintf("/root/module/%v.auto.tfvars.json", r.Execution.Name))
320320
if err != nil {
321321
return err
322322
}

pkg/terraform/state/deploy.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ func createEnvForJob(input *Input, action, runName, namespace string) {
448448

449449
func getCombinedVars(state *v1.State, input *Input) map[string]string {
450450
combinedVars := combineVars(input)
451-
combinedVars["key"] = state.Name
452451

453452
return combinedVars
454453
}

0 commit comments

Comments
 (0)