-
Notifications
You must be signed in to change notification settings - Fork 304
New custom slack sink, slack_sink_preview #1789
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
Merged
Merged
Changes from 23 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
ce49b90
WIP
aantn 96a69e2
Update sender.py
aantn 0f3710f
Update sender.py
aantn cdec3f7
Update sender.py
aantn 7ff23d6
Update sender.py
aantn 26ed319
Update sender.py
aantn ef3214d
Update sender.py
aantn d79a00d
Update sender.py
aantn 64bafc5
Update sender.py
aantn 787846a
incorporate feedback from igor
aantn c693938
Merge branch 'master' into claude-slack
aantn d72e001
add templating
aantn c4866c3
remove unused code
aantn 092f0c8
add logs
aantn 8c1a9a8
simplify code - always use jinja
aantn 9b15ca1
add legacy option
aantn 6bafca4
Merge branch 'master' into claude-slack
Avi-Robusta 9281648
bugfix sending to slack
Avi-Robusta 92c1b76
fixing template
Avi-Robusta 4e6b055
refactoring code
Avi-Robusta abe1c74
saving progress
Avi-Robusta cca0d57
added tests
Avi-Robusta ea81979
refactoring changes
Avi-Robusta 5df775d
misc changes
Avi-Robusta ed0178c
changess
Avi-Robusta 567372c
working version
Avi-Robusta 317fbf4
refactor send finding to slack
Avi-Robusta bb5d1c2
added space
Avi-Robusta 181adc1
removing unneeded code atm
Avi-Robusta d4a85a1
refactor
Avi-Robusta edd0cbd
fixing
Avi-Robusta 4650e18
docs update
Avi-Robusta ba20164
updated tests
Avi-Robusta c468f5a
bugfixes and header support
Avi-Robusta fa8a68e
fixed mentions
Avi-Robusta fcad848
added channel override test
Avi-Robusta b1dda3b
refactoring, removing useless changes
Avi-Robusta a73bf41
Merge branch 'master' into claude-slack
Avi-Robusta 3c1f709
refactoring sender
Avi-Robusta 57f094c
remove unneeded code
Avi-Robusta 7b9daf2
added additional features
Avi-Robusta 6546ba5
changed manual tests
Avi-Robusta 640ae37
add aggregation key
Avi-Robusta 1a7ee23
pr changes
Avi-Robusta e5094c4
added fingerprint to template
Avi-Robusta 24d32c7
Merge branch 'master' into claude-slack
arikalon1 052d6f4
Merge branch 'master' into claude-slack
Avi-Robusta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from robusta.core.sinks.slack.preview.slack_sink_preview import SlackSinkPreview | ||
| from robusta.core.sinks.slack.preview.slack_sink_params_preview import SlackSinkPreviewConfigWrapper, SlackSinkPreviewParams |
14 changes: 14 additions & 0 deletions
14
src/robusta/core/sinks/slack/preview/slack_sink_preview.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from robusta.core.sinks.slack.preview.slack_sink_preview_params import SlackSinkPreviewConfigWrapper, SlackSinkPreviewParams | ||
| from robusta.core.sinks.slack.slack_sink import SlackSink | ||
| from robusta.integrations import slack as slack_module | ||
|
|
||
|
|
||
| class SlackSinkPreview(SlackSink): | ||
| params: SlackSinkPreviewParams | ||
|
|
||
| def __init__(self, sink_config: SlackSinkPreviewConfigWrapper, registry): | ||
| self.slack_sender = slack_module.SlackSender( | ||
| self.api_key, self.account_id, self.cluster_name, self.signing_key, self.slack_channel, is_preview=True | ||
| ) | ||
| super().__init__(sink_config.slack_sink, registry, self.slack_sender) | ||
|
|
||
43 changes: 43 additions & 0 deletions
43
src/robusta/core/sinks/slack/preview/slack_sink_preview_params.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| from robusta.core.sinks.sink_base_params import SinkBaseParams | ||
| from robusta.core.sinks.sink_config import SinkConfigBase | ||
| from robusta.core.sinks.slack import SlackSinkParams | ||
| from enum import Enum | ||
| from typing import Optional, Dict | ||
|
|
||
|
|
||
| class SlackTemplateStyle(str, Enum): | ||
| DEFAULT = "default" | ||
| LEGACY = "legacy" | ||
|
|
||
|
|
||
| class SlackSinkPreviewParams(SlackSinkParams): | ||
| template_style: SlackTemplateStyle = SlackTemplateStyle.DEFAULT # Use "legacy" for old-style formatting | ||
| slack_custom_templates: Optional[Dict[str, str]] = None # Template name -> custom template content | ||
| template_name: Optional[str] = None | ||
|
|
||
|
Avi-Robusta marked this conversation as resolved.
|
||
| def get_effective_template_name(self) -> str: | ||
| """ | ||
| Returns the template name to use for this sink. If template_name is set, use it. | ||
| Otherwise, use 'legacy.j2' if template_style is legacy, else 'header.j2'. | ||
| """ | ||
| if self.template_name: | ||
| return self.template_name | ||
| if self.template_style == SlackTemplateStyle.LEGACY: | ||
| return "legacy.j2" | ||
| return "header.j2" | ||
|
|
||
| def get_custom_template(self) -> Optional[str]: | ||
| """ | ||
| Returns the custom template string for the effective template name, if it exists. | ||
| """ | ||
| template_name = self.get_effective_template_name() | ||
| if self.slack_custom_templates and template_name in self.slack_custom_templates: | ||
| return self.slack_custom_templates[template_name] | ||
| return None | ||
|
|
||
|
|
||
| class SlackSinkPreviewConfigWrapper(SinkConfigBase): | ||
| slack_sink: SlackSinkPreviewParams | ||
|
|
||
| def get_params(self) -> SinkBaseParams: | ||
| return self.slack_sink | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.