From 38a9cd5efa8fa6484a9dc9e4953aa98eca64343d Mon Sep 17 00:00:00 2001 From: Goncalo Miranda Date: Wed, 24 Jul 2024 12:37:44 +0100 Subject: [PATCH] fix destroy team membership when user is not the active on-call --- pagerduty/resource_pagerduty_team_membership.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pagerduty/resource_pagerduty_team_membership.go b/pagerduty/resource_pagerduty_team_membership.go index 70456cd4e..a36f45283 100644 --- a/pagerduty/resource_pagerduty_team_membership.go +++ b/pagerduty/resource_pagerduty_team_membership.go @@ -253,7 +253,12 @@ func buildEPsIdsList(l []*pagerduty.OnCall) []string { func extractEPsAssociatedToUser(c *pagerduty.Client, userID string) ([]string, error) { var oncalls []*pagerduty.OnCall retryErr := retry.Retry(2*time.Minute, func() *retry.RetryError { - resp, _, err := c.OnCall.List(&pagerduty.ListOnCallOptions{UserIds: []string{userID}}) + now := time.Now() + resp, _, err := c.OnCall.List(&pagerduty.ListOnCallOptions{ + UserIds: []string{userID}, + Since: now.Format(time.RFC3339), + Until: now.Add(time.Hour * 24 * 90).Format(time.RFC3339), + }) if err != nil { if isErrCode(err, http.StatusBadRequest) { return retry.NonRetryableError(err)