Skip to content

Commit f36020d

Browse files
authored
Merge pull request #495 from ghostinthewires/add-upgrade-tfinit
Add -upgrade to terraform init cmd
2 parents 5e9464b + 20060e1 commit f36020d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

server/events/runtime/init_step_runner.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ func (i *InitStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []strin
1616
if ctx.ProjectConfig != nil && ctx.ProjectConfig.TerraformVersion != nil {
1717
tfVersion = ctx.ProjectConfig.TerraformVersion
1818
}
19-
terraformInitCmd := append([]string{"init", "-input=false", "-no-color"}, extraArgs...)
19+
terraformInitCmd := append([]string{"init", "-input=false", "-no-color", "-upgrade"}, extraArgs...)
2020

2121
// If we're running < 0.9 we have to use `terraform get` instead of `init`.
2222
if MustConstraint("< 0.9.0").Check(tfVersion) {
2323
ctx.Log.Info("running terraform version %s so will use `get` instead of `init`", tfVersion)
24-
terraformInitCmd = append([]string{"get", "-no-color"}, extraArgs...)
24+
terraformInitCmd = append([]string{"get", "-no-color", "-upgrade"}, extraArgs...)
2525
}
2626

2727
out, err := i.TerraformExecutor.RunCommandWithVersion(ctx.Log, path, terraformInitCmd, tfVersion, ctx.Workspace)

server/events/runtime/init_step_runner_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ func TestRun_UsesGetOrInitForRightVersion(t *testing.T) {
5959
Equals(t, "", output)
6060

6161
// If using init then we specify -input=false but not for get.
62-
expArgs := []string{c.expCmd, "-input=false", "-no-color", "extra", "args"}
62+
expArgs := []string{c.expCmd, "-input=false", "-no-color", "-upgrade", "extra", "args"}
6363
if c.expCmd == "get" {
64-
expArgs = []string{c.expCmd, "-no-color", "extra", "args"}
64+
expArgs = []string{c.expCmd, "-no-color", "-upgrade", "extra", "args"}
6565
}
6666
terraform.VerifyWasCalledOnce().RunCommandWithVersion(nil, "/path", expArgs, tfVersion, "workspace")
6767
})

0 commit comments

Comments
 (0)