Skip to content

Commit 8b0c29e

Browse files
committed
feat: add new discord fields
This adds the functionality to configure the discord message content, username and avatar_url.
1 parent c2af71c commit 8b0c29e

File tree

16 files changed

+236
-0
lines changed

16 files changed

+236
-0
lines changed

Diff for: Documentation/api-reference/api.md

+68
Original file line numberDiff line numberDiff line change
@@ -21827,6 +21827,40 @@ HTTPConfig
2182721827
<p>HTTP client configuration.</p>
2182821828
</td>
2182921829
</tr>
21830+
<tr>
21831+
<td>
21832+
<code>content</code><br/>
21833+
<em>
21834+
string
21835+
</em>
21836+
</td>
21837+
<td>
21838+
<em>(Optional)</em>
21839+
<p>The template of the content&rsquo;s body.</p>
21840+
</td>
21841+
</tr>
21842+
<tr>
21843+
<td>
21844+
<code>username</code><br/>
21845+
<em>
21846+
string
21847+
</em>
21848+
</td>
21849+
<td>
21850+
<em>(Optional)</em>
21851+
</td>
21852+
</tr>
21853+
<tr>
21854+
<td>
21855+
<code>avatarURL</code><br/>
21856+
<em>
21857+
string
21858+
</em>
21859+
</td>
21860+
<td>
21861+
<em>(Optional)</em>
21862+
</td>
21863+
</tr>
2183021864
</tbody>
2183121865
</table>
2183221866
<h3 id="monitoring.coreos.com/v1alpha1.DockerSDConfig">DockerSDConfig
@@ -31681,6 +31715,40 @@ HTTPConfig
3168131715
<p>HTTP client configuration.</p>
3168231716
</td>
3168331717
</tr>
31718+
<tr>
31719+
<td>
31720+
<code>content</code><br/>
31721+
<em>
31722+
string
31723+
</em>
31724+
</td>
31725+
<td>
31726+
<em>(Optional)</em>
31727+
<p>The template of the content&rsquo;s body.</p>
31728+
</td>
31729+
</tr>
31730+
<tr>
31731+
<td>
31732+
<code>username</code><br/>
31733+
<em>
31734+
string
31735+
</em>
31736+
</td>
31737+
<td>
31738+
<em>(Optional)</em>
31739+
</td>
31740+
</tr>
31741+
<tr>
31742+
<td>
31743+
<code>avatarURL</code><br/>
31744+
<em>
31745+
string
31746+
</em>
31747+
</td>
31748+
<td>
31749+
<em>(Optional)</em>
31750+
</td>
31751+
</tr>
3168431752
</tbody>
3168531753
</table>
3168631754
<h3 id="monitoring.coreos.com/v1beta1.EmailConfig">EmailConfig

Diff for: bundle.yaml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: example/prometheus-operator-crd-full/monitoring.coreos.com_alertmanagerconfigs.yaml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: jsonnet/prometheus-operator/alertmanagerconfigs-crd.json

+10
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@
262262
"type": "object",
263263
"x-kubernetes-map-type": "atomic"
264264
},
265+
"avatarURL": {
266+
"type": "string"
267+
},
268+
"content": {
269+
"description": "The template of the content's body.",
270+
"type": "string"
271+
},
265272
"httpConfig": {
266273
"description": "HTTP client configuration.",
267274
"properties": {
@@ -910,6 +917,9 @@
910917
"title": {
911918
"description": "The template of the message's title.",
912919
"type": "string"
920+
},
921+
"username": {
922+
"type": "string"
913923
}
914924
},
915925
"required": [

Diff for: jsonnet/prometheus-operator/alertmanagerconfigs-v1beta1-crd.libsonnet

+10
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@
134134
type: 'object',
135135
'x-kubernetes-map-type': 'atomic',
136136
},
137+
avatarURL: {
138+
type: 'string',
139+
},
140+
content: {
141+
description: "The template of the content's body.",
142+
type: 'string',
143+
},
137144
httpConfig: {
138145
description: 'HTTP client configuration.',
139146
properties: {
@@ -780,6 +787,9 @@
780787
description: "The template of the message's title.",
781788
type: 'string',
782789
},
790+
username: {
791+
type: 'string',
792+
},
783793
},
784794
required: [
785795
'apiURL',

Diff for: pkg/alertmanager/amcfg.go

+12
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,18 @@ func (cb *configBuilder) convertDiscordConfig(ctx context.Context, in monitoring
760760
out.Message = *in.Message
761761
}
762762

763+
if in.Content != nil && *in.Content != "" {
764+
out.Content = *in.Content
765+
}
766+
767+
if in.Username != nil && *in.Username != "" {
768+
out.Username = *in.Username
769+
}
770+
771+
if in.AvatarURL != nil && *in.AvatarURL != "" {
772+
out.AvatarURL = *in.AvatarURL
773+
}
774+
763775
url, err := cb.getValidURLFromSecret(ctx, crKey.Namespace, in.APIURL)
764776
if err != nil {
765777
return nil, err

Diff for: pkg/alertmanager/types.go

+3
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ type discordConfig struct {
367367
WebhookURL string `yaml:"webhook_url,omitempty"`
368368
Title string `yaml:"title,omitempty"`
369369
Message string `yaml:"message,omitempty"`
370+
Content string `yaml:"content,omitempty"`
371+
Username string `yaml:"username,omitempty"`
372+
AvatarURL string `yaml:"avatar_url,omitempty"`
370373
}
371374

372375
type webexConfig struct {

Diff for: pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go

+7
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,13 @@ type DiscordConfig struct {
299299
// HTTP client configuration.
300300
// +optional
301301
HTTPConfig *HTTPConfig `json:"httpConfig,omitempty"`
302+
// The template of the content's body.
303+
// +optional
304+
Content *string `json:"content,omitempty"`
305+
// +optional
306+
Username *string `json:"username,omitempty"`
307+
// +optional
308+
AvatarURL *string `json:"avatarURL,omitempty"`
302309
}
303310

304311
// SlackConfig configures notifications via Slack.

Diff for: pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pkg/apis/monitoring/v1beta1/alertmanager_config_types.go

+8
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,14 @@ type DiscordConfig struct {
295295
// HTTP client configuration.
296296
// +optional
297297
HTTPConfig *HTTPConfig `json:"httpConfig,omitempty"`
298+
299+
// The template of the content's body.
300+
// +optional
301+
Content *string `json:"content,omitempty"`
302+
// +optional
303+
Username *string `json:"username,omitempty"`
304+
// +optional
305+
AvatarURL *string `json:"avatarURL,omitempty"`
298306
}
299307

300308
// SlackConfig configures notifications via Slack.

Diff for: pkg/apis/monitoring/v1beta1/conversion_from.go

+3
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ func convertDiscordConfigFrom(in v1alpha1.DiscordConfig) DiscordConfig {
267267
Title: in.Title,
268268
Message: in.Message,
269269
SendResolved: in.SendResolved,
270+
Content: in.Content,
271+
Username: in.Username,
272+
AvatarURL: in.AvatarURL,
270273
}
271274
}
272275

Diff for: pkg/apis/monitoring/v1beta1/conversion_to.go

+3
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ func convertDiscordConfigTo(in DiscordConfig) v1alpha1.DiscordConfig {
263263
Title: in.Title,
264264
Message: in.Message,
265265
SendResolved: in.SendResolved,
266+
Content: in.Content,
267+
Username: in.Username,
268+
AvatarURL: in.AvatarURL,
266269
}
267270
}
268271

Diff for: pkg/apis/monitoring/v1beta1/zz_generated.deepcopy.go

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pkg/client/applyconfiguration/monitoring/v1alpha1/discordconfig.go

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)