Skip to content
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

support discord #185

Merged
merged 1 commit into from
Jan 6, 2023
Merged

support discord #185

merged 1 commit into from
Jan 6, 2023

Conversation

Gentleelephant
Copy link
Collaborator

Signed-off-by: Gentleelephant birdhk@kubesphere.io

MentionedRoles []string `json:"mentionedRoles,omitempty"`

// DiscordConfigSelector to be selected for this receiver
DiscordConfigSelector *metav1.LabelSelector `json:"webhookConfigSelector,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

The discord has no config, no need for this.

Type *string `json:"type,omitempty"`
MentionedUsers []string `json:"mentionedUsers,omitempty"`
MentionedRoles []string `json:"mentionedRoles,omitempty"`
*Config
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for this.

r.Webhook = discord.Webhook
}

r.ResourceVersion, _ = strconv.ParseUint(obj.ResourceVersion, 10, 64)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of ResourceVersion?

}

if utils.StringIsNil(n.receiver.TmplName) {
if tmplName != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the content and embed messages use the same template?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes,they only differ in the display.
content:
image
embed:
image

code := resp.StatusCode
level.Debug(n.logger).Log("msg", "DiscordNotifier", "response code:", code)

if code != http.StatusNoContent {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the discord server return a 204 for sending successfully, not 200?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes
image

}()

retry := 0
for {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will it retry infinitely under extreme conditions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should we limit the number of times?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes

Copy link
Collaborator

Choose a reason for hiding this comment

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

120 is too large, I think 3 is more suitable.

}

func (r *Receiver) SetConfig(c internal.Config) {
if reflect2.IsNil(c) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just return, no need to add this if statement.

}

func (c *Config) Clone() internal.Config {
return &Config{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just return.

}()

retry := 0
for {
Copy link
Collaborator

Choose a reason for hiding this comment

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

120 is too large, I think 3 is more suitable.

Signed-off-by: Gentleelephant <birdhk@kubesphere.io>

support discord

Signed-off-by: Gentleelephant <birdhk@kubesphere.io>
@benjaminhuo benjaminhuo merged commit 14d44f0 into kubesphere:master Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants