Skip to content

Commit 155dd4e

Browse files
committed
Support sending text files and tables to the webhook sink
1 parent 03a3e11 commit 155dd4e

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/robusta/core/sinks/webhook/webhook_sink.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import requests
77

8+
from robusta.core.reporting import TableBlock, FileBlock
89
from robusta.core.reporting import HeaderBlock, JsonBlock, KubernetesDiffBlock, ListBlock, MarkdownBlock
910
from robusta.core.reporting.base import BaseBlock, Finding
1011
from robusta.core.sinks.sink_base import SinkBase
@@ -25,6 +26,8 @@ def __init__(self, sink_config: WebhookSinkConfigWrapper, registry):
2526
)
2627
self.size_limit = sink_config.webhook_sink.size_limit
2728
self.slack_webhook = sink_config.webhook_sink.slack_webhook
29+
self.send_table_block = sink_config.webhook_sink.table_blocks
30+
self.send_file_block = sink_config.webhook_sink.file_blocks
2831

2932
def write_finding(self, finding: Finding, platform_enabled: bool):
3033
if self.format == "text":
@@ -134,6 +137,10 @@ def __to_unformatted_text(cls, block: BaseBlock) -> List[str]:
134137
lines.append(cls.__to_clear_text(block.text))
135138
elif isinstance(block, JsonBlock):
136139
lines.append(block.json_str)
140+
elif isinstance(block, TableBlock) and cls.send_table_block:
141+
lines.append(block.to_table_string())
142+
elif isinstance(block, FileBlock) and cls.send_file_block and block.is_text_file():
143+
lines.append(str(block.contents))
137144
elif isinstance(block, KubernetesDiffBlock):
138145
for diff in block.diffs:
139146
lines.append(f"*{'.'.join(diff.path)}*: {diff.other_value} ==> {diff.value}")

src/robusta/core/sinks/webhook/webhook_sink_params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class WebhookSinkParams(SinkBaseParams):
1010
authorization: SecretStr = None
1111
format: str = "text"
1212
slack_webhook: bool = False
13+
table_blocks: bool = False
14+
file_blocks: bool = False
1315

1416
@classmethod
1517
def _get_sink_type(cls):

0 commit comments

Comments
 (0)