diff --git a/build/alicloud/TF_VERSION b/build/alicloud/TF_VERSION index ecf56ca4..1282fff5 100644 --- a/build/alicloud/TF_VERSION +++ b/build/alicloud/TF_VERSION @@ -1 +1 @@ -0.14.11 +0.15.5 diff --git a/build/all/TF_VERSION b/build/all/TF_VERSION index ecf56ca4..1282fff5 100644 --- a/build/all/TF_VERSION +++ b/build/all/TF_VERSION @@ -1 +1 @@ -0.14.11 +0.15.5 diff --git a/build/aws/TF_VERSION b/build/aws/TF_VERSION index ecf56ca4..1282fff5 100644 --- a/build/aws/TF_VERSION +++ b/build/aws/TF_VERSION @@ -1 +1 @@ -0.14.11 +0.15.5 diff --git a/build/azure/TF_VERSION b/build/azure/TF_VERSION index ecf56ca4..1282fff5 100644 --- a/build/azure/TF_VERSION +++ b/build/azure/TF_VERSION @@ -1 +1 @@ -0.14.11 +0.15.5 diff --git a/build/equinixmetal/TF_VERSION b/build/equinixmetal/TF_VERSION index ecf56ca4..1282fff5 100644 --- a/build/equinixmetal/TF_VERSION +++ b/build/equinixmetal/TF_VERSION @@ -1 +1 @@ -0.14.11 +0.15.5 diff --git a/build/gcp/TF_VERSION b/build/gcp/TF_VERSION index ecf56ca4..1282fff5 100644 --- a/build/gcp/TF_VERSION +++ b/build/gcp/TF_VERSION @@ -1 +1 @@ -0.14.11 +0.15.5 diff --git a/build/openstack/TF_VERSION b/build/openstack/TF_VERSION index ecf56ca4..1282fff5 100644 --- a/build/openstack/TF_VERSION +++ b/build/openstack/TF_VERSION @@ -1 +1 @@ -0.14.11 +0.15.5 diff --git a/build/slim/TF_VERSION b/build/slim/TF_VERSION index ecf56ca4..1282fff5 100644 --- a/build/slim/TF_VERSION +++ b/build/slim/TF_VERSION @@ -1 +1 @@ -0.14.11 +0.15.5 diff --git a/pkg/terraformer/terraformer.go b/pkg/terraformer/terraformer.go index ccf6d021..39781504 100644 --- a/pkg/terraformer/terraformer.go +++ b/pkg/terraformer/terraformer.go @@ -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)) } @@ -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{} diff --git a/pkg/terraformer/terraformer_test.go b/pkg/terraformer/terraformer_test.go index 9345d744..c4daa99c 100644 --- a/pkg/terraformer/terraformer_test.go +++ b/pkg/terraformer/terraformer_test.go @@ -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)) @@ -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)) @@ -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()) }) @@ -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") }) @@ -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") @@ -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") @@ -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") @@ -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") @@ -389,7 +389,7 @@ 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()) @@ -397,7 +397,7 @@ var _ = Describe("Terraformer", func() { 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()) @@ -405,7 +405,7 @@ var _ = Describe("Terraformer", func() { 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()) }) @@ -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") }) diff --git a/test/e2e/binary/binary_test.go b/test/e2e/binary/binary_test.go index 3c10e2a6..74d9ccfe 100644 --- a/test/e2e/binary/binary_test.go +++ b/test/e2e/binary/binary_test.go @@ -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") }) @@ -449,7 +449,7 @@ 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") @@ -457,7 +457,7 @@ var _ = Describe("terraformer", func() { 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") @@ -465,7 +465,7 @@ var _ = Describe("terraformer", func() { 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") @@ -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") diff --git a/test/utils/fake-terraform/main.go b/test/utils/fake-terraform/main.go index a23f6af9..dbcc8144 100644 --- a/test/utils/fake-terraform/main.go +++ b/test/utils/fake-terraform/main.go @@ -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] } diff --git a/test/utils/objects.go b/test/utils/objects.go index 49d98a84..0d892e1f 100644 --- a/test/utils/objects.go +++ b/test/utils/objects.go @@ -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