notifier

package
v0.0.0-...-2d2e921 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const NotificationHeader = "gotk-component"

NotificationHeader is a header sent to identify requests from the notification controller.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertManagerAlert

type AlertManagerAlert struct {
	Status      string            `json:"status"`
	Labels      map[string]string `json:"labels"`
	Annotations map[string]string `json:"annotations"`
}

type Alertmanager

type Alertmanager struct {
	URL      string
	ProxyURL string
	CertPool *x509.CertPool
}

func NewAlertmanager

func NewAlertmanager(hookURL string, proxyURL string, certPool *x509.CertPool) (*Alertmanager, error)

func (*Alertmanager) Post

func (s *Alertmanager) Post(ctx context.Context, event eventv1.Event) error

type AzureDevOps

type AzureDevOps struct {
	Project     string
	Repo        string
	ProviderUID string
	Client      azureDevOpsClient
}

AzureDevOps is an Azure DevOps notifier.

func NewAzureDevOps

func NewAzureDevOps(providerUID string, addr string, token string, certPool *x509.CertPool) (*AzureDevOps, error)

NewAzureDevOps creates and returns a new AzureDevOps notifier.

func (AzureDevOps) Post

func (a AzureDevOps) Post(ctx context.Context, event eventv1.Event) error

Post Azure DevOps commit status

type AzureEventHub

type AzureEventHub struct {
	Hub *eventhub.Hub
}

AzureEventHub holds the eventhub client

func NewAzureEventHub

func NewAzureEventHub(endpointURL, token, eventHubNamespace string) (*AzureEventHub, error)

NewAzureEventHub creates a eventhub client

func (*AzureEventHub) Post

func (e *AzureEventHub) Post(ctx context.Context, event eventv1.Event) error

Post all notification-controller messages to EventHub

type Bitbucket

type Bitbucket struct {
	Owner       string
	Repo        string
	ProviderUID string
	Client      *bitbucket.Client
}

Bitbucket is a Bitbucket Server notifier.

func NewBitbucket

func NewBitbucket(providerUID string, addr string, token string, certPool *x509.CertPool) (*Bitbucket, error)

NewBitbucket creates and returns a new Bitbucket notifier.

func (Bitbucket) Post

func (b Bitbucket) Post(ctx context.Context, event eventv1.Event) error

Post Bitbucket commit status

type DataDog

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

func NewDataDog

func NewDataDog(address string, proxyUrl string, certPool *x509.CertPool, token string) (*DataDog, error)

NewDataDog creates a new DataDog provider by mapping the notification provider API to sensible values for the DataDog API. url: The DataDog API endpoint to use. Examples: https://api.datadoghq.com, https://api.datadoghq.eu, etc. token: The DataDog API key (not the application key). headers: A map of extra tags to add to the event

func (*DataDog) Post

func (d *DataDog) Post(ctx context.Context, event eventv1.Event) error

type Discord

type Discord struct {
	URL      string
	ProxyURL string
	Username string
	Channel  string
}

Discord holds the hook URL

func NewDiscord

func NewDiscord(hookURL string, proxyURL string, username string, channel string) (*Discord, error)

NewDiscord validates the URL and returns a Discord object

func (*Discord) Post

func (s *Discord) Post(ctx context.Context, event eventv1.Event) error

Post Discord message

type Factory

type Factory struct {
	URL         string
	ProxyURL    string
	Username    string
	Channel     string
	Token       string
	Headers     map[string]string
	CertPool    *x509.CertPool
	Password    string
	ProviderUID string
}

func NewFactory

func NewFactory(url string,
	proxy string,
	username string,
	channel string,
	token string,
	headers map[string]string,
	certPool *x509.CertPool,
	password string,
	providerUID string) *Factory

func (Factory) Notifier

func (f Factory) Notifier(provider string) (Interface, error)

type Forwarder

type Forwarder struct {
	URL      string
	ProxyURL string
	Headers  map[string]string
	CertPool *x509.CertPool
	HMACKey  []byte
}

Forwarder is an implementation of the notification Interface that posts the body as an HTTP request using an optional proxy.

func NewForwarder

func NewForwarder(hookURL string, proxyURL string, headers map[string]string, certPool *x509.CertPool, hmacKey []byte) (*Forwarder, error)

func (*Forwarder) Post

func (f *Forwarder) Post(ctx context.Context, event eventv1.Event) error

type GitHub

type GitHub struct {
	Owner       string
	Repo        string
	ProviderUID string
	Client      *github.Client
}

func NewGitHub

func NewGitHub(providerUID string, addr string, token string, certPool *x509.CertPool) (*GitHub, error)

func (*GitHub) Post

func (g *GitHub) Post(ctx context.Context, event eventv1.Event) error

Post Github commit status

type GitHubDispatch

type GitHubDispatch struct {
	Owner  string
	Repo   string
	Client *github.Client
}

func NewGitHubDispatch

func NewGitHubDispatch(addr string, token string, certPool *x509.CertPool) (*GitHubDispatch, error)

func (*GitHubDispatch) Post

func (g *GitHubDispatch) Post(ctx context.Context, event eventv1.Event) error

Post GitHub Repository Dispatch webhook

type GitLab

type GitLab struct {
	Id          string
	ProviderUID string
	Client      *gitlab.Client
}

func NewGitLab

func NewGitLab(providerUID string, addr string, token string, certPool *x509.CertPool) (*GitLab, error)

func (*GitLab) Post

func (g *GitLab) Post(ctx context.Context, event eventv1.Event) error

Post GitLab commit status

type Gitea

type Gitea struct {
	BaseURL     string
	Token       string
	Owner       string
	Repo        string
	ProviderUID string
	Client      *gitea.Client
	Debug       bool
}

func NewGitea

func NewGitea(providerUID string, addr string, token string, certPool *x509.CertPool) (*Gitea, error)

func (*Gitea) Post

func (g *Gitea) Post(ctx context.Context, event eventv1.Event) error

type GoogleChat

type GoogleChat struct {
	URL      string
	ProxyURL string
	Username string
	Channel  string
}

Slack holds the hook URL

func NewGoogleChat

func NewGoogleChat(hookURL string, proxyURL string) (*GoogleChat, error)

NewGoogleChat validates the Google Chat URL and returns a GoogleChat object

func (*GoogleChat) Post

func (s *GoogleChat) Post(ctx context.Context, event eventv1.Event) error

Post Google Chat message

type GoogleChatCard

type GoogleChatCard struct {
	Header   GoogleChatCardHeader    `json:"header"`
	Sections []GoogleChatCardSection `json:"sections"`
}

type GoogleChatCardHeader

type GoogleChatCardHeader struct {
	Title      string  `json:"title"`
	SubTitle   string  `json:"subtitle"`
	ImageUrl   *string `json:"imageUrl"`
	ImageStyle *string `json:"imageStyle"`
}

type GoogleChatCardSection

type GoogleChatCardSection struct {
	Header  string                 `json:"header"`
	Widgets []GoogleChatCardWidget `json:"widgets"`
}

type GoogleChatCardWidget

type GoogleChatCardWidget struct {
	TextParagraph *GoogleChatCardWidgetTextParagraph `json:"textParagraph"`
	KeyValue      *GoogleChatCardWidgetKeyValue      `json:"keyValue"`
}

type GoogleChatCardWidgetKeyValue

type GoogleChatCardWidgetKeyValue struct {
	TopLabel         string  `json:"topLabel"`
	Content          string  `json:"content"`
	ContentMultiLine bool    `json:"contentMultiline"`
	BottomLabel      *string `json:"bottomLabel"`
	Icon             *string `json:"icon"`
}

type GoogleChatCardWidgetTextParagraph

type GoogleChatCardWidgetTextParagraph struct {
	Text string `json:"text"`
}

type GoogleChatPayload

type GoogleChatPayload struct {
	Cards []GoogleChatCard `json:"cards"`
}

GoogleChatPayload holds the channel and attachments

type GooglePubSub

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

GooglePubSub holds a Google Pub/Sub client and target topic.

func NewGooglePubSub

func NewGooglePubSub(projectID, topicID, jsonCreds string, attrs map[string]string) (*GooglePubSub, error)

NewGooglePubSub creates a Google Pub/Sub client tied to a specific project and topic.

The jsonCreds parameter is optional, and if len(jsonCreds) == 0 then the automatic authentication methods of the Google libraries will take place, and therefore methods like Workload Identity will be automatically attempted.

The attrs paramter is optional, and if len(attrs) == 0 then no attributes will be added to the Pub/Sub message.

func (*GooglePubSub) Post

func (g *GooglePubSub) Post(ctx context.Context, event eventv1.Event) error

Post posts Flux events to a Google Pub/Sub topic.

type Grafana

type Grafana struct {
	URL      string
	Token    string
	ProxyURL string
	CertPool *x509.CertPool
	Username string
	Password string
}

func NewGrafana

func NewGrafana(URL string, proxyURL string, token string, certPool *x509.CertPool, username string, password string) (*Grafana, error)

NewGrafana validates the Grafana URL and returns a Grafana object

func (*Grafana) Post

func (g *Grafana) Post(ctx context.Context, event eventv1.Event) error

Post annotation

type GraphitePayload

type GraphitePayload struct {
	When int64    `json:"when"` //optional unix timestamp (ms)
	Text string   `json:"text"`
	Tags []string `json:"tags,omitempty"`
}

GraphiteAnnotation represents a Grafana API annotation in Graphite format

type Interface

type Interface interface {
	Post(ctx context.Context, event eventv1.Event) error
}

type Lark

type Lark struct {
	URL string
}

func NewLark

func NewLark(address string) (*Lark, error)

func (*Lark) Post

func (l *Lark) Post(ctx context.Context, event eventv1.Event) error

type LarkCard

type LarkCard struct {
	Config LarkConfig `json:"config"`

	Header LarkHeader `json:"header"`

	Elements []LarkElement `json:"elements"`
}

type LarkConfig

type LarkConfig struct {
	WideScreenMode bool `json:"wide_screen_mode"`
}

type LarkElement

type LarkElement struct {
	Tag  string   `json:"tag"`
	Text LarkText `json:"text"`
}

type LarkHeader

type LarkHeader struct {
	Title    LarkTitle `json:"title"`
	Template string    `json:"template"`
}

type LarkPayload

type LarkPayload struct {
	MsgType string   `json:"msg_type"`
	Card    LarkCard `json:"card"`
}

type LarkText

type LarkText struct {
	Tag     string `json:"tag"`
	Content string `json:"content"`
}

type LarkTitle

type LarkTitle struct {
	Tag     string `json:"tag"`
	Content string `json:"content"`
}

type MSTeams

type MSTeams struct {
	URL      string
	ProxyURL string
	CertPool *x509.CertPool
}

MS Teams holds the incoming webhook URL

func NewMSTeams

func NewMSTeams(hookURL string, proxyURL string, certPool *x509.CertPool) (*MSTeams, error)

NewMSTeams validates the MS Teams URL and returns a MSTeams object

func (*MSTeams) Post

func (s *MSTeams) Post(ctx context.Context, event eventv1.Event) error

Post MS Teams message

type MSTeamsField

type MSTeamsField struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type MSTeamsPayload

type MSTeamsPayload struct {
	Type       string           `json:"@type"`
	Context    string           `json:"@context"`
	ThemeColor string           `json:"themeColor"`
	Summary    string           `json:"summary"`
	Sections   []MSTeamsSection `json:"sections"`
}

MSTeamsPayload holds the message card data

type MSTeamsSection

type MSTeamsSection struct {
	ActivityTitle    string         `json:"activityTitle"`
	ActivitySubtitle string         `json:"activitySubtitle"`
	Facts            []MSTeamsField `json:"facts"`
}

MSTeamsSection holds the canary analysis result

type Matrix

type Matrix struct {
	Token    string
	URL      string
	RoomId   string
	CertPool *x509.CertPool
}

func NewMatrix

func NewMatrix(serverURL, token, roomId string, certPool *x509.CertPool) (*Matrix, error)

func (*Matrix) Post

func (m *Matrix) Post(ctx context.Context, event eventv1.Event) error

type MatrixPayload

type MatrixPayload struct {
	Body    string `json:"body"`
	MsgType string `json:"msgtype"`
}

type NopNotifier

type NopNotifier struct{}

func (*NopNotifier) Post

func (n *NopNotifier) Post(ctx context.Context, event eventv1.Event) error

type Opsgenie

type Opsgenie struct {
	URL      string
	ProxyURL string
	CertPool *x509.CertPool
	ApiKey   string
}

func NewOpsgenie

func NewOpsgenie(hookURL string, proxyURL string, certPool *x509.CertPool, token string) (*Opsgenie, error)

func (*Opsgenie) Post

func (s *Opsgenie) Post(ctx context.Context, event eventv1.Event) error

Post opsgenie alert message

type OpsgenieAlert

type OpsgenieAlert struct {
	Message     string            `json:"message"`
	Description string            `json:"description"`
	Details     map[string]string `json:"details"`
}

type PagerDuty

type PagerDuty struct {
	Endpoint   string
	RoutingKey string
	ProxyURL   string
	CertPool   *x509.CertPool
}

func NewPagerDuty

func NewPagerDuty(endpoint string, proxyURL string, certPool *x509.CertPool, routingKey string) (*PagerDuty, error)

func (*PagerDuty) Post

func (p *PagerDuty) Post(ctx context.Context, event eventv1.Event) error

type PureJWT

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

PureJWT just contains the jwt

func NewJWTProvider

func NewJWTProvider(jwt string) *PureJWT

NewJWTProvider create a pureJWT method

func (*PureJWT) GetToken

func (j *PureJWT) GetToken(uri string) (*auth.Token, error)

GetToken uses a JWT token, we assume that we will get new tokens when needed, thus no Expiry defined

type Rocket

type Rocket struct {
	URL      string
	ProxyURL string
	Username string
	Channel  string
	CertPool *x509.CertPool
}

Rocket holds the hook URL

func NewRocket

func NewRocket(hookURL string, proxyURL string, certPool *x509.CertPool, username string, channel string) (*Rocket, error)

NewRocket validates the Rocket URL and returns a Rocket object

func (*Rocket) Post

func (s *Rocket) Post(ctx context.Context, event eventv1.Event) error

Post Rocket message

type Sentry

type Sentry struct {
	Client *sentry.Client
}

Sentry holds the client instance

func NewSentry

func NewSentry(certPool *x509.CertPool, dsn string, environment string) (*Sentry, error)

NewSentry creates a Sentry client from the provided Data Source Name (DSN)

func (*Sentry) Post

func (s *Sentry) Post(ctx context.Context, event eventv1.Event) error

Post event to Sentry

type Slack

type Slack struct {
	URL      string
	ProxyURL string
	Token    string
	Username string
	Channel  string
	CertPool *x509.CertPool
}

Slack holds the hook URL

func NewSlack

func NewSlack(hookURL string, proxyURL string, token string, certPool *x509.CertPool, username string, channel string) (*Slack, error)

NewSlack validates the Slack URL and returns a Slack object

func (*Slack) Post

func (s *Slack) Post(ctx context.Context, event eventv1.Event) error

Post Slack message

type SlackAttachment

type SlackAttachment struct {
	Color      string       `json:"color"`
	AuthorName string       `json:"author_name"`
	Text       string       `json:"text"`
	MrkdwnIn   []string     `json:"mrkdwn_in"`
	Fields     []SlackField `json:"fields"`
}

SlackAttachment holds the markdown message body

type SlackField

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

type SlackPayload

type SlackPayload struct {
	Channel     string            `json:"channel"`
	Username    string            `json:"username"`
	IconUrl     string            `json:"icon_url"`
	IconEmoji   string            `json:"icon_emoji"`
	Text        string            `json:"text,omitempty"`
	Attachments []SlackAttachment `json:"attachments,omitempty"`
}

SlackPayload holds the channel and attachments

type Telegram

type Telegram struct {
	Channel string
	Token   string
}

func NewTelegram

func NewTelegram(channel, token string) (*Telegram, error)

func (*Telegram) Post

func (t *Telegram) Post(ctx context.Context, event eventv1.Event) error

type Webex

type Webex struct {
	// mandatory: this should be set to the universal webex API server https://webexapis.com/v1/messages
	URL string
	// mandatory: webex room ID, specifies on which webex space notifications must be sent
	RoomId string
	// mandatory: webex bot access token, this access token must be generated after creating a webex bot
	Token string

	// optional: use a proxy as needed
	ProxyURL string
	// optional: x509 cert is no longer needed to post to a webex space
	CertPool *x509.CertPool
}

Webex holds the hook URL

func NewWebex

func NewWebex(hookURL, proxyURL string, certPool *x509.CertPool, channel string, token string) (*Webex, error)

NewWebex validates the Webex URL and returns a Webex object

func (*Webex) CreateMarkdown

func (s *Webex) CreateMarkdown(event *eventv1.Event) string

func (*Webex) Post

func (s *Webex) Post(ctx context.Context, event eventv1.Event) error

Post Webex message

type WebexPayload

type WebexPayload struct {
	RoomId   string `json:"roomId,omitempty"`
	Markdown string `json:"markdown,omitempty"`
}

WebexPayload holds the message text

Jump to

Keyboard shortcuts

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