Skip to content

Commit 5733f82

Browse files
authored
Merge pull request #950 from cjgajard/cjavier/hotfix-ds-alert-grouping-setting-cursor
Fix cursor for datasource alert grouping setting
2 parents bdd3319 + 7b5b20c commit 5733f82

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pagerdutyplugin/data_source_pagerduty_alert_grouping_setting.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,12 @@ func (d *dataSourceAlertGroupingSetting) Read(ctx context.Context, req datasourc
6868
return
6969
}
7070

71-
var cursorAfter, cursorBefore string
71+
var cursorAfter string
7272
var found *pagerduty.AlertGroupingSetting
7373
err := apiutil.All(ctx, func(offset int) (bool, error) {
7474
resp, err := d.client.ListAlertGroupingSettings(ctx, pagerduty.ListAlertGroupingSettingsOptions{
75-
After: cursorAfter,
76-
Before: cursorBefore,
77-
Limit: 100,
75+
After: cursorAfter,
76+
Limit: 100,
7877
})
7978
if err != nil {
8079
return false, err
@@ -87,6 +86,7 @@ func (d *dataSourceAlertGroupingSetting) Read(ctx context.Context, req datasourc
8786
}
8887
}
8988

89+
cursorAfter = resp.After
9090
return resp.After != "", nil
9191
})
9292
if err != nil {

pagerdutyplugin/resource_pagerduty_alert_grouping_setting.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ func (r *resourceAlertGroupingSetting) Create(ctx context.Context, req resource.
147147
err := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError {
148148
response, err := r.client.CreateAlertGroupingSetting(ctx, plan)
149149
if err != nil {
150+
if util.IsBadRequestError(err) {
151+
return retry.NonRetryableError(err)
152+
}
150153
return retry.RetryableError(err)
151154
}
152155
plan.ID = response.ID

0 commit comments

Comments
 (0)