Skip to content

Commit

Permalink
Merge pull request #950 from cjgajard/cjavier/hotfix-ds-alert-groupin…
Browse files Browse the repository at this point in the history
…g-setting-cursor

Fix cursor for datasource alert grouping setting
  • Loading branch information
cjgajard authored Nov 8, 2024
2 parents bdd3319 + 7b5b20c commit 5733f82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,12 @@ func (d *dataSourceAlertGroupingSetting) Read(ctx context.Context, req datasourc
return
}

var cursorAfter, cursorBefore string
var cursorAfter string
var found *pagerduty.AlertGroupingSetting
err := apiutil.All(ctx, func(offset int) (bool, error) {
resp, err := d.client.ListAlertGroupingSettings(ctx, pagerduty.ListAlertGroupingSettingsOptions{
After: cursorAfter,
Before: cursorBefore,
Limit: 100,
After: cursorAfter,
Limit: 100,
})
if err != nil {
return false, err
Expand All @@ -87,6 +86,7 @@ func (d *dataSourceAlertGroupingSetting) Read(ctx context.Context, req datasourc
}
}

cursorAfter = resp.After
return resp.After != "", nil
})
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pagerdutyplugin/resource_pagerduty_alert_grouping_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ func (r *resourceAlertGroupingSetting) Create(ctx context.Context, req resource.
err := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError {
response, err := r.client.CreateAlertGroupingSetting(ctx, plan)
if err != nil {
if util.IsBadRequestError(err) {
return retry.NonRetryableError(err)
}
return retry.RetryableError(err)
}
plan.ID = response.ID
Expand Down

0 comments on commit 5733f82

Please sign in to comment.