notify

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package notify provides experimental support for notifications providers.

Tracking issue: https://github.com/ubclaunchpad/inertia/issues/194

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color string

Color is used to represent message color for different states (i.e success, fail)

const (
	// Green for success messages
	Green Color = "good"
	// Yellow for warning messages
	Yellow Color = "warning"
	// Red for error messages
	Red Color = "danger"
)

type Message

type Message struct {
	Text  string `json:"text"`
	Color string `json:"color"`
}

Message builds the attachments content of Message

type MessageArray

type MessageArray struct {
	Attachments []Message `json:"attachments"`
}

MessageArray builds the json message to be posted to webhook

type Notifier

type Notifier interface {
	Notify(string, Options) error
	IsEqual(Notifier) bool
}

Notifier manages notifications

func NewSlackNotifier

func NewSlackNotifier(webhookURL string) Notifier

NewSlackNotifier creates a notifier with web hook url to slack channel. Passing it an empty url makes it a no-op notifier.

type Notifiers

type Notifiers []Notifier

Notifiers is a collection of notification targets

func (Notifiers) Exists

func (n Notifiers) Exists(nt Notifier) bool

Exists checks if the given notifier is already configured

func (Notifiers) Notify

func (n Notifiers) Notify(msg string, opts Options) error

Notify delivers a notification to all targets

type Options

type Options struct {
	Color Color
}

Options is used to configure formatting of notifications

type SlackNotifier

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

SlackNotifier represents slack notifications

func (*SlackNotifier) IsEqual

func (n *SlackNotifier) IsEqual(nt Notifier) bool

IsEqual implements Notifier by checking the provided notifier is a slack notifier and if it has the same hook URL

func (*SlackNotifier) Notify

func (n *SlackNotifier) Notify(text string, options Options) error

Notify sends the notification

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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