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

feature: making Slack action URL configurable #1535

Conversation

jkeyes
Copy link
Contributor

@jkeyes jkeyes commented Oct 8, 2024

Problem

The "Open view" action in the Slack alert it refers to http://localhost instead of the server where it is deployed.

Solution

Add a Host field to the [slack] section of config.toml. If this field is non-empty use it as the base for the "Open view" Action URL, otherwise default to http://localhost:{port}.

Changes Made

  • added Host field to the SlackConfig struct
  • refactored the slack.Attachment creation code into its own function
  • added a host parameter to the hitSlackWebhook function
  • updated docs to include the new field
  • added webhook_test.go to test the new createSlackAttachment function
  • added config_test.go to test the new Host field

How to Test

  • set host in config.toml to https://example.com
  • create an alert that can easily be triggered e.g. resource count > 0
  • click the "Open view" action in the Slack alert
  • verify the browser attempts to open https://example.com/inventory?view={viewId}

Screenshots

None.

Notes

None.

Checklist

  • Code follows the contributing guidelines
  • Changes have been thoroughly tested
  • Documentation has been updated, if necessary
  • Any dependencies have been added to the project, if necessary

Reviewers

@[username of the reviewer]

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hey, thank you for opening your Pull Request ! 🙂 While a Tailwarden team member takes a look at your PR we would like to invite you to join our official Discord server, where you can interact directly with other contributors and Tailwarden team members. Link here: https://discord.tailwarden.com

Copy link
Collaborator

@Azanul Azanul left a comment

Choose a reason for hiding this comment

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

Really liked what you did with createSlackAttachment

@Azanul Azanul merged commit 0034150 into tailwarden:develop Oct 9, 2024
4 checks passed
@jkeyes jkeyes deleted the feature/1534-configurable-host-for-slack-alert branch October 9, 2024 14:54
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.

3 participants