Skip to content

Commit

Permalink
remove lego domain and fix business services
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspj committed Mar 8, 2024
1 parent d3ff96a commit 744c497
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pagerduty/resource_pagerduty_business_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ func resourcePagerDutyBusinessServiceRead(d *schema.ResourceData, meta interface
return retry.NonRetryableError(err)
}

if err := handleNotFoundError(err, d); err != nil {
return retry.RetryableError(err)
}

return retry.RetryableError(err)
} else if businessService != nil {
d.Set("name", businessService.Name)
Expand Down Expand Up @@ -190,7 +194,7 @@ func resourcePagerDutyBusinessServiceDelete(d *schema.ResourceData, meta interfa
log.Printf("[INFO] Deleting PagerDuty business service %s", d.Id())

if _, err := client.BusinessServices.Delete(d.Id()); err != nil {
return err
return handleNotFoundError(err, d)
}

d.SetId("")
Expand Down
4 changes: 4 additions & 0 deletions pagerduty/resource_pagerduty_service_dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ func resourcePagerDutyServiceDependencyDisassociate(ctx context.Context, d *sche
return retry.NonRetryableError(err)
}

if err = handleNotFoundError(err, d); err == nil {
return nil
}

// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
Expand Down
4 changes: 2 additions & 2 deletions pagerduty/resource_pagerduty_service_dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestAccPagerDutyBusinessServiceDependency_Basic(t *testing.T) {
{
Config: testAccCheckPagerDutyBusinessServiceDependencyConfig(service, businessService, username, email, escalationPolicy),
Check: resource.ComposeTestCheckFunc(
testAccExternallyDestroyedDependentService("pagerduty_service_dependency.bar", "pagerduty_service.dependBar", "pagerduty_service.supportBar"),
testAccExternallyDestroyedDependentService("pagerduty_service_dependency.foo", "pagerduty_business_service.foo", "pagerduty_service.foo"),
),
ExpectNonEmptyPlan: true,
},
Expand Down Expand Up @@ -384,7 +384,7 @@ func TestAccPagerDutyTechnicalServiceDependency_Basic(t *testing.T) {
dependentService := fmt.Sprintf("tf-%s", acctest.RandString(5))
supportingService := fmt.Sprintf("tf-%s", acctest.RandString(5))
username := fmt.Sprintf("tf-%s", acctest.RandString(5))
email := fmt.Sprintf("%s@lego.com", username)
email := fmt.Sprintf("%s@foo.test", username)
escalationPolicy := fmt.Sprintf("tf-%s", acctest.RandString(5))

resource.Test(t, resource.TestCase{
Expand Down

0 comments on commit 744c497

Please sign in to comment.