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

[Task] Add "template" field for Global Event Rules and Service Event Rules #314

Conversation

giranm
Copy link
Contributor

@giranm giranm commented Mar 4, 2021

Summary

This PR enables users to define the "template" field within the action.extractions object, required for the "Customize Event Fields" section within the UI. This functionality is GA'd with the following public documentation:

Tests

testAccCheckPagerDutyRulesetRuleConfig was updated to include the template field

% TF_ACC=1 go test -v ./pagerduty -run TestAccPagerDutyRulesetRule           
=== RUN   TestAccPagerDutyRulesetRule_import
--- PASS: TestAccPagerDutyRulesetRule_import (9.51s)
=== RUN   TestAccPagerDutyRulesetRule_Basic
--- PASS: TestAccPagerDutyRulesetRule_Basic (11.60s)
=== RUN   TestAccPagerDutyRulesetRule_MultipleRules
--- PASS: TestAccPagerDutyRulesetRule_MultipleRules (13.14s)
PASS
ok      github.com/terraform-providers/terraform-provider-pagerduty/pagerduty   34.830s

testAccCheckPagerDutyServiceEventRuleConfig was updated to include the template field

% TF_ACC=1 go test -v ./pagerduty -run TestAccPagerDutyServiceEventRule      
=== RUN   TestAccPagerDutyServiceEventRule_import
--- PASS: TestAccPagerDutyServiceEventRule_import (15.35s)
=== RUN   TestAccPagerDutyServiceEventRule_Basic
--- PASS: TestAccPagerDutyServiceEventRule_Basic (18.25s)
=== RUN   TestAccPagerDutyServiceEventRule_MultipleRules
--- PASS: TestAccPagerDutyServiceEventRule_MultipleRules (18.68s)
PASS
ok      github.com/terraform-providers/terraform-provider-pagerduty/pagerduty   52.888s

Example

I've included the Global Event Rule outputs below, similar outputs are seen for the Service Event Rule.

Code

resource "pagerduty_ruleset" "example_ruleset" {
  name = "Example Ruleset"
}

resource "pagerduty_ruleset_rule" "example_ruleset_rule" {
  ruleset = pagerduty_ruleset.example_ruleset.id
  conditions {
    operator = "and"
    subconditions {
      operator = "contains"
      parameter {
        value = "disk space"
        path  = "summary"
      }
    }
  }
  variable {
    type = "regex"
    name = "Src"
    parameters {
      value = "(.*)"
      path  = "payload.source"
    }
  }
  actions {
    extractions {
      target   = "summary"
      template = "{{Src}} | Some Issue Title"
    }
    extractions {
      target = "dedup_key"
      source = "payload.class"
      regex  = "(.*)"
    }
  }
}

Screenshots

Screenshot 2021-03-04 at 22 24 05

Screenshot 2021-03-04 at 22 24 18

@giranm
Copy link
Contributor Author

giranm commented Mar 9, 2021

Have raised PR heimweh/go-pagerduty#50 to ensure this is also captured at the underlying Go library.

@giranm
Copy link
Contributor Author

giranm commented Mar 10, 2021

Additional commit pushed to reflect changes to go-pagerduty lib.
go.mod, go.sum and modules.txt now available.

Copy link
Contributor

@stmcallister stmcallister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thanks for making the changes in the heimweh/go-pagerduty project as well and updating the modules here. 🎉

@stmcallister stmcallister merged commit a462319 into PagerDuty:master Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants