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
Add Telegram Receiver type to AlertmanagerConfig CRD #4726
Add Telegram Receiver type to AlertmanagerConfig CRD #4726
Conversation
20d8a02
to
432aaaa
Compare
6783b9f
to
7ef6c27
Compare
@philipgough i did the changes mentioned above :) |
// +optional | ||
DisableNotifications *bool `json:"disableNotifications,omitempty"` | ||
// Parse mode for telegram message | ||
//+kubebuilder:validation:Enum="";MarkdownV2;Markdown;HTML |
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.
nit: since this is marked as optional, I don't believe we need to include the empty string in the enum
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.
Ye! I was having doubts with the enum, I looked for examples in the project and I found:
https://github.com/prometheus-operator/prometheus-operator/blob/main/pkg/apis/monitoring/v1/thanos_types.go#L145
So I decided to leave it with the empty value as it is a valid value documented: https://prometheus.io/docs/alerting/latest/configuration/#telegram_config
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.
Still, if you think it could be better to remove it... let me know and I'll do it
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.
I did a quick test and indeed the Kube API makes a distinction between
- "the field is not present in the submitted request" ✔️
- "the field is present and the value is empty" 🚫
- "the field is present and the value is in the enums list" ✔️
From an API perspective, it's probably better to remove "" from the allowed values but we can tackle in a follow-up PR and globally.
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.
/lgtm
thanks @angelbarrera92 for the contribution.
@simonpasquier - do you want to take a look before we merge?
// +optional | ||
DisableNotifications *bool `json:"disableNotifications,omitempty"` | ||
// Parse mode for telegram message | ||
//+kubebuilder:validation:Enum="";MarkdownV2;Markdown;HTML |
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.
I did a quick test and indeed the Kube API makes a distinction between
- "the field is not present in the submitted request" ✔️
- "the field is present and the value is empty" 🚫
- "the field is present and the value is in the enums list" ✔️
From an API perspective, it's probably better to remove "" from the allowed values but we can tackle in a follow-up PR and globally.
I think I resolved all the points @simonpasquier raised, so asking for a new review round! |
Maybe I can do a rebase to squash all commits before merging. What do you think? |
We can "Squash and merge" from the GitHub UI :) |
@angelbarrera92 - thanks for taking care of this. Looks in good shape now but needs a rebase :) |
a9d8d4d
to
f2c3d14
Compare
Ready! |
Guys please merge this! ⏳ |
This commit adds the logic to enable the usage of telegram as receiver for alertmanger Fixes: prometheus-operator#4703
Changes chatID from secret to int and adds a check for the alertmanager version Fixes: prometheus-operator#4703
Moves parseMode to be an enum in the telegram configuration. Fixes: prometheus-operator#4703
Removes not needed validation as the input is validated with the openAPI schema Fixes: prometheus-operator#4703
change errors -> fmt Co-authored-by: Simon Pasquier <spasquie@redhat.com>
change errors -> fmt Co-authored-by: Simon Pasquier <spasquie@redhat.com>
change error message as suggested Co-authored-by: Simon Pasquier <spasquie@redhat.com>
check if exists config before checking the version Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Move botToken and chatID validation to sanitize function
change unused kubebuilder attributes
f2c3d14
to
f6cbd01
Compare
Description
Add Telegram Receiver type to AlertmanagerConfig CRD
Fixes #4703
There are a few things to consider while using this new feature:
Type of change
CHANGE
(fix or feature that would cause existing functionality to not work as expected)FEATURE
(non-breaking change which adds functionality)BUGFIX
(non-breaking change which fixes an issue)ENHANCEMENT
(non-breaking change which improves existing functionality)NONE
(if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)Changelog entry
Add Telegram Receiver type to AlertmanagerConfig CRD