Skip to content

Commit

Permalink
tidy up and clarify recipient type helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jharley committed Nov 7, 2023
1 parent f4e143c commit 8232d01
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
17 changes: 6 additions & 11 deletions client/recipient.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,15 @@ const (
PDDefaultSeverity = PDSeverityCRITICAL
)

// TriggerRecipientTypes returns a list of recipient types compatible with Triggers
// TriggerRecipientTypes returns a list of recipient types compatible with Triggers.
// Triggers are a special case as 'Marker' recipients are supported in addition to
// usual types.
func TriggerRecipientTypes() []RecipientType {
return []RecipientType{
RecipientTypeEmail,
RecipientTypePagerDuty,
RecipientTypeSlack,
RecipientTypeWebhook,
RecipientTypeMarker,
RecipientTypeMSTeams,
}
return append(RecipientTypes(), RecipientTypeMarker)
}

// BurnAlertRecipientTypes returns a list of recipient types compatible with Burn Alerts
func BurnAlertRecipientTypes() []RecipientType {
// RecipientTypes returns all supported Recipient types
func RecipientTypes() []RecipientType {
return []RecipientType{
RecipientTypeEmail,
RecipientTypePagerDuty,
Expand Down
4 changes: 2 additions & 2 deletions honeycombio/data_source_recipient.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ If you want to match multiple recipients, use the 'honeycombio_recipients' data
"type": {
Type: schema.TypeString,
Required: true,
Description: "The type of recipient, allowed types are `email`, `pagerduty`, `msteams`, `slack` and `webhook`.",
ValidateFunc: validation.StringInSlice(helper.AsStringSlice(honeycombio.BurnAlertRecipientTypes()), false),
Description: "The type of recipient.",
ValidateFunc: validation.StringInSlice(helper.AsStringSlice(honeycombio.RecipientTypes()), false),
},
"target": {
Type: schema.TypeString,
Expand Down
2 changes: 1 addition & 1 deletion honeycombio/data_source_recipients.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func dataSourceHoneycombioRecipients() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Description: "The type of recipients.",
ValidateFunc: validation.StringInSlice(helper.AsStringSlice(honeycombio.BurnAlertRecipientTypes()), false),
ValidateFunc: validation.StringInSlice(helper.AsStringSlice(honeycombio.RecipientTypes()), false),
},
"detail_filter": {
Type: schema.TypeList,
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/burn_alert_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (*burnAlertResource) Schema(_ context.Context, _ resource.SchemaRequest, re
},
},
Blocks: map[string]schema.Block{
"recipient": notificationRecipientSchema(client.BurnAlertRecipientTypes()),
"recipient": notificationRecipientSchema(client.RecipientTypes()),
},
}
}
Expand Down

0 comments on commit 8232d01

Please sign in to comment.