-
Notifications
You must be signed in to change notification settings - Fork 260
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
Added support for webhook_url dynamic overriding using annotations (issue 1083) #1476
Conversation
* Created MsTeamsWebhookUrlTransformer to enable overriding the webhook_url using annotations from yaml files * Enhanced MsTeamsSender.send_finding_to_ms_teams to support overriding the webhook_url * Moved shared methods and logic from ChannelTransformer to BaseChannelTransformer
…rom test_channel_transformer.py
…-dev/robusta into issue-1083-dynamic-ms-teams-sink
…rom additional_env_vars * Added additional pytests for MsTeamsWebhookUrlTransformer to test_ms_teams_transformer.py file
def validate_url_or_get_env(cls, webhook_url: str, default_webhook_url: str) -> str: | ||
if URL_PATTERN.match(webhook_url): | ||
return webhook_url | ||
env_value = os.getenv(webhook_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add info logs here, in case the url matching is failed?
Also is there any reference to this url pattern ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RoiGlinik There is no reference to this url pattern as I composed it from different resources, but I added pytests with different valid and invalid urls.
Introduced the
webhook_override
attribute for ms_teams_sink, enabling the use of annotations from YAML files to dynamically override thewebhook_url
.Issue #1083.
If no such annotation exists, the default webhook will be used. If the annotation is found but its value
does not contain a valid URL, the system will search for an environmental variable with the name of the value in the
additional_env_vars
section of yourgenerated_values.yaml
file.Reason for using annotations instead of labels:
Annotations are used instead of labels because URLs can't be passed to labels (see comment for
MsTeamsWebhookUrlTransformer
insrc/robusta/core/sinks/msteams/msteams_webhook_tranformer.py
)