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

Suppress Equal Diff on Schedule Layer Timestamps #321

Merged
Merged
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
31 changes: 13 additions & 18 deletions pagerduty/resource_pagerduty_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,24 @@ func resourcePagerDutySchedule() *schema.Resource {
},

"start": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
ValidateFunc: validateRFC3339,
DiffSuppressFunc: suppressRFC3339Diff,
},

"end": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateRFC3339,
DiffSuppressFunc: suppressRFC3339Diff,
},

"rotation_virtual_start": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
ValidateFunc: validateRFC3339,
DiffSuppressFunc: suppressRFC3339Diff,
},

"rotation_turn_length_seconds": {
Expand Down Expand Up @@ -176,18 +182,7 @@ func resourcePagerDutyScheduleRead(d *schema.ResourceData, meta interface{}) err
d.Set("name", schedule.Name)
d.Set("time_zone", schedule.TimeZone)
d.Set("description", schedule.Description)
// Here we override whatever `start` value we get back from the API
// and use what's in the configuration. This is to prevent a diff issue
// because we always get back a new `start` value from the PagerDuty API.
for _, sl := range schedule.ScheduleLayers {
for _, rsl := range d.Get("layer").([]interface{}) {
ssl := rsl.(map[string]interface{})

if sl.ID == ssl["id"].(string) {
sl.Start = ssl["start"].(string)
}
}
}

layers, err := flattenScheduleLayers(schedule.ScheduleLayers)
if err != nil {
return resource.NonRetryableError(err)
Expand Down