8000 feat: Add new discord message fields by junaidk · Pull Request #7307 · prometheus-operator/prometheus-operator · GitHub
[go: up one dir, main page]

Skip to content

Conversation

junaidk
Copy link
Contributor
@junaidk junaidk commented Jan 30, 2025

Description

This adds the functionality to configure the discord message content, username and avatar_url introduced in alertmanager release v0.28.0.

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.)

Verification

Please check the Prometheus-Operator testing guidelines for recommendations about automated tests.

Changelog entry

Add discord message content, username and avatar_url fields introduced in alertmanager v0.28.0

@junaidk junaidk requested a review from a team as a code owner January 30, 2025 12:45
Copy link
Contributor
@slashpai slashpai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR

You will also need to add unit tests

// HTTP client configuration.
// +optional
HTTPConfig *HTTPConfig `json:"httpConfig,omitempty"`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove blank line

@junaidk
Copy link
Contributor Author
junaidk commented Jan 31, 2025

Thanks for the PR

You will also need to add unit tests

I have added unit tests for related code.

@slashpai
Copy link
Contributor
slashpai commented Feb 3, 2025

I guess you added only golden files, you also need to write testcases see #7310 for eg

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to reset the fields in *discordConfig.sanitize() if the version isn't >= v0.28.0.

@slashpai
Copy link
Contributor
slashpai commented Feb 3, 2025

Created #7313 to add only in am config secret

@junaidk
Copy link
Contributor Author
junaidk commented Feb 4, 2025

I guess you added only golden files, you also need to write testcases see #7310 for eg

Sorry, I forgot to add the changes in the commit.
I have added those changes now.

Comment on lines 298 to 304
// The template of the content's body.
// +optional
Content *string `json:"content,omitempty"`
// +optional
Username *string `json:"username,omitempty"`
// +optional
AvatarURL *string `json:"avatarURL,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same remarks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the suggestion.
I have incorporated it in code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @junaidk seems you added the kubebuilder checks only in v1beta1, missing for v1alpha1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.
I forgot to save and commit changes for v1alpha1.

@junaidk junaidk force-pushed the extend-discord-msg-content branch from 3de4b47 to eca6cca Compare February 5, 2025 03:20
@junaidk junaidk requested a review from slashpai February 14, 2025 14:43
@junaidk
Copy link
Contributor Author
junaidk commented Mar 3, 2025

Hi @simonpasquier
I have fixed all mentioned issue in the PR review.
Do you think there is still anything missing?

@junaidk
Copy link
Contributor Author
junaidk commented Mar 17, 2025

@slashpai and @simonpasquier can you also have a look again please.

@junaidk
Copy link
Contributor Author
junaidk commented Mar 27, 2025

@heliapb can you guide on how can I get this PR reviewed and merged.
it has been open since two months.

@heliapb
Copy link
Member
heliapb commented Mar 27, 2025

Hi @junaidk sure thing, let's see if the team has time to review it /cc @slashpai @simonpasquier when you have time please take a look. Thanks

Comment on lines 288 to 289
// +required
// +kubebuilder:validation:Required
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeated

Comment on lines 300 to 301
// +optional
// +kubebuilder:validation:Optional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Comment on lines 284 to 285
// +required
// +kubebuilder:validation:Required
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits

Comment on lines 307 to 308
// +kubebuilder:validation:MinLength=1
AvatarURL *string `json:"avatarURL,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// +kubebuilder:validation:MinLength=1
AvatarURL *string `json:"avatarURL,omitempty"`
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Pattern:="^http(s)?://.+$"
AvatarURL *string `json:"avatarURL,omitempty"`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. updated

Copy link
Contributor
@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

// +optional
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Pattern:="^http(s)?://.+$"
AvatarURL *string `json:"avatarURL,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can reuse the URL type in fact

Suggested change
AvatarURL *string `json:"avatarURL,omitempty"`
AvatarURL *URL `json:"avatarURL,omitempty"`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, updated


// HTTP client configuration.
// +optional
HTTPConfig *HTTPConfig `json:"httpConfig,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) can we keep the HTTPConfig field at the bottom of the struct definition?


// The template of the message's title.
// +optional
// +kubebuilder:validation:MinLength=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's discuss new validations on existing fields in a different PR

Suggested change
// +kubebuilder:validation:MinLength=1


// The template of the message's body.
// +optional
// +kubebuilder:validation:MinLength=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

out.Message = *in.Message
}

if in.Content != nil && *in.Content != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit)

Suggested change
if in.Content != nil && *in.Content != "" {
if ptr.Deref(in.Content, "") != "" {
67E5

Copy link
Contributor
@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@slashpai slashpai merged commit 42229a7 into prometheus-operator:main Apr 16, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0