-
Notifications
You must be signed in to change notification settings - Fork 0
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
[ORCA-4811] Add support for dynamic_route_to
action to pagerduty_event_orchestration_router
#1
[ORCA-4811] Add support for dynamic_route_to
action to pagerduty_event_orchestration_router
#1
Conversation
if !isNilFunc(dra) && len(dra.([]interface{})) > 0 { | ||
actions.DynamicRouteTo = expandRouterDynamicRouteToAction(dra) | ||
} else { | ||
actions.RouteTo = am["route_to"].(string) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotation: The dynamic_route_to
action takes precedence over route_to
but we can hopefully add validation for these actions to be mutually exclusive in the subsequent ticket (https://pagerduty.atlassian.net/browse/ORCA-4813).
@@ -76,3 +76,5 @@ require ( | |||
google.golang.org/protobuf v1.33.0 // indirect | |||
gopkg.in/ini.v1 v1.67.0 // indirect | |||
) | |||
|
|||
replace github.com/heimweh/go-pagerduty => github.com/alexzakabluk/go-pagerduty v0.0.0-20240607142119-ac9a64bba6da |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotation: This change as well as the changes in go.sum
, vendor/github.com/heimweh/go-pagerduty/pagerduty/event_orchestration_path.go
, and vendor/modules.txt
is the result of temporarily pointing the provider to a feature branch of github.com/heimweh/go-pagerduty
:
$ go mod edit -replace "github.com/heimweh/go-pagerduty=github.com/alexzakabluk/go-pagerduty@rule-actions-updates"
$ go mod tidy
$ go mod vendor
We can merge this change into the base branch and upgrade to the latest go-pagerduty
version before merging into https://github.com/PagerDuty/terraform-provider-pagerduty. If we don't merge this change the base branch won't compile since the DynamicRouteTo
property will be missing in the API Client.
"route_to": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotation: We can't have either dynamic_route_to
or route_to
required because they are mutually exclusive and a rule will have either one. Hopefully in the subsequent PR we can add a check for a rule to have one or the other.
dynamicRouteToByNameInput := &pagerduty.EventOrchestrationPathDynamicRouteTo{ | ||
LookupBy: "service_name", | ||
Regex: ".*", | ||
Source: "event.custom_details.pd_service_name", | ||
} | ||
dynamicRouteToByIDInput := &pagerduty.EventOrchestrationPathDynamicRouteTo{ | ||
LookupBy: "service_id", | ||
Regex: "ID:(.*)", | ||
Source: "event.custom_details.pd_service_id", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotation: I'm using these variables to 1. build the config and 2. use in the verification functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still feel unfamiliar enough with Go to be tentative in my ability to spot issues. As usual your through QA gives me confidence, and I don't see anything immediately worrying about the code in this PR 🚀
This reverts commit e42694d.
I reverted the commit that fixes the import Router test because there is another PR addressing the issue: PagerDuty#883 |
36a750d
into
event-orchestration-dynamic-routing-and-esc-policy-support
Context
This PR adds support for the
dynamic_route_to
rule action for thepagerduty_event_orchestration_router
resource. Config validation is out of scope for this ticket and will be added as part of https://pagerduty.atlassian.net/browse/ORCA-4813.The action can be configured as follows:
Testing
Acceptance Tests Passing
TestAccPagerDutyEventOrchestrationPathRouter_import
test is failing, but import tests for unrouted and service orchestrations are also failing on the master branch because of the same error where theImportStateVerify
function finds differences in rule IDs in case with Router/Unrouted EOs, and theenable_event_orchestration_for_service
for Service EO. I added some temporary logs in various spots in the code to confirm that rule IDs are mapped to the resource data when a GET call is made, so I suspect it could be an update to the testing library or something similar that caused the checks to get stricter or run at a different time. I will look into it a bit more but I want to do it outside of the scope of this PR.✅ Note 2 Update: I tested Router import with the latest version of PD TF Provider (3.13.1) locally and confirmed that it's working as expected. So I added the
ImportStateVerifyIgnore: []string{"set.0.rule.0.id", "set.0.rule.1.id"}
property to the router import test so it doesn't compare rule IDs. All Router tests are passing now but I also asked in the #terraform-provider channel to make sure we are not hiding any import issues:Local testing steps for posterity:
pdt-
account as a data source in my localmain.tf
:terraform plan
andterraform apply
: