slack

package
v0.0.1-0...-8535732 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package slack handles interfacing with the Slack API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSlackComplete

func IsSlackComplete(slackStatus Status) bool

IsSlackComplete once a slack status has reached any of these states it will require no more updates.

Types

type Slacker

type Slacker interface {
	PostMessage(options ...slack.MsgOption) error
	PostMessageToUser(user *slack.User, options ...slack.MsgOption) error
	LookupUser(email string) (*slack.User, bool)
}

Slacker represents a type that can interact with the Slack API.

func New

func New(cfg *config.SlackConfig) (Slacker, error)

New creates a new Slack client that uses the given token for authentication.

type Status

type Status string

Status represents which lifecycle stage a cluster has most recently sent a slack message for.

const (
	// StatusSkip is for when cluster should not result in Slack messages.
	StatusSkip Status = "skip"

	// StatusFailed is for when a cluster has failed.
	StatusFailed Status = "failed"

	// StatusDestroyed is for when a cluster is being deleted.
	StatusDestroyed Status = "destroyed"

	// StatusReady is for when a cluster is ready.
	StatusReady Status = "ready"

	// StatusNearingExpiry is for when a cluster is close to expiry.
	StatusNearingExpiry Status = "nearing_expiry"

	// StatusCreating is for when a cluster is being created.
	StatusCreating Status = "creating"
)

func FormatSlackMessage

func FormatSlackMessage(wfStatus v1.Status, clusterIsNearingExpiry bool, slackStatus Status, contextData TemplateData) (Status, []slack.MsgOption)

FormatSlackMessage formats the correct Slack message given the current cluster state.

type TemplateData

type TemplateData struct {
	Description    string
	Flavor         string
	ID             string
	Remaining      string
	Scheduled      bool
	URL            string
	OwnerEmail     string
	OwnerID        string
	FailureDetails string
}

TemplateData represents the available context that is passed when executing Slack message templates.

Jump to

Keyboard shortcuts

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