Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address: Using pagerduty_alert_grouping_setting causes error HTTP response failed with status code 404 and no JSON error object was present #952

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
imjaroiswebdev marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
56 changes: 56 additions & 0 deletions pagerdutyplugin/resource_pagerduty_alert_grouping_setting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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)
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Loading