Skip to content

Commit

Permalink
ref: metric alert trigger now requires at least an action
Browse files Browse the repository at this point in the history
  • Loading branch information
jianyuan committed Oct 20, 2024
1 parent 071b228 commit 358914d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/resources/metric_alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ resource "sentry_metric_alert" "main" {

Required:

- `action` (Block List, Min: 1) (see [below for nested schema](#nestedblock--trigger--action))
- `alert_threshold` (Number)
- `label` (String)
- `threshold_type` (Number)

Optional:

- `action` (Block List) (see [below for nested schema](#nestedblock--trigger--action))
- `resolve_threshold` (Number)

Read-Only:
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func (p *SentryProvider) Resources(ctx context.Context) []func() resource.Resour
func (p *SentryProvider) DataSources(ctx context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
NewAllClientKeysDataSource,
NewAllProjectsDataSource,
NewAllOrganizationMembersDataSource,
NewAllProjectsDataSource,
NewClientKeyDataSource,
NewIssueAlertDataSource,
NewOrganizationDataSource,
Expand Down
8 changes: 7 additions & 1 deletion sentry/data_source_sentry_metric_alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestAccSentryMetricAlertDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttrPair(dn, "owners", rn, "owners"),
resource.TestCheckResourceAttr(dn, "trigger.#", "2"),
resource.TestCheckResourceAttrPair(dn, "triggers.0", rn, "triggers.0"),
resource.TestCheckResourceAttr(dn, "trigger.0.action.#", "0"),
resource.TestCheckResourceAttr(dn, "trigger.0.action.#", "1"),
resource.TestCheckResourceAttrPair(dn, "triggers.1", rn, "triggers.1"),
resource.TestCheckResourceAttr(dn, "trigger.1.action.#", "1"),
testAccCheckSentryMetricAlertExists(rnCopy, &alertCopyID),
Expand Down Expand Up @@ -85,6 +85,12 @@ resource "sentry_metric_alert" "test" {
resolve_threshold = 100.0
trigger {
action {
type = "email"
target_type = "team"
target_identifier = sentry_team.test.internal_id
}
alert_threshold = 1000
label = "critical"
resolve_threshold = 100.0
Expand Down
2 changes: 1 addition & 1 deletion sentry/resource_sentry_metric_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func resourceSentryMetricAlert() *schema.Resource {
},
"action": {
Type: schema.TypeList,
Optional: true,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Expand Down
7 changes: 6 additions & 1 deletion sentry/resource_sentry_metric_alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ resource "sentry_metric_alert" "test" {
type = "email"
target_type = "team"
target_identifier = sentry_team.test.internal_id
integration_id = 32
}
alert_threshold = 1000
Expand All @@ -144,6 +143,12 @@ resource "sentry_metric_alert" "test" {
}
trigger {
action {
type = "email"
target_type = "team"
target_identifier = sentry_team.test.internal_id
}
alert_threshold = 500
label = "warning"
resolve_threshold = 100.0
Expand Down

0 comments on commit 358914d

Please sign in to comment.