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: resource 'env0_environment_scheduling' does not pass destroy_cro… #842

Merged
merged 1 commit into from
May 1, 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
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 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically passes a null instead of a disabled cron.
Would have been better to fix it in the backend. However, for the sake of time I've fixed it here.

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 * * * *"
}
Loading