Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: env0_environment resource - cannot re-enable vcs #963

Merged
merged 5 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions env0/resource_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,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
Expand All @@ -702,12 +708,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
Expand Down
23 changes: 23 additions & 0 deletions tests/integration/012_environment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,29 @@ 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}"
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
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
Expand Down
Loading