Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade terraform to 0.15.5 #107

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/alicloud/TF_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.11
0.15.5
2 changes: 1 addition & 1 deletion build/all/TF_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.11
0.15.5
2 changes: 1 addition & 1 deletion build/aws/TF_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.11
0.15.5
2 changes: 1 addition & 1 deletion build/azure/TF_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.11
0.15.5
2 changes: 1 addition & 1 deletion build/equinixmetal/TF_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.11
0.15.5
2 changes: 1 addition & 1 deletion build/gcp/TF_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.11
0.15.5
2 changes: 1 addition & 1 deletion build/openstack/TF_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.11
0.15.5
2 changes: 1 addition & 1 deletion build/slim/TF_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.11
0.15.5
5 changes: 2 additions & 3 deletions pkg/terraformer/terraformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ func (t *Terraformer) executeTerraform(ctx context.Context, command Command, par
if command == StateReplaceProvider {
args = append(args, strings.Split(string(command), " ")...)
} else {
args = append(args, "-chdir="+t.paths.ConfigDir)
args = append(args, string(command))
}

Expand All @@ -258,11 +259,9 @@ func (t *Terraformer) executeTerraform(ctx context.Context, command Command, par

if command == StateReplaceProvider {
args = append(args, params...)
} else {
args = append(args, t.paths.ConfigDir)
}

log.Info("executing terraform", "command", command, "args", strings.Join(args[1:], " "))
log.Info("executing terraform", "command", command, "args", strings.Join(args, " "))
tfCmd := exec.Command(TerraformBinary, args...)

logBuffer := &bytes.Buffer{}
Expand Down
34 changes: 17 additions & 17 deletions pkg/terraformer/terraformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ var _ = Describe("Terraformer", func() {
It("should run Apply successfully", func() {
Expect(tf.Run(terraformer.Apply)).To(Succeed())
Eventually(logBuffer).Should(gbytes.Say("some terraform output"))
Eventually(logBuffer).Should(gbytes.Say("args: init"))
Eventually(logBuffer).Should(gbytes.Say("args: apply"))
Eventually(logBuffer).Should(gbytes.Say("init"))
Eventually(logBuffer).Should(gbytes.Say("apply"))
Eventually(logBuffer).Should(gbytes.Say("terraform process finished successfully"))
testObjs.Refresh()
Expect(testObjs.ConfigurationConfigMap.Finalizers).To(ContainElement(terraformer.TerraformerFinalizer))
Expand All @@ -172,8 +172,8 @@ var _ = Describe("Terraformer", func() {
It("should run Destroy successfully", func() {
Expect(tf.Run(terraformer.Destroy)).To(Succeed())
Eventually(logBuffer).Should(gbytes.Say("some terraform output"))
Eventually(logBuffer).Should(gbytes.Say("args: init"))
Eventually(logBuffer).Should(gbytes.Say("args: destroy"))
Eventually(logBuffer).Should(gbytes.Say("init"))
Eventually(logBuffer).Should(gbytes.Say("destroy"))
Eventually(logBuffer).Should(gbytes.Say("terraform process finished successfully"))
testObjs.Refresh()
Expect(testObjs.ConfigurationConfigMap.Finalizers).ToNot(ContainElement(terraformer.TerraformerFinalizer))
Expand All @@ -192,9 +192,9 @@ var _ = Describe("Terraformer", func() {
It("should run Validate successfully", func() {
Expect(tf.Run(terraformer.Validate)).To(Succeed())
Eventually(logBuffer).Should(gbytes.Say("some terraform output"))
Eventually(logBuffer).Should(gbytes.Say("args: init"))
Eventually(logBuffer).Should(gbytes.Say("args: validate"))
Eventually(logBuffer).Should(gbytes.Say("args: plan"))
Eventually(logBuffer).Should(gbytes.Say("init"))
Eventually(logBuffer).Should(gbytes.Say("validate"))
Eventually(logBuffer).Should(gbytes.Say("plan"))
Eventually(logBuffer).Should(gbytes.Say("terraform process finished successfully"))
Expect(paths.TerminationMessagePath).To(testutils.BeEmptyFile())
})
Expand Down Expand Up @@ -250,7 +250,7 @@ var _ = Describe("Terraformer", func() {
Eventually(logBuffer).Should(gbytes.Say("successfully stored terraform state"))

Expect(paths.TerminationMessagePath).To(testutils.BeFileWithContents(And(
ContainSubstring("args: init"),
ContainSubstring("init"),
ContainSubstring("some terraform error"),
)), "termination log should contain all terraform logs")
})
Expand All @@ -270,7 +270,7 @@ var _ = Describe("Terraformer", func() {
Eventually(logBuffer).Should(gbytes.Say("successfully stored terraform state"))

Expect(paths.TerminationMessagePath).To(testutils.BeFileWithContents(And(
ContainSubstring("args: apply"),
ContainSubstring("apply"),
ContainSubstring("doing some long running IaaS ops"),
ContainSubstring("some terraform error"),
)), "termination log should contain all terraform logs")
Expand All @@ -289,7 +289,7 @@ var _ = Describe("Terraformer", func() {
Eventually(logBuffer).Should(gbytes.Say("successfully stored terraform state"))

Expect(paths.TerminationMessagePath).To(testutils.BeFileWithContents(And(
ContainSubstring("args: destroy"),
ContainSubstring("destroy"),
ContainSubstring("doing some long running IaaS ops"),
ContainSubstring("some terraform error"),
)), "termination log should contain all terraform logs")
Expand All @@ -308,7 +308,7 @@ var _ = Describe("Terraformer", func() {
Eventually(logBuffer).Should(gbytes.Say("successfully stored terraform state"))

Expect(paths.TerminationMessagePath).To(testutils.BeFileWithContents(And(
ContainSubstring("args: validate"),
ContainSubstring("validate"),
ContainSubstring("doing some long running IaaS ops"),
ContainSubstring("some terraform error"),
)), "termination log should contain all terraform logs")
Expand Down Expand Up @@ -336,8 +336,8 @@ var _ = Describe("Terraformer", func() {
Eventually(logBuffer).Should(gbytes.Say("successfully stored terraform state"))

Expect(paths.TerminationMessagePath).To(testutils.BeFileWithContents(And(
Not(ContainSubstring("args: validate")),
ContainSubstring("args: plan"),
Not(ContainSubstring("validate")),
ContainSubstring("plan"),
ContainSubstring("doing some long running IaaS ops"),
ContainSubstring("some terraform error"),
)), "termination log should contain all terraform logs")
Expand Down Expand Up @@ -389,23 +389,23 @@ var _ = Describe("Terraformer", func() {
It("should run Apply successfully and execute the state replace-provider command", func() {
Expect(tf.Run(terraformer.Apply)).To(Succeed())
Eventually(logBuffer).Should(gbytes.Say("some terraform output"))
Eventually(logBuffer).Should(gbytes.Say("args: state replace-provider"))
Eventually(logBuffer).Should(gbytes.Say("state replace-provider"))
Eventually(logBuffer).Should(gbytes.Say("terraform process finished successfully"))
testObjs.Refresh()
Expect(paths.TerminationMessagePath).To(testutils.BeEmptyFile())
})
It("should run Destroy successfully and execute the state replace-provider command", func() {
Expect(tf.Run(terraformer.Destroy)).To(Succeed())
Eventually(logBuffer).Should(gbytes.Say("some terraform output"))
Eventually(logBuffer).Should(gbytes.Say("args: state replace-provider"))
Eventually(logBuffer).Should(gbytes.Say("state replace-provider"))
Eventually(logBuffer).Should(gbytes.Say("terraform process finished successfully"))
testObjs.Refresh()
Expect(paths.TerminationMessagePath).To(testutils.BeEmptyFile())
})
It("should run Validate successfully and execute the state replace-provider command", func() {
Expect(tf.Run(terraformer.Validate)).To(Succeed())
Eventually(logBuffer).Should(gbytes.Say("some terraform output"))
Eventually(logBuffer).Should(gbytes.Say("args: state replace-provider"))
Eventually(logBuffer).Should(gbytes.Say("state replace-provider"))
Eventually(logBuffer).Should(gbytes.Say("terraform process finished successfully"))
Expect(paths.TerminationMessagePath).To(testutils.BeEmptyFile())
})
Expand Down Expand Up @@ -448,7 +448,7 @@ var _ = Describe("Terraformer", func() {
Eventually(logBuffer).Should(gbytes.Say("successfully stored terraform state"))

Expect(paths.TerminationMessagePath).To(testutils.BeFileWithContents(And(
ContainSubstring("args: state replace-provider"),
ContainSubstring("state replace-provider"),
ContainSubstring("some terraform error"),
)), "termination log should contain all terraform logs")
})
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/binary/binary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ var _ = Describe("terraformer", func() {
It("should return exit code from terraform init", func() {
runExitCodeTest("apply", 12)
Expect(paths.TerminationMessagePath).To(testutils.BeFileWithContents(And(
ContainSubstring("args: init"),
ContainSubstring("init"),
ContainSubstring("some terraform error"),
)), "termination log should contain all terraform logs")
})
Expand All @@ -449,23 +449,23 @@ var _ = Describe("terraformer", func() {
It("should return exit code from terraform apply", func() {
runExitCodeTest("apply", 42)
Expect(paths.TerminationMessagePath).To(testutils.BeFileWithContents(And(
ContainSubstring("args: apply"),
ContainSubstring("apply"),
ContainSubstring("doing some long running IaaS ops"),
ContainSubstring("some terraform error"),
)), "termination log should contain all terraform logs")
})
It("should return exit code from terraform destroy", func() {
runExitCodeTest("destroy", 43)
Expect(paths.TerminationMessagePath).To(testutils.BeFileWithContents(And(
ContainSubstring("args: destroy"),
ContainSubstring("destroy"),
ContainSubstring("doing some long running IaaS ops"),
ContainSubstring("some terraform error"),
)), "termination log should contain all terraform logs")
})
It("should return exit code from terraform validate", func() {
runExitCodeTest("validate", 44)
Expect(paths.TerminationMessagePath).To(testutils.BeFileWithContents(And(
ContainSubstring("args: validate"),
ContainSubstring("validate"),
ContainSubstring("doing some long running IaaS ops"),
ContainSubstring("some terraform error"),
)), "termination log should contain all terraform logs")
Expand All @@ -482,8 +482,8 @@ var _ = Describe("terraformer", func() {
It("should return exit code from terraform plan", func() {
runExitCodeTest("validate", 45)
Expect(paths.TerminationMessagePath).To(testutils.BeFileWithContents(And(
Not(ContainSubstring("args: validate")),
ContainSubstring("args: plan"),
Not(ContainSubstring("validate")),
ContainSubstring("plan"),
ContainSubstring("doing some long running IaaS ops"),
ContainSubstring("some terraform error"),
)), "termination log should contain all terraform logs")
Expand Down
5 changes: 4 additions & 1 deletion test/utils/fake-terraform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ func main() {
}

func getCommand(args []string) string {
if len(args) < 1 {
if len(args) < 2 {
return ""
}
if strings.HasPrefix(args[0], "-chdir=") {
return args[1]
}
return args[0]
}

Expand Down
2 changes: 1 addition & 1 deletion test/utils/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func PrepareTestObjects(ctx context.Context, c client.Client, namespacePrefix, t
namespacePrefix = "tf-test-"
}
if terraformVersion == "" {
terraformVersion = "0.14.11"
terraformVersion = "0.15.5"
}

// create test namespace
Expand Down