Skip to content

Commit

Permalink
Merge pull request #1275 from ashokhein/include-cluster-name
Browse files Browse the repository at this point in the history
Include cluster name in all alerts
  • Loading branch information
stefanprodan authored Oct 6, 2022
2 parents 1b2df99 + 4dbeec0 commit 7b6c37e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions pkg/controller/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ func (c *Controller) sendEventToWebhook(r *flaggerv1.Canary, eventType, template

func (c *Controller) alert(canary *flaggerv1.Canary, message string, metadata bool, severity flaggerv1.AlertSeverity) {
var fields []notifier.Field

if c.clusterName != "" {
fields = append(fields,
notifier.Field{
Name: "Cluster",
Value: c.clusterName,
},
)
}

if metadata {
fields = alertMetadata(canary, c.clusterName)
fields = alertMetadata(canary)
}

// send alert with the global notifier
Expand Down Expand Up @@ -173,18 +183,9 @@ func (c *Controller) alert(canary *flaggerv1.Canary, message string, metadata bo
}
}

func alertMetadata(canary *flaggerv1.Canary, cluster string) []notifier.Field {
func alertMetadata(canary *flaggerv1.Canary) []notifier.Field {
var fields []notifier.Field

if cluster != "" {
fields = append(fields,
notifier.Field{
Name: "Cluster",
Value: cluster,
},
)
}

fields = append(fields,
notifier.Field{
Name: "Target",
Expand Down

0 comments on commit 7b6c37e

Please sign in to comment.