55
66import requests
77
8+ from robusta .core .reporting import TableBlock , FileBlock
89from robusta .core .reporting import HeaderBlock , JsonBlock , KubernetesDiffBlock , ListBlock , MarkdownBlock
910from robusta .core .reporting .base import BaseBlock , Finding
1011from 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 } " )
0 commit comments