slack

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2023 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const FullValidConfigForTesting = `` /* 393-byte string literal not displayed */

FullValidConfigForTesting is a string representation of a JSON object that contains all fields supported by the notifier Config. It can be used without secrets.

View Source
const FullValidSecretsForTesting = `{
	"url": "http://localhost/url-secret",
	"token": "test-secret-token"
}`

FullValidSecretsForTesting is a string representation of JSON object that contains all fields that can be overridden from secrets

Variables

View Source
var APIURL = "https://slack.com/api/chat.postMessage"

APIURL of where the notification payload is sent. It is public to be overridable in integration tests.

Functions

This section is empty.

Types

type Config

type Config struct {
	EndpointURL    string                          `json:"endpointUrl,omitempty" yaml:"endpointUrl,omitempty"`
	URL            string                          `json:"url,omitempty" yaml:"url,omitempty"`
	Token          string                          `json:"token,omitempty" yaml:"token,omitempty"`
	Recipient      string                          `json:"recipient,omitempty" yaml:"recipient,omitempty"`
	Text           string                          `json:"text,omitempty" yaml:"text,omitempty"`
	Title          string                          `json:"title,omitempty" yaml:"title,omitempty"`
	Username       string                          `json:"username,omitempty" yaml:"username,omitempty"`
	IconEmoji      string                          `json:"icon_emoji,omitempty" yaml:"icon_emoji,omitempty"`
	IconURL        string                          `json:"icon_url,omitempty" yaml:"icon_url,omitempty"`
	MentionChannel string                          `json:"mentionChannel,omitempty" yaml:"mentionChannel,omitempty"`
	MentionUsers   receivers.CommaSeparatedStrings `json:"mentionUsers,omitempty" yaml:"mentionUsers,omitempty"`
	MentionGroups  receivers.CommaSeparatedStrings `json:"mentionGroups,omitempty" yaml:"mentionGroups,omitempty"`
}

func NewConfig

func NewConfig(jsonData json.RawMessage, decryptFn receivers.DecryptFunc) (Config, error)

type Notifier

type Notifier struct {
	*receivers.Base
	// contains filtered or unexported fields
}

Notifier is responsible for sending alert notification to Slack.

func New

func New(cfg Config, meta receivers.Metadata, template *templates.Template, sender receivers.WebhookSender, images images.Provider, logger logging.Logger, appVersion string) *Notifier

func (*Notifier) Notify

func (sn *Notifier) Notify(ctx context.Context, alerts ...*types.Alert) (bool, error)

Notify sends an alert notification to Slack.

func (*Notifier) SendResolved

func (sn *Notifier) SendResolved() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL