slack

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channels added in v1.12.0

type Channels struct {
	InfoChannel       string `envconfig:"SLACK_INFO_CHANNEL"`
	WarningChannel    string `envconfig:"SLACK_WARNING_CHANNEL"`
	AlarmChannel      string `envconfig:"SLACK_ALARM_CHANNEL"`
	PublishLogChannel string `envconfig:"SLACK_PUBLISH_LOG_CHANNEL"`
}

Channels holds the Slack channel names for different notification levels

type Client added in v1.12.0

type Client struct {
	// contains filtered or unexported fields
}

Client is a wrapper around the go-slack client

func (*Client) SendAlarm added in v1.12.0

func (c *Client) SendAlarm(ctx context.Context, summary string, err error, fields []Field) (*MessageRef, error)

SendAlarm sends an error notification to the configured Slack alarm channel.

func (*Client) SendInfo added in v1.12.0

func (c *Client) SendInfo(ctx context.Context, summary string, fields []Field) (*MessageRef, error)

SendInfo sends an info notification to the configured Slack info channel.

func (*Client) SendPublishLog added in v1.20.0

func (c *Client) SendPublishLog(ctx context.Context, summary string, fields []Field) (*MessageRef, error)

SendPublishLog sends a publish log notification to the configured Slack publish log channel.

func (*Client) SendWarning added in v1.12.0

func (c *Client) SendWarning(ctx context.Context, summary string, fields []Field) (*MessageRef, error)

SendWarning sends a warning notification to the configured Slack warning channel.

func (*Client) UpdatePublishLog added in v1.20.0

func (c *Client) UpdatePublishLog(ctx context.Context, ref *MessageRef, summary string, fields []Field) (*MessageRef, error)

UpdatePublishLog updates a previously sent publish log message. The colour is set to green as we assume that a publish log is only updated when the publish is successful.

func (*Client) UpdatePublishLogAsAlarm added in v1.21.0

func (c *Client) UpdatePublishLogAsAlarm(ctx context.Context, ref *MessageRef, summary string, fields []Field) (*MessageRef, error)

UpdatePublishLogAsAlarm updates a previously sent publish log message as a red alarm, used when one or more content items failed to publish.

type Clienter added in v1.12.0

type Clienter interface {
	SendAlarm(ctx context.Context, summary string, err error, fields []Field) (*MessageRef, error)
	SendWarning(ctx context.Context, summary string, fields []Field) (*MessageRef, error)
	SendInfo(ctx context.Context, summary string, fields []Field) (*MessageRef, error)
	SendPublishLog(ctx context.Context, summary string, fields []Field) (*MessageRef, error)
	UpdatePublishLog(ctx context.Context, ref *MessageRef, summary string, fields []Field) (*MessageRef, error)
	UpdatePublishLogAsAlarm(ctx context.Context, ref *MessageRef, summary string, fields []Field) (*MessageRef, error)
}

Clienter represents an interface for a generic Client

func New added in v1.12.0

func New(slackConfig *SlackConfig, apiToken string, enabled bool) (Clienter, error)

New returns a new Client if Slack notifications are enabled. If not enabled, it returns a NoopClient

type Colour added in v1.12.0

type Colour string
const (
	RedColour    Colour = "danger"
	YellowColour Colour = "warning"
	GreenColour  Colour = "good"
)

List of colours used in Slack attachments

func (Colour) String added in v1.12.0

func (c Colour) String() string

type Emoji added in v1.12.0

type Emoji string
const (
	InfoEmoji    Emoji = ":information_source:"
	WarningEmoji Emoji = ":warning:"
	AlarmEmoji   Emoji = ":rotating_light:"
	TimerEmoji   Emoji = ":hourglass_flowing_sand:"
	TickEmoji    Emoji = ":white_check_mark:"
)

List of custom emoji names used in Slack

func (Emoji) String added in v1.12.0

func (e Emoji) String() string

type Field added in v1.20.0

type Field struct {
	Title string
	Value string
}

Field represents a key-value pair to be included in the Slack message attachments.

type MessageRef added in v1.20.0

type MessageRef struct {
	ChannelID string
	Timestamp string
}

MessageRef represents a reference to a Slack message. It contains the channel ID and timestamp of the message, which can be used for updating the message later.

type NoopClient added in v1.12.0

type NoopClient struct{}

NoopClient is a Client that does nothing, used when Slack notifications are disabled

func (*NoopClient) SendAlarm added in v1.12.0

func (n *NoopClient) SendAlarm(ctx context.Context, summary string, err error, fields []Field) (*MessageRef, error)

func (*NoopClient) SendInfo added in v1.12.0

func (n *NoopClient) SendInfo(ctx context.Context, summary string, fields []Field) (*MessageRef, error)

func (*NoopClient) SendPublishLog added in v1.20.0

func (n *NoopClient) SendPublishLog(ctx context.Context, summary string, fields []Field) (*MessageRef, error)

func (*NoopClient) SendWarning added in v1.12.0

func (n *NoopClient) SendWarning(ctx context.Context, summary string, fields []Field) (*MessageRef, error)

func (*NoopClient) UpdatePublishLog added in v1.20.0

func (n *NoopClient) UpdatePublishLog(ctx context.Context, ref *MessageRef, summary string, fields []Field) (*MessageRef, error)

func (*NoopClient) UpdatePublishLogAsAlarm added in v1.21.0

func (n *NoopClient) UpdatePublishLogAsAlarm(ctx context.Context, ref *MessageRef, summary string, fields []Field) (*MessageRef, error)

type SlackConfig

type SlackConfig struct {
	Channels Channels
}

SlackConfig holds configuration for sending Slack notifications

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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