notifier

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

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

	SectionBlockType = "section"

	MarkdownTextType = "mrkdwn"
)

Variables

This section is empty.

Functions

This section is empty.

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 *iter8v1alpha2.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) RegisterHandler added in v0.1.0

func (nc *NotificationCenter) RegisterHandler(ctx context.Context, cache cache.Cache) error

RegisterHandler adds event handlers to k8s cache

type Notifier

type Notifier interface {
	// MakeRequest returns the platform-specific request instance
	MakeRequest(instance *iter8v1alpha2.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 *iter8v1alpha2.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