From fb62b8d757ea3abd9c4f3e8ff27d004b3676ed50 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Thu, 5 Oct 2023 10:19:20 -0500 Subject: [PATCH] =?UTF-8?q?Fix:=20unable=20to=20unset=20auto=5Fdeploy=5Fby?= =?UTF-8?q?=5Fcustom=5Fglob=20property=20of=20environme=E2=80=A6=20(#720)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix: unable to unset auto_deploy_by_custom_glob property of environment resource back to empty string or null * added an integration test * added an integration test * added an integration test * added an integration test * added an integration test --- client/environment.go | 2 +- tests/integration/012_environment/main.tf | 27 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/client/environment.go b/client/environment.go index f9679642..9b9cb68e 100644 --- a/client/environment.go +++ b/client/environment.go @@ -129,7 +129,7 @@ type EnvironmentCreate struct { ContinuousDeployment *bool `json:"continuousDeployment,omitempty" tfschema:"-"` PullRequestPlanDeployments *bool `json:"pullRequestPlanDeployments,omitempty" tfschema:"-"` AutoDeployOnPathChangesOnly *bool `json:"autoDeployOnPathChangesOnly,omitempty" tfchema:"-"` - AutoDeployByCustomGlob string `json:"autoDeployByCustomGlob,omitempty"` + AutoDeployByCustomGlob string `json:"autoDeployByCustomGlob"` ConfigurationChanges *ConfigurationChanges `json:"configurationChanges,omitempty" tfschema:"-"` TTL *TTL `json:"ttl,omitempty" tfschema:"-"` TerragruntWorkingDirectory string `json:"terragruntWorkingDirectory,omitempty"` diff --git a/tests/integration/012_environment/main.tf b/tests/integration/012_environment/main.tf index 3731b08e..614d3ba1 100644 --- a/tests/integration/012_environment/main.tf +++ b/tests/integration/012_environment/main.tf @@ -11,12 +11,17 @@ resource "env0_project" "test_project" { force_destroy = true } +data "env0_template" "github_template_for_environment" { + name = "Github Integrated Template" +} + resource "env0_template" "template" { - name = "Template for environment resource-${random_string.random.result}" - type = "terraform" - repository = "https://github.com/env0/templates" - path = "misc/null-resource" - terraform_version = "0.15.1" + repository = data.env0_template.github_template_for_environment.repository + github_installation_id = data.env0_template.github_template_for_environment.github_installation_id + name = "Template for environment resource-${random_string.random.result}" + type = "terraform" + path = "misc/null-resource" + terraform_version = "0.15.1" } resource "env0_template_project_assignment" "assignment" { @@ -24,6 +29,18 @@ resource "env0_template_project_assignment" "assignment" { project_id = env0_project.test_project.id } +resource "env0_environment" "auto_glob_envrironment" { + depends_on = [env0_template_project_assignment.assignment] + name = "environment-auto-glob-${random_string.random.result}" + project_id = env0_project.test_project.id + template_id = env0_template.template.id + auto_deploy_by_custom_glob = var.second_run ? "" : "//*" + auto_deploy_on_path_changes_only = true + approve_plan_automatically = true + deploy_on_push = true + force_destroy = true +} + resource "env0_environment" "example" { depends_on = [env0_template_project_assignment.assignment] force_destroy = true