fix(oncall): enable creation of web based schedules through tf #2382
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes an issue that prevented the creation of web type schedules in Grafana OnCall using Terraform. Although the provider was intended to support all schedule types, a validation conflict caused the creation of web schedules to fail.
The provider was incorrectly returning the error
Error: time_zone can not be set with type: web.This contradicted the Grafana OnCall API, which requires the time_zone field for this schedule type and would fail with the error
Error: POST <oncall_api_url>/api/v1/schedules/: 400 {time_zone: [This field is required.]}.This fix resolves the conflicting validation logic, allowing time_zone to be correctly passed to the API for web schedules.
Key Changes
time_zonelogic: The validation for the time_zone field has been adjusted to allow its use with web type schedules, resolving the API conflict.webschedules: Implemented the CustomizeDiff function, which forces the resource to be recreated (ForceNew) whenever any of its attributes are changed and the type is web. This ensures that the Terraform state remains consistent, as changes in the Grafana UI are not reflected back into the state.webschedule example: Added a new grafana_oncall_schedule resource example with type = "web" to demonstrate its correct usage, including the lifecycle { ignore_changes = all } block.How to Test
Additional Details