Skip to content

Commit 8c2549c

Browse files
committed
add env var and use proxy if exists
1 parent d169b2b commit 8c2549c

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/robusta/core/model/env_vars.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def load_bool(env_var, default: bool):
7373

7474
SLACK_REQUEST_TIMEOUT = int(os.environ.get("SLACK_REQUEST_TIMEOUT", 90))
7575
SLACK_TABLE_COLUMNS_LIMIT = int(os.environ.get("SLACK_TABLE_COLUMNS_LIMIT", 3))
76+
SLACK_PROXY_URL = os.environ.get("SLACK_PROXY_URL") # proxy endpoint "https://api.robusta.dev/integrations/slack/postmessage"
7677
DISCORD_TABLE_COLUMNS_LIMIT = int(os.environ.get("DISCORD_TABLE_COLUMNS_LIMIT", 4))
7778
RSA_KEYS_PATH = os.environ.get("RSA_KEYS_PATH", "/etc/robusta/auth")
7879

src/robusta/integrations/slack/sender.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
HOLMES_ENABLED,
2121
SLACK_REQUEST_TIMEOUT,
2222
SLACK_TABLE_COLUMNS_LIMIT,
23+
SLACK_PROXY_URL,
2324
)
2425
from robusta.core.reporting.base import Emojis, EnrichmentType, Finding, FindingStatus, LinkType
2526
from robusta.core.reporting.blocks import (
@@ -77,21 +78,26 @@ def __init__(self, slack_token: str, account_id: str, cluster_name: str, signing
7778
ssl=ssl_context,
7879
timeout=SLACK_REQUEST_TIMEOUT,
7980
retry_handlers=all_builtin_retry_handlers(),
81+
proxy=SLACK_PROXY_URL
8082
)
83+
if SLACK_PROXY_URL:
84+
logging.info(f"Slack client configured to use proxy: {SLACK_PROXY_URL}")
85+
8186
self.registry = registry
8287
self.signing_key = signing_key
8388
self.account_id = account_id
8489
self.cluster_name = cluster_name
8590
self.is_preview = is_preview
8691
self.disable_holmes_note = disable_holmes_note
8792

88-
if slack_token not in self.verified_api_tokens:
89-
try:
90-
self.slack_client.auth_test()
91-
self.verified_api_tokens.add(slack_token)
92-
except SlackApiError as e:
93-
logging.error(f"Cannot connect to Slack API: {e}")
94-
raise e
93+
if SLACK_PROXY_URL is None:
94+
if slack_token not in self.verified_api_tokens:
95+
try:
96+
self.slack_client.auth_test()
97+
self.verified_api_tokens.add(slack_token)
98+
except SlackApiError as e:
99+
logging.error(f"Cannot connect to Slack API: {e}")
100+
raise e
95101

96102
def __slack_preview_sanitize_string(self, text: str) -> str:
97103
"""

0 commit comments

Comments
 (0)