diff --git a/client/configuration_set_test.go b/client/configuration_set_test.go index 562f472f..aee29d76 100644 --- a/client/configuration_set_test.go +++ b/client/configuration_set_test.go @@ -155,5 +155,3 @@ var _ = Describe("Configuration Set", func() { }) }) }) - -// TODO add more tests... diff --git a/client/template.go b/client/template.go index e1ae24d8..9f9e8691 100644 --- a/client/template.go +++ b/client/template.go @@ -174,7 +174,7 @@ func (payload *TemplateCreatePayload) Invalidate() error { payload.TerraformVersion = "" } - if payload.Type != "opentofu" { + if payload.Type != "opentofu" && payload.TerragruntTfBinary != "opentofu" { payload.OpentofuVersion = "" } diff --git a/env0/resource_environment_test.go b/env0/resource_environment_test.go index 0e5a31c1..d25ddfda 100644 --- a/env0/resource_environment_test.go +++ b/env0/resource_environment_test.go @@ -2018,7 +2018,8 @@ func TestUnitEnvironmentWithoutTemplateResource(t *testing.T) { GithubInstallationId: 2, TerraformVersion: "0.12.25", TerragruntVersion: "0.26.1", - TerragruntTfBinary: "terraform", + OpentofuVersion: "1.7.1", + TerragruntTfBinary: "opentofu", } environmentCreatePayload := client.EnvironmentCreate{ @@ -2074,6 +2075,7 @@ func TestUnitEnvironmentWithoutTemplateResource(t *testing.T) { IsTerragruntRunAll: updatedTemplate.IsTerragruntRunAll, OrganizationId: updatedTemplate.OrganizationId, TerragruntTfBinary: updatedTemplate.TerragruntTfBinary, + OpentofuVersion: updatedTemplate.OpentofuVersion, } createPayload := client.EnvironmentCreateWithoutTemplate{ @@ -2092,6 +2094,11 @@ func TestUnitEnvironmentWithoutTemplateResource(t *testing.T) { terragruntTfBinary = "terragrunt_tf_binary = \"" + template.TerragruntTfBinary + "\"" } + openTofuVersion := "" + if template.OpentofuVersion != "" { + openTofuVersion = "opentofu_version = \"" + template.OpentofuVersion + "\"" + } + return fmt.Sprintf(` resource "%s" "%s" { name = "%s" @@ -2114,6 +2121,7 @@ func TestUnitEnvironmentWithoutTemplateResource(t *testing.T) { github_installation_id = %d %s %s + %s } }`, resourceType, resourceName, @@ -2135,6 +2143,7 @@ func TestUnitEnvironmentWithoutTemplateResource(t *testing.T) { template.GithubInstallationId, terragruntVersion, terragruntTfBinary, + openTofuVersion, ) } @@ -2176,7 +2185,7 @@ func TestUnitEnvironmentWithoutTemplateResource(t *testing.T) { resource.TestCheckResourceAttr(accessor, "terragrunt_working_directory", environment.TerragruntWorkingDirectory), resource.TestCheckResourceAttr(accessor, "vcs_commands_alias", environment.VcsCommandsAlias), resource.TestCheckResourceAttr(accessor, "without_template_settings.0.repository", updatedTemplate.Repository), - resource.TestCheckResourceAttr(accessor, "without_template_settings.0.terraform_version", updatedTemplate.TerraformVersion), + resource.TestCheckResourceAttr(accessor, "without_template_settings.0.opentofu_version", updatedTemplate.OpentofuVersion), resource.TestCheckResourceAttr(accessor, "without_template_settings.0.type", updatedTemplate.Type), resource.TestCheckResourceAttr(accessor, "without_template_settings.0.path", updatedTemplate.Path), resource.TestCheckResourceAttr(accessor, "without_template_settings.0.terragrunt_version", updatedTemplate.TerragruntVersion),