Skip to content

Commit

Permalink
Fix: resource 'env0_environment_scheduling' does not pass destroy_cro…
Browse files Browse the repository at this point in the history
…n=null on updates (#842)
  • Loading branch information
TomerHeber committed May 1, 2024
1 parent 5abb4d4 commit 9134c59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions env0/resource_environment_scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ func resourceEnvironmentSchedulingCreateOrUpdate(ctx context.Context, d *schema.
return diag.Errorf("schema resource data deserialization failed: %v", err)
}

if payload.Deploy != nil && !payload.Deploy.Enabled {
payload.Deploy = nil
}

if payload.Destroy != nil && !payload.Destroy.Enabled {
payload.Destroy = nil
}

if _, err := apiClient.EnvironmentSchedulingUpdate(environmentId, payload); err != nil {
return diag.Errorf("could not create or update environment scheduling: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/014_environment_scheduling/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ resource "env0_environment" "environment" {
resource "env0_environment_scheduling" "scheduling" {
environment_id = env0_environment.environment.id
deploy_cron = "5 * * * *"
destroy_cron = "10 * * * *"
destroy_cron = var.second_run ? null : "10 * * * *"
}

0 comments on commit 9134c59

Please sign in to comment.