notifier

package
v0.0.0-...-4232eae Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigMapName = "iter8config-notifiers"

	NotifierLevelVerbose = "verbose"
	NotifierLevelNormal  = "normal"
	NotifierLevelWarning = "warning"
	NotifierLevelError   = "error"
)
View Source
const (
	NotifierNameSlack = "slack"

	SectionBlockType = "section"

	MarkdownTextType = "mrkdwn"
)

Variables

This section is empty.

Functions

func RemoveNotifiers

func RemoveNotifiers(nc *NotificationCenter) func(obj interface{})

RemoveNotifiers will remove all the notifiers away

func UpdateConfigFromConfigmap

func UpdateConfigFromConfigmap(nc *NotificationCenter) func(obj interface{})

UpdateConfigFromConfigmap update notification

Types

type Attachment

type Attachment struct {
	Color  string  `json:"color"`
	Author string  `json:"author_name"`
	Fields []Field `json:"fields"`
	Text   string  `json:"text"`
	Ts     int64   `json:"ts"`
}

type Config

type Config struct {
	// Namespace speficies the namespace where experiments should be monitored
	Namespace string `yaml:"namespace,omitempty"`

	// URL specifies the endpoint to send notification
	URL string `yaml:"url"`

	// NotifierName is the name of notification receiver
	Notifier string `yaml:"notifier"`

	// Level specifies the informative level
	Level string `yaml:"level"`

	// Actions lists the actions that user may want to take during the experiment
	Actions []string `yaml:"actions,omitempty"`

	// Labels are used to filter out the experiments for report
	Labels map[string]string `yaml:"labels,omitempty"`
}

Config defines the configuration used for a notifier channel

type ConfiguredNotifier

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

ConfiguredNotifier is the wrapper of the a notifier implementation and its configuration

type Field

type Field struct {
	Title string `json:"title"`
	Value string `json:"value"`
	Short bool   `json:"short"`
}

type MarkdownText

type MarkdownText struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type NotificationCenter

type NotificationCenter struct {
	Notifiers map[string]*ConfiguredNotifier
	// contains filtered or unexported fields
}

NotificationCenter is designed to send notifications to registered notifiers

func NewNotificationCenter

func NewNotificationCenter(logger logr.Logger) *NotificationCenter

NewNotificationCenter returns a new NotificationCenter

func (*NotificationCenter) Notify

func (nc *NotificationCenter) Notify(instance *iter8v1alpha1.Experiment, reason string, messageFormat string, messageA ...interface{})

Notify will generate notifications to all the matched notifier specified in the configs Errors occured will only be logged

func (*NotificationCenter) RemoveNotifier

func (nc *NotificationCenter) RemoveNotifier(name string)

RemoveNotifier will remove the notifier stored inside the center

func (*NotificationCenter) UpdateNotifier

func (nc *NotificationCenter) UpdateNotifier(name string, cfg *Config)

UpdateNotifier will update the notifier stored inside the center

type Notifier

type Notifier interface {
	// MakeRequest returns the platform-specific request instance
	MakeRequest(instance *iter8v1alpha1.Experiment, reason string, messageFormat string, messageA ...interface{}) interface{}
}

Notifier is the interface for notifier implementations

type SectionBlock

type SectionBlock struct {
	Type string       `json:"type"`
	Text MarkdownText `json:"text"`
}

type SlackRequest

type SlackRequest struct {
	Text        string         `json:"text"`
	Blocks      []SectionBlock `json:"blocks"`
	Attachments []Attachment   `json:"attachments"`
}

type SlackWebhook

type SlackWebhook struct{}

func NewSlackWebhook

func NewSlackWebhook() *SlackWebhook

func (*SlackWebhook) MakeRequest

func (s *SlackWebhook) MakeRequest(instance *iter8v1alpha1.Experiment, reason string, messageFormat string, messageA ...interface{}) interface{}

MakeRequest implements Notifier MakeRequest function

Jump to

Keyboard shortcuts

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