From 80e2edbe508640c8248fa44078f2cbb663c0c074 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Thu, 10 Oct 2024 09:21:05 -0500 Subject: [PATCH 1/4] Fix: env0_environment resource - cannot re-enable vcs --- env0/resource_environment.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/env0/resource_environment.go b/env0/resource_environment.go index 2743f557..1afa852d 100644 --- a/env0/resource_environment.go +++ b/env0/resource_environment.go @@ -671,6 +671,12 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta } } + if shouldUpdateTemplate(d) { + if err := updateTemplate(d, apiClient); err != nil { + return err + } + } + if shouldUpdate(d) { if err := update(d, apiClient); err != nil { return err @@ -689,12 +695,6 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta } } - if shouldUpdateTemplate(d) { - if err := updateTemplate(d, apiClient); err != nil { - return err - } - } - if shouldDeploy(d) { if err := deploy(d, apiClient); err != nil { return err From 8902a73f017fa72363d94f634aa8073ca638a2a5 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Tue, 22 Oct 2024 08:44:02 -0500 Subject: [PATCH 2/4] add harness test --- tests/integration/012_environment/main.tf | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/integration/012_environment/main.tf b/tests/integration/012_environment/main.tf index 8b783ec4..d3b8bfb8 100644 --- a/tests/integration/012_environment/main.tf +++ b/tests/integration/012_environment/main.tf @@ -184,6 +184,27 @@ resource "env0_environment" "environment-without-template" { } } +data "env0_template" "gitlab_template" { + name = "Gitlab Integrated Template" +} + +resource "env0_environment" "environment-without-template-start-with-no-vcs" { + name = "start-with-non-vsc-${random_string.random.result}" + + auto_deploy_on_path_changes_only = var.second_run ? true : false + deploy_on_push = var.second_run ? true : false + run_plan_on_pull_requests = var.second_run ? true : false + + without_template_settings { + type = "opentofu" + is_gitlab = var.second_run ? true : false + repository = data.env0_template.gitlab_template.repository + token_id = data.env0_template.gitlab_template.token_id + token_name = data.env0_template.gitlab_template.token_name + opentofu_version = "latest" + } +} + resource "env0_environment" "inactive" { depends_on = [env0_template_project_assignment.assignment] force_destroy = true From 306eafc0cd5c952a151276b37a89ae8effcaf370 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Tue, 22 Oct 2024 08:46:50 -0500 Subject: [PATCH 3/4] add harness test --- tests/integration/012_environment/main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/012_environment/main.tf b/tests/integration/012_environment/main.tf index d3b8bfb8..5b7ce5b1 100644 --- a/tests/integration/012_environment/main.tf +++ b/tests/integration/012_environment/main.tf @@ -189,7 +189,8 @@ data "env0_template" "gitlab_template" { } resource "env0_environment" "environment-without-template-start-with-no-vcs" { - name = "start-with-non-vsc-${random_string.random.result}" + name = "start-with-non-vsc-${random_string.random.result}" + project_id = env0_project.test_project.id auto_deploy_on_path_changes_only = var.second_run ? true : false deploy_on_push = var.second_run ? true : false From 8190085cc30d77da42f27a0f64ec2c76fc41d1fc Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Tue, 22 Oct 2024 08:51:24 -0500 Subject: [PATCH 4/4] add harness test --- tests/integration/012_environment/main.tf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/integration/012_environment/main.tf b/tests/integration/012_environment/main.tf index 5b7ce5b1..9be5dab8 100644 --- a/tests/integration/012_environment/main.tf +++ b/tests/integration/012_environment/main.tf @@ -189,8 +189,9 @@ data "env0_template" "gitlab_template" { } resource "env0_environment" "environment-without-template-start-with-no-vcs" { - name = "start-with-non-vsc-${random_string.random.result}" - project_id = env0_project.test_project.id + name = "start-with-non-vsc-${random_string.random.result}" + project_id = env0_project.test_project.id + force_destroy = true auto_deploy_on_path_changes_only = var.second_run ? true : false deploy_on_push = var.second_run ? true : false