From 24ed61fc9a447e926ed26c73d6066f756381196a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Reyes?= Date: Mon, 5 Feb 2024 18:18:40 -0300 Subject: [PATCH 1/3] add test case to prevent regression --- ...ty_event_orchestration_path_router_test.go | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/pagerduty/resource_pagerduty_event_orchestration_path_router_test.go b/pagerduty/resource_pagerduty_event_orchestration_path_router_test.go index 5f905e293..894fbc8c4 100644 --- a/pagerduty/resource_pagerduty_event_orchestration_path_router_test.go +++ b/pagerduty/resource_pagerduty_event_orchestration_path_router_test.go @@ -108,6 +108,41 @@ func TestAccPagerDutyEventOrchestrationPathRouter_Basic(t *testing.T) { }) } +func TestAccPagerDutyEventOrchestrationPathRouter_EnableRoutingRule(t *testing.T) { + team := fmt.Sprintf("tf-name-%s", acctest.RandString(5)) + escalationPolicy := fmt.Sprintf("tf-%s", acctest.RandString(5)) + service := fmt.Sprintf("tf-%s", acctest.RandString(5)) + orchestration := fmt.Sprintf("tf-orchestration-%s", acctest.RandString(5)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckPagerDutyEventOrchestrationRouterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckPagerDutyEventOrchestrationRouterEnableRoutingRuleConfig(team, escalationPolicy, service, orchestration), + Check: resource.ComposeTestCheckFunc( + testAccCheckPagerDutyEventOrchestrationRouterExists("pagerduty_event_orchestration_router.router"), + resource.TestCheckResourceAttr( + "pagerduty_event_orchestration_router.router", "set.0.rule.0.disabled", "true"), + ), + }, + { + Config: testAccCheckPagerDutyEventOrchestrationRouterEnableRoutingRuleConfigUpdated(team, escalationPolicy, service, orchestration), + Check: resource.ComposeTestCheckFunc( + testAccCheckPagerDutyEventOrchestrationRouterExists("pagerduty_event_orchestration_router.router"), + resource.TestCheckResourceAttr( + "pagerduty_event_orchestration_router.router", "set.0.rule.0.disabled", "false"), + ), + // This is unnecessary, because this is the default behaviour of all + // tests, it is only here to explicitely state that this is the expected + // outcome from test. + ExpectNonEmptyPlan: false, + }, + }, + }) +} + func testAccCheckPagerDutyEventOrchestrationRouterDestroy(s *terraform.State) error { client, _ := testAccProvider.Meta().(*Config).Client() for _, r := range s.RootModule().Resources { @@ -391,6 +426,54 @@ func testAccCheckPagerDutyEventOrchestrationRouterConfigDeleteAllRulesInSet(t, e `) } +func testAccCheckPagerDutyEventOrchestrationRouterEnableRoutingRuleConfig(t, ep, s, o string) string { + return fmt.Sprintf("%s%s", createBaseConfig(t, ep, s, o), + `resource "pagerduty_event_orchestration_router" "router" { + event_orchestration = pagerduty_event_orchestration.orch.id + + catch_all { + actions { + route_to = "unrouted" + } + } + set { + id = "start" + rule { + disabled = true + label = "rule1 label" + actions { + route_to = pagerduty_service.bar.id + } + } + } + } + `) +} + +func testAccCheckPagerDutyEventOrchestrationRouterEnableRoutingRuleConfigUpdated(t, ep, s, o string) string { + return fmt.Sprintf("%s%s", createBaseConfig(t, ep, s, o), + `resource "pagerduty_event_orchestration_router" "router" { + event_orchestration = pagerduty_event_orchestration.orch.id + + catch_all { + actions { + route_to = "unrouted" + } + } + set { + id = "start" + rule { + disabled = false + label = "rule1 label" + actions { + route_to = pagerduty_service.bar.id + } + } + } + } + `) +} + func testAccCheckPagerDutyEventOrchestrationRouterConfigDelete(t, ep, s, o string) string { return createBaseConfig(t, ep, s, o) } From 14db537aa431af4640757136178e5a6b1eec71ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Reyes?= Date: Mon, 5 Feb 2024 19:15:09 -0300 Subject: [PATCH 2/3] replace github.com/heimweh/go-pagerduty=github.com/imjaroiswebdev/go-pagerduty@6f8c039 go mod tidy && go mod vendor --- go.mod | 2 ++ go.sum | 4 ++-- .../go-pagerduty/pagerduty/event_orchestration_path.go | 2 +- vendor/modules.txt | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 87e4ba53d..dda3d2faf 100644 --- a/go.mod +++ b/go.mod @@ -74,3 +74,5 @@ require ( google.golang.org/protobuf v1.32.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) + +replace github.com/heimweh/go-pagerduty => github.com/imjaroiswebdev/go-pagerduty v0.0.0-20240205220520-6f8c0393b684 diff --git a/go.sum b/go.sum index 5947591ec..ccc00c5ac 100644 --- a/go.sum +++ b/go.sum @@ -91,8 +91,8 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/heimweh/go-pagerduty v0.0.0-20231212192829-0de11cddf326 h1:ZyL8A1yPg0C9rUKc/QCUNM848NJ9DhTE/cRZH54y/5s= -github.com/heimweh/go-pagerduty v0.0.0-20231212192829-0de11cddf326/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s= +github.com/imjaroiswebdev/go-pagerduty v0.0.0-20240205220520-6f8c0393b684 h1:/RQu11u50ZZED2vVYRlKlFRukv3etj6wTASBmoa+LRU= +github.com/imjaroiswebdev/go-pagerduty v0.0.0-20240205220520-6f8c0393b684/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= diff --git a/vendor/github.com/heimweh/go-pagerduty/pagerduty/event_orchestration_path.go b/vendor/github.com/heimweh/go-pagerduty/pagerduty/event_orchestration_path.go index f2fcbd3c5..afc5a128a 100644 --- a/vendor/github.com/heimweh/go-pagerduty/pagerduty/event_orchestration_path.go +++ b/vendor/github.com/heimweh/go-pagerduty/pagerduty/event_orchestration_path.go @@ -37,7 +37,7 @@ type EventOrchestrationPathRule struct { Label string `json:"label,omitempty"` Conditions []*EventOrchestrationPathRuleCondition `json:"conditions"` Actions *EventOrchestrationPathRuleActions `json:"actions,omitempty"` - Disabled bool `json:"disabled,omitempty"` + Disabled bool `json:"disabled"` } type EventOrchestrationPathRuleCondition struct { diff --git a/vendor/modules.txt b/vendor/modules.txt index 5fd311e77..9b054576b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -247,7 +247,7 @@ github.com/hashicorp/terraform-svchost # github.com/hashicorp/yamux v0.1.1 ## explicit; go 1.15 github.com/hashicorp/yamux -# github.com/heimweh/go-pagerduty v0.0.0-20231212192829-0de11cddf326 +# github.com/heimweh/go-pagerduty v0.0.0-20231212192829-0de11cddf326 => github.com/imjaroiswebdev/go-pagerduty v0.0.0-20240205220520-6f8c0393b684 ## explicit; go 1.17 github.com/heimweh/go-pagerduty/pagerduty github.com/heimweh/go-pagerduty/persistentconfig @@ -546,3 +546,4 @@ google.golang.org/protobuf/types/known/timestamppb # gopkg.in/ini.v1 v1.67.0 ## explicit gopkg.in/ini.v1 +# github.com/heimweh/go-pagerduty => github.com/imjaroiswebdev/go-pagerduty v0.0.0-20240205220520-6f8c0393b684 From 2e56eefe61daa26cdffb6f4ce44580673f7125e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Reyes?= Date: Tue, 6 Feb 2024 12:20:39 -0300 Subject: [PATCH 3/3] point `heimweh/go-pagerduty` to `a2cbd99` --- 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 dda3d2faf..6edeab651 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/hashicorp/terraform-plugin-mux v0.13.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0 github.com/hashicorp/terraform-plugin-testing v1.6.0 - github.com/heimweh/go-pagerduty v0.0.0-20231212192829-0de11cddf326 + github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76 ) require ( @@ -74,5 +74,3 @@ require ( google.golang.org/protobuf v1.32.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) - -replace github.com/heimweh/go-pagerduty => github.com/imjaroiswebdev/go-pagerduty v0.0.0-20240205220520-6f8c0393b684 diff --git a/go.sum b/go.sum index ccc00c5ac..11ae6360c 100644 --- a/go.sum +++ b/go.sum @@ -91,8 +91,8 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/imjaroiswebdev/go-pagerduty v0.0.0-20240205220520-6f8c0393b684 h1:/RQu11u50ZZED2vVYRlKlFRukv3etj6wTASBmoa+LRU= -github.com/imjaroiswebdev/go-pagerduty v0.0.0-20240205220520-6f8c0393b684/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s= +github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76 h1:+JY7wpGAsTe/r51/nTdo3pQQ2Wj4cTXpsQfij1JK2gc= +github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= diff --git a/vendor/modules.txt b/vendor/modules.txt index 9b054576b..11f0cb2bf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -247,7 +247,7 @@ github.com/hashicorp/terraform-svchost # github.com/hashicorp/yamux v0.1.1 ## explicit; go 1.15 github.com/hashicorp/yamux -# github.com/heimweh/go-pagerduty v0.0.0-20231212192829-0de11cddf326 => github.com/imjaroiswebdev/go-pagerduty v0.0.0-20240205220520-6f8c0393b684 +# github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76 ## explicit; go 1.17 github.com/heimweh/go-pagerduty/pagerduty github.com/heimweh/go-pagerduty/persistentconfig @@ -546,4 +546,3 @@ google.golang.org/protobuf/types/known/timestamppb # gopkg.in/ini.v1 v1.67.0 ## explicit gopkg.in/ini.v1 -# github.com/heimweh/go-pagerduty => github.com/imjaroiswebdev/go-pagerduty v0.0.0-20240205220520-6f8c0393b684