From af50218ac8c08f8a0cbb46182bad4dd705a77ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Reyes?= Date: Mon, 11 Nov 2024 19:42:49 -0300 Subject: [PATCH 1/3] replace github.com/PagerDuty/go-pagerduty=github.com/alxndr13/go-pagerduty@60a4c9b --- go.mod | 2 ++ go.sum | 8 ++------ .../PagerDuty/go-pagerduty/alert_grouping_setting.go | 6 ++++++ vendor/modules.txt | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index a1c072521..0daf7e2e6 100644 --- a/go.mod +++ b/go.mod @@ -76,3 +76,5 @@ require ( google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) + +replace github.com/PagerDuty/go-pagerduty => github.com/alxndr13/go-pagerduty v0.0.0-20241111083444-60a4c9be7359 diff --git a/go.sum b/go.sum index a710df66d..4980fd3e7 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,11 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/PagerDuty/go-pagerduty v1.8.1-0.20241002154647-8ceedfd04d88 h1:y/icahuphX4xGMW4nLN+Bl4MbFUU4rEA9spwgcPIDJk= -github.com/PagerDuty/go-pagerduty v1.8.1-0.20241002154647-8ceedfd04d88/go.mod h1:ilimTqwHSBjmvKeYA/yayDBZvzf/CX4Pwa9Qbhekzok= -github.com/PagerDuty/go-pagerduty v1.8.1-0.20241025123418-0c3fc7303be4 h1:egkL94FTYFe3GfnJMpY2aAj6tA2wXXYRfGPJPfC90BQ= -github.com/PagerDuty/go-pagerduty v1.8.1-0.20241025123418-0c3fc7303be4/go.mod h1:ilimTqwHSBjmvKeYA/yayDBZvzf/CX4Pwa9Qbhekzok= -github.com/PagerDuty/go-pagerduty v1.8.1-0.20241104145658-2a0050d437ac h1:GtkaaoQH3DSWt9hxC71pAp31pyhKFxU1nBfa5iZWecE= -github.com/PagerDuty/go-pagerduty v1.8.1-0.20241104145658-2a0050d437ac/go.mod h1:ilimTqwHSBjmvKeYA/yayDBZvzf/CX4Pwa9Qbhekzok= github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX7IL/m9Y5LO+KQYv+t1CQOiFe6+SV2J7bE= github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/alxndr13/go-pagerduty v0.0.0-20241111083444-60a4c9be7359 h1:3xXdKIuWfwMzEBTbmSW3fUcVcW+0cJiYbUmAXYPxh8w= +github.com/alxndr13/go-pagerduty v0.0.0-20241111083444-60a4c9be7359/go.mod h1:ilimTqwHSBjmvKeYA/yayDBZvzf/CX4Pwa9Qbhekzok= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= diff --git a/vendor/github.com/PagerDuty/go-pagerduty/alert_grouping_setting.go b/vendor/github.com/PagerDuty/go-pagerduty/alert_grouping_setting.go index c7e0cb3c7..a7f08180f 100644 --- a/vendor/github.com/PagerDuty/go-pagerduty/alert_grouping_setting.go +++ b/vendor/github.com/PagerDuty/go-pagerduty/alert_grouping_setting.go @@ -107,6 +107,12 @@ func (c *Client) ListAlertGroupingSettings(ctx context.Context, o ListAlertGroup } resp, err := c.get(ctx, "/alert_grouping_settings?"+v.Encode(), nil) + + // If there are no alert grouping settings, return an empty response. + if resp.StatusCode == 404 { + return &ListAlertGroupingSettingsResponse{}, nil + } + if err != nil { return nil, err } diff --git a/vendor/modules.txt b/vendor/modules.txt index bc372a9cb..8e92c9bc2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/PagerDuty/go-pagerduty v1.8.1-0.20241104145658-2a0050d437ac +# github.com/PagerDuty/go-pagerduty v1.8.1-0.20241104145658-2a0050d437ac => github.com/alxndr13/go-pagerduty v0.0.0-20241111083444-60a4c9be7359 ## explicit; go 1.19 github.com/PagerDuty/go-pagerduty # github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c @@ -561,3 +561,4 @@ google.golang.org/protobuf/types/known/timestamppb # gopkg.in/ini.v1 v1.67.0 ## explicit gopkg.in/ini.v1 +# github.com/PagerDuty/go-pagerduty => github.com/alxndr13/go-pagerduty v0.0.0-20241111083444-60a4c9be7359 From 9f6e34650e6dcd97d0d2cbd820dc612828cfea8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Reyes?= Date: Mon, 11 Nov 2024 19:43:50 -0300 Subject: [PATCH 2/3] add test case for AGS service not exist regresions --- ...e_pagerduty_alert_grouping_setting_test.go | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/pagerdutyplugin/resource_pagerduty_alert_grouping_setting_test.go b/pagerdutyplugin/resource_pagerduty_alert_grouping_setting_test.go index abee54526..cec9f0681 100644 --- a/pagerdutyplugin/resource_pagerduty_alert_grouping_setting_test.go +++ b/pagerdutyplugin/resource_pagerduty_alert_grouping_setting_test.go @@ -213,6 +213,28 @@ func TestAccPagerDutyAlertGroupingSetting_Time_WithTimeoutZero(t *testing.T) { }) } +func TestAccPagerDutyAlertGroupingSetting_serviceNotExist(t *testing.T) { + ref := fmt.Sprint("tf-", acctest.RandString(5)) + service := fmt.Sprint("tf-", acctest.RandString(5)) + name := fmt.Sprintf("%s grouping", service) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + CheckDestroy: testAccCheckPagerDutyAlertGroupingSettingDestroy, + Steps: []resource.TestStep{ + { + Config: testAccPagerDutyAlertGroupingSettingServiceNotExist(ref, service, name), + Check: resource.ComposeTestCheckFunc( + testAccCheckPagerDutyAlertGroupingSettingExists("pagerduty_alert_grouping_setting."+ref), + resource.TestCheckResourceAttr("pagerduty_alert_grouping_setting."+ref, "name", name), + resource.TestCheckResourceAttrSet("pagerduty_alert_grouping_setting."+ref, "description"), + ), + }, + }, + }) +} + func testAccCheckPagerDutyAlertGroupingSettingDestroy(s *terraform.State) error { for _, r := range s.RootModule().Resources { if r.Type != "pagerduty_alert_grouping_setting" { @@ -407,3 +429,37 @@ resource "pagerduty_alert_grouping_setting" "foo" { services = [pagerduty_service.foo.id] }`, service1, name) } + +func testAccPagerDutyAlertGroupingSettingServiceNotExist(ref, service, name string) string { + return fmt.Sprintf(` +data "pagerduty_escalation_policy" "default" { + name = "Default" +} + +resource "pagerduty_service" "foo" { + name = "%[2]s" + auto_resolve_timeout = "null" + acknowledgement_timeout = 1800 + escalation_policy = data.pagerduty_escalation_policy.default.id + alert_creation = "create_alerts_and_incidents" + + auto_pause_notifications_parameters { + enabled = true + timeout = 120 + } + + incident_urgency_rule { + type = "constant" + urgency = "high" + } +} + +resource "pagerduty_alert_grouping_setting" "%[1]s" { + name = "%[3]s" + services = [pagerduty_service.foo.id] + type = "intelligent" + config { + time_window = 300 + } +}`, ref, service, name) +} From 306481a16023fb395bb49fe1449919ed3043c7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Reyes?= Date: Mon, 11 Nov 2024 20:06:52 -0300 Subject: [PATCH 3/3] point update to github.com/PagerDuty/go-pagerduty@0ef8f34 --- go.mod | 4 +--- go.sum | 4 ++-- vendor/modules.txt | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 0daf7e2e6..3586aa367 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/PagerDuty/terraform-provider-pagerduty go 1.20 require ( - github.com/PagerDuty/go-pagerduty v1.8.1-0.20241104145658-2a0050d437ac + github.com/PagerDuty/go-pagerduty v1.8.1-0.20241111225923-0ef8f340dd3c github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/hc-install v0.6.2 @@ -76,5 +76,3 @@ require ( google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) - -replace github.com/PagerDuty/go-pagerduty => github.com/alxndr13/go-pagerduty v0.0.0-20241111083444-60a4c9be7359 diff --git a/go.sum b/go.sum index 4980fd3e7..e62897a25 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,11 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/PagerDuty/go-pagerduty v1.8.1-0.20241111225923-0ef8f340dd3c h1:Bnw38sqsVdQVOiuTealk57GnuRb86zyd5v/XW3BcPl8= +github.com/PagerDuty/go-pagerduty v1.8.1-0.20241111225923-0ef8f340dd3c/go.mod h1:ilimTqwHSBjmvKeYA/yayDBZvzf/CX4Pwa9Qbhekzok= github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX7IL/m9Y5LO+KQYv+t1CQOiFe6+SV2J7bE= github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/alxndr13/go-pagerduty v0.0.0-20241111083444-60a4c9be7359 h1:3xXdKIuWfwMzEBTbmSW3fUcVcW+0cJiYbUmAXYPxh8w= -github.com/alxndr13/go-pagerduty v0.0.0-20241111083444-60a4c9be7359/go.mod h1:ilimTqwHSBjmvKeYA/yayDBZvzf/CX4Pwa9Qbhekzok= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= diff --git a/vendor/modules.txt b/vendor/modules.txt index 8e92c9bc2..5e46b9f90 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/PagerDuty/go-pagerduty v1.8.1-0.20241104145658-2a0050d437ac => github.com/alxndr13/go-pagerduty v0.0.0-20241111083444-60a4c9be7359 +# github.com/PagerDuty/go-pagerduty v1.8.1-0.20241111225923-0ef8f340dd3c ## explicit; go 1.19 github.com/PagerDuty/go-pagerduty # github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c @@ -561,4 +561,3 @@ google.golang.org/protobuf/types/known/timestamppb # gopkg.in/ini.v1 v1.67.0 ## explicit gopkg.in/ini.v1 -# github.com/PagerDuty/go-pagerduty => github.com/alxndr13/go-pagerduty v0.0.0-20241111083444-60a4c9be7359