From 3aa08528762a1cd958091d68dcd988f5e0f1e5f3 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Tue, 3 Oct 2023 15:05:05 -0500 Subject: [PATCH 1/6] Fix: unable to unset auto_deploy_by_custom_glob property of environment resource back to empty string or null --- client/environment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"` From 531dd91ddc6c5a350b5a80cf02d64a53a9f22d21 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Wed, 4 Oct 2023 09:49:48 -0500 Subject: [PATCH 2/6] added an integration test --- tests/integration/012_environment/main.tf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/integration/012_environment/main.tf b/tests/integration/012_environment/main.tf index 3731b08e..b84c1556 100644 --- a/tests/integration/012_environment/main.tf +++ b/tests/integration/012_environment/main.tf @@ -24,6 +24,16 @@ resource "env0_template_project_assignment" "assignment" { project_id = env0_project.test_project.id } +resource "env0_environment" "auto_glob_envrironment" { + 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 +} + resource "env0_environment" "example" { depends_on = [env0_template_project_assignment.assignment] force_destroy = true From 3c7d9e594c417d6af57925caf73c9809822f8976 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Wed, 4 Oct 2023 09:55:28 -0500 Subject: [PATCH 3/6] added an integration test --- tests/integration/012_environment/main.tf | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/integration/012_environment/main.tf b/tests/integration/012_environment/main.tf index b84c1556..25461001 100644 --- a/tests/integration/012_environment/main.tf +++ b/tests/integration/012_environment/main.tf @@ -12,11 +12,12 @@ resource "env0_project" "test_project" { } 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" + 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" + github_installation_id = 12223344 } resource "env0_template_project_assignment" "assignment" { From c1e38a15db35c8f46fb909175b561edd808720cd Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Wed, 4 Oct 2023 10:01:23 -0500 Subject: [PATCH 4/6] added an integration test --- tests/integration/012_environment/main.tf | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/integration/012_environment/main.tf b/tests/integration/012_environment/main.tf index 25461001..abe7572a 100644 --- a/tests/integration/012_environment/main.tf +++ b/tests/integration/012_environment/main.tf @@ -11,13 +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" { + 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" - repository = "https://github.com/env0/templates" path = "misc/null-resource" terraform_version = "0.15.1" - github_installation_id = 12223344 } resource "env0_template_project_assignment" "assignment" { From 9b488b3b23fffafcd47eec69353f119baf689ed1 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Wed, 4 Oct 2023 10:14:51 -0500 Subject: [PATCH 5/6] added an integration test --- tests/integration/012_environment/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/012_environment/main.tf b/tests/integration/012_environment/main.tf index abe7572a..289b848c 100644 --- a/tests/integration/012_environment/main.tf +++ b/tests/integration/012_environment/main.tf @@ -30,6 +30,7 @@ resource "env0_template_project_assignment" "assignment" { } 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 From 726e2694827670a6b2db8f78aaf27aba4e3ed3d7 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Wed, 4 Oct 2023 10:30:39 -0500 Subject: [PATCH 6/6] added an integration test --- tests/integration/012_environment/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/012_environment/main.tf b/tests/integration/012_environment/main.tf index 289b848c..614d3ba1 100644 --- a/tests/integration/012_environment/main.tf +++ b/tests/integration/012_environment/main.tf @@ -38,6 +38,7 @@ resource "env0_environment" "auto_glob_envrironment" { auto_deploy_on_path_changes_only = true approve_plan_automatically = true deploy_on_push = true + force_destroy = true } resource "env0_environment" "example" {