From 091e8fa7703ebf4fc81dbfd2fb775908feec1e10 Mon Sep 17 00:00:00 2001 From: Alison Warner Date: Wed, 3 Jul 2024 17:15:00 -0700 Subject: [PATCH 1/2] WIP --- ...gerduty_event_orchestration_path_global.go | 5 ++++ ...ty_event_orchestration_path_global_test.go | 24 ++++++++++++++++++- ...erduty_event_orchestration_path_service.go | 5 ++++ .../pagerduty/event_orchestration_path.go | 1 + 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/pagerduty/resource_pagerduty_event_orchestration_path_global.go b/pagerduty/resource_pagerduty_event_orchestration_path_global.go index 1f989d5fe..892d91bcd 100644 --- a/pagerduty/resource_pagerduty_event_orchestration_path_global.go +++ b/pagerduty/resource_pagerduty_event_orchestration_path_global.go @@ -83,6 +83,11 @@ func buildEventOrchestrationPathGlobalRuleActionsSchema() map[string]*schema.Sch Optional: true, } + a["escalation_policy"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + } + return a } diff --git a/pagerduty/resource_pagerduty_event_orchestration_path_global_test.go b/pagerduty/resource_pagerduty_event_orchestration_path_global_test.go index bdc6fded0..440ea04a1 100644 --- a/pagerduty/resource_pagerduty_event_orchestration_path_global_test.go +++ b/pagerduty/resource_pagerduty_event_orchestration_path_global_test.go @@ -41,6 +41,7 @@ func TestAccPagerDutyEventOrchestrationPathGlobal_Basic(t *testing.T) { Config: testAccCheckPagerDutyEventOrchestrationGlobalDefaultConfig(team, escalationPolicy, service, orch), Check: resource.ComposeTestCheckFunc(baseChecks...), }, + // Adding/updating/deleting automation_action properties { Config: testAccCheckPagerDutyEventOrchestrationPathGlobalAutomationActionsConfig(team, escalationPolicy, service, orch), @@ -276,7 +277,7 @@ func createBaseGlobalOrchConfig(t, ep, s, o string) string { `, t, ep, s, o) } -func testAccCheckPagerDutyEventOrchestrationGlobalDefaultConfig(t, ep, s, o string) string { +func testAccCheckPagerDutyEventOrchestrationGlobalDefaultConfigDefaultConfig(t, ep, s, o string) string { return fmt.Sprintf("%s%s", createBaseGlobalOrchConfig(t, ep, s, o), `resource "pagerduty_event_orchestration_global" "my_global_orch" { event_orchestration = pagerduty_event_orchestration.orch.id @@ -291,6 +292,27 @@ func testAccCheckPagerDutyEventOrchestrationGlobalDefaultConfig(t, ep, s, o stri `) } +func testAccCheckPagerDutyEventOrchestrationGlobalDefaultWithEscalationPolicy(t, ep, s, o string) string { + return fmt.Sprintf("%s%s", createBaseGlobalOrchConfig(t, ep, s, o), + `resource "pagerduty_event_orchestration_global" "my_global_orch" { + event_orchestration = pagerduty_event_orchestration.orch.id + + catch_all { + actions {} + } + set { + id = "start" + rule { + label = "rule 1" + actions { + "escalation_policy": "POLICY" + } + } + } + } + `) +} + func testAccCheckPagerDutyEventOrchestrationPathGlobalAutomationActionsConfig(t, ep, s, o string) string { return fmt.Sprintf("%s%s", createBaseGlobalOrchConfig(t, ep, s, o), `resource "pagerduty_event_orchestration_global" "my_global_orch" { diff --git a/pagerduty/resource_pagerduty_event_orchestration_path_service.go b/pagerduty/resource_pagerduty_event_orchestration_path_service.go index c6b85c6d9..4e91565a8 100644 --- a/pagerduty/resource_pagerduty_event_orchestration_path_service.go +++ b/pagerduty/resource_pagerduty_event_orchestration_path_service.go @@ -93,6 +93,11 @@ func buildEventOrchestrationPathServiceRuleActionsSchema() map[string]*schema.Sc Optional: true, } + a["escalation_policy"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + } + return a } 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 72b60e0f4..2bca63d24 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 @@ -64,6 +64,7 @@ type EventOrchestrationPathRuleActions struct { EventAction string `json:"event_action"` Variables []*EventOrchestrationPathActionVariables `json:"variables"` Extractions []*EventOrchestrationPathActionExtractions `json:"extractions"` + EscalationPolicy string `json:"escalation_policy"` } type EventOrchestrationPathIncidentCustomFieldUpdate struct { From 09b6b9d8e1b3f53998474d654c7802e93d47485f Mon Sep 17 00:00:00 2001 From: Alison Warner Date: Mon, 8 Jul 2024 09:24:47 -0700 Subject: [PATCH 2/2] Add tests for global and service orchs --- ...ty_event_orchestration_path_global_test.go | 6 +++- ...y_event_orchestration_path_service_test.go | 29 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/pagerduty/resource_pagerduty_event_orchestration_path_global_test.go b/pagerduty/resource_pagerduty_event_orchestration_path_global_test.go index 440ea04a1..3f7777baa 100644 --- a/pagerduty/resource_pagerduty_event_orchestration_path_global_test.go +++ b/pagerduty/resource_pagerduty_event_orchestration_path_global_test.go @@ -41,6 +41,10 @@ func TestAccPagerDutyEventOrchestrationPathGlobal_Basic(t *testing.T) { Config: testAccCheckPagerDutyEventOrchestrationGlobalDefaultConfig(team, escalationPolicy, service, orch), Check: resource.ComposeTestCheckFunc(baseChecks...), }, + { + Config: testAccCheckPagerDutyEventOrchestrationGlobalDefaultWithEscalationPolicy(team, escalationPolicy, service, orch), + Check: resource.ComposeTestCheckFunc(baseChecks...), + }, // Adding/updating/deleting automation_action properties { @@ -277,7 +281,7 @@ func createBaseGlobalOrchConfig(t, ep, s, o string) string { `, t, ep, s, o) } -func testAccCheckPagerDutyEventOrchestrationGlobalDefaultConfigDefaultConfig(t, ep, s, o string) string { +func testAccCheckPagerDutyEventOrchestrationGlobalDefaultConfig(t, ep, s, o string) string { return fmt.Sprintf("%s%s", createBaseGlobalOrchConfig(t, ep, s, o), `resource "pagerduty_event_orchestration_global" "my_global_orch" { event_orchestration = pagerduty_event_orchestration.orch.id diff --git a/pagerduty/resource_pagerduty_event_orchestration_path_service_test.go b/pagerduty/resource_pagerduty_event_orchestration_path_service_test.go index ff91dcbd0..19c14313b 100644 --- a/pagerduty/resource_pagerduty_event_orchestration_path_service_test.go +++ b/pagerduty/resource_pagerduty_event_orchestration_path_service_test.go @@ -43,6 +43,10 @@ func TestAccPagerDutyEventOrchestrationPathService_Basic(t *testing.T) { Config: testAccCheckPagerDutyEventOrchestrationPathServiceDefaultConfig(escalationPolicy, service), Check: resource.ComposeTestCheckFunc(baseChecks...), }, + { + Config: testAccCheckPagerDutyEventOrchestrationServiceEscalationPolicy(escalationPolicy, service), + Check: resource.ComposeTestCheckFunc(baseChecks...), + }, // Adding/updating/deleting automation_action properties { Config: testAccCheckPagerDutyEventOrchestrationPathServiceAutomationActionsConfig(escalationPolicy, service), @@ -341,6 +345,31 @@ func createBaseServicePathConfig(ep, s string) string { `, ep, s) } +func testAccCheckPagerDutyEventOrchestrationServiceEscalationPolicy(ep, s string) string { + return fmt.Sprintf("%s%s", createBaseServicePathConfig(ep, s), + `resource "pagerduty_event_orchestration_service" "serviceA" { + service = pagerduty_service.bar.id + + set { + id = "start" + } + + catch_all { + actions { } + } + set { + id = "start" + rule { + label = "rule 1" + actions { + "escalation_policy": "POLICY" + } + } + } + } + `) +} + func testAccCheckPagerDutyEventOrchestrationPathServiceDefaultConfig(ep, s string) string { return fmt.Sprintf("%s%s", createBaseServicePathConfig(ep, s), `resource "pagerduty_event_orchestration_service" "serviceA" {