notify

package
v0.0.0-...-d8ef078 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotifyOn

func NotifyOn(filter NotifyFilter) notifyOptsFunc

func WithNotify

func WithNotify(notify NotifyType) notifyOptsFunc

func WithRepo

func WithRepo(repo Repo) repoOptFunc

func WithRepoBranch

func WithRepoBranch(branch string) repoOptFunc

func WithRepoName

func WithRepoName(name string) repoOptFunc

func WithSlackConfig

func WithSlackConfig(config *SlackConfig) notifyOptsFunc

Types

type Data

type Data struct {
	Runner     *runner.Runner
	Repo       *Repo
	ResultsURL string
}

func (Data) StatusColor

func (d Data) StatusColor() string

type NotifyFilter

type NotifyFilter string
const (
	NotifyFilterAll   NotifyFilter = "all"
	NotifyFilterDrift NotifyFilter = "drift"
)

func (NotifyFilter) IsValid

func (f NotifyFilter) IsValid() bool

IsValid checks that the given string for a notification is valid

func (NotifyFilter) ShouldNotify

func (f NotifyFilter) ShouldNotify(runner *runner.Runner) bool

ShouldNotify takes a runner and returns a bool whether the notification should be sent, or not

type NotifyType

type NotifyType string
const (
	NotifyTypeSlack NotifyType = "slack"
)

type Repo

type Repo struct {
	Name   string
	Branch string
}

func LookupRepo

func LookupRepo(opts ...repoOptFunc) (*Repo, error)

LookupRepo gets the repository data for the drift detection. It reads from environment variables (if set) otherwise fetches the information from the local git repository

type Service

type Service interface {
	Send(data *Data) error
}

func New

func New(opts ...notifyOptsFunc) (Service, error)

type SlackConfig

type SlackConfig struct {
	// Channel is the slack channel where to send the notification
	Channel string
	// Template is an optional string that will be templated into JSON for
	// Slack's message options.
	// A default template will be used if empty
	TemplateFile string
	// SkipAuthTest defines whether to skip the Slack auth test when creating
	// the service or not
	SkipAuthTest bool
}

func DefaultSlackConfig

func DefaultSlackConfig() *SlackConfig

Jump to

Keyboard shortcuts

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