Template Functions
Special template functions are made available on notifications to complex block formation easier.
labelsFormat
Formats the given set of labels into a markdown string
Syntax:
labelsFormat(map[string]any): string
Example:
labelsFormat(map[string]any{
	"namespace": "default",
	"cluster": "staging",
})
### Labels
**namespace**: default
**cluster**: staging
Slack
These slack helper functions will return a json string suitable for use in slack blocks/messages.
slackHealthEmoji
Returns a slack emoji based on the supplied health
Syntax:
slackHealthEmoji(health): string
Returns:
:large_green_circle:forhealthyhealth status:red_circle:forunhealthyhealth status:large_orange_circle:forwarninghealth status:white_circle:for any other health status
slackSectionLabels
Formats the given set of labels into fields of a slack section block
Syntax:
slackSectionLabels(map[string]any): SlackSection
Example:
slackSectionLabels(map[string]any{
	"namespace": "default",
	"cluster": "staging",
})
{
	"type": "section",
	"text": {
		"type": "mrkdwn",
		"text": "*Labels*"
	},
	"fields": [
		{
			"type": "mrkdwn",
			"text": "*namespace*: default",
			"verbatim": true
		},
		{
			"type": "mrkdwn",
			"text": "*cluster*: staging",
			"verbatim": true
		}
	]
}
slackSectionTextFieldPlain
Creates a plain text field for a Slack section block
Syntax:
slackSectionTextFieldPlain(text: string): string
Example:
slackSectionTextFieldPlain("alert-manager")
{
	"type": "plain_text",
	"text": "alert-manager"
}
slackSectionTextFieldMD
Creates a markdown text field for a Slack section block
Syntax:
slackSectionTextFieldMD(text: string): string
Example:
slackSectionTextFieldPlain("alert-manager")
{
	"type": "mrkdwn",
	"text": "alert-manager"
}
slackSectionTextMD
Creates a Slack section block with markdown text
Syntax:
slackSectionTextMD(text: string): string
Example:
slackSectionTextMD("alert-manager")
{
	"type": "section",
	"text": {
		"type": "mrkdwn",
		"text": "alert-manager"
	}
}
slackSectionTextPlain
Creates a Slack section block with plain text
Syntax:
slackSectionTextPlain(text: string): string
Example:
slackSectionTextMD("alert-manager")
{
	"type": "section",
	"text": {
		"type": "plain_text",
		"text": "alert-manager"
	}
}
SlackURLAction
Creates a Slack action block with a URL button
Syntax:
slackURLAction(name: string, url: string): string
Example:
slackURLAction("Grafana", "https://grafana.com")
{
	"type": "actions",
	"elements": [
		{
			"type": "button",
			"text": {
				"type": "plain_text",
				"text": "Grafana",
				"emoji": true
			},
			"url": "https://grafana.com",
			"action_id": "Grafana"
		}
	]
}