Skip to content

Commit

Permalink
feat: slack channel regex accepts channel id (#540)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?

- Closes #533

## Short description of the changes
Updates the Slack channel regex to include channel ids in addition to
channels/users beginning with `#` or `@`
  • Loading branch information
brookesargent authored Sep 3, 2024
1 parent 895e2a5 commit f6deb55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/resources/slack_recipient.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ resource "honeycombio_slack_recipient" "alerts" {

The following arguments are supported:

* `channel` - (Required) The Slack channel or username to send the notification to. Must begin with `#` or `@`.
* `channel` - (Required) The Slack channel or username to send the notification to. Must begin with `#` or `@` or be a valid channel id e.g. `CABC123DEF.

## Attribute Reference

Expand Down
6 changes: 4 additions & 2 deletions honeycombio/resource_slack_recipient.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
honeycombio "github.com/honeycombio/terraform-provider-honeycombio/client"
)

var channelRegex = regexp.MustCompile(`^#.*|^@.*|^(C|D|G)[A-Z0-9]{6,}$`)

func newSlackRecipient() *schema.Resource {
return &schema.Resource{
CreateContext: resourceSlackRecipientCreate,
Expand All @@ -26,8 +28,8 @@ func newSlackRecipient() *schema.Resource {
"channel": {
Type: schema.TypeString,
Required: true,
Description: "The Slack channel or username to send the notification to. Must begin with `#` or `@`.",
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^(#|@).+`), "channel must begin with `#` or `@`"),
Description: "The Slack channel or username to send the notification to. Must begin with `#` or `@` or be a valid channel id e.g. `CABC123DEF.",
ValidateFunc: validation.StringMatch(channelRegex, "channel must begin with `#` or `@` or be a valid channel id e.g. `CABC123DEF`"),
},
},
}
Expand Down

0 comments on commit f6deb55

Please sign in to comment.