notifier

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: Apache-2.0 Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const NotificationHeader = "gotk-component"

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

View Source
const OperationPost = "post"

OperationPost is the operation name used in cache event metrics

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertManagerAlert added in v0.18.0

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

	StartsAt AlertManagerTime `json:"startsAt"`
	EndsAt   AlertManagerTime `json:"endsAt,omitempty"`
}

type AlertManagerTime added in v1.3.0

type AlertManagerTime time.Time

AlertManagerTime takes care of representing time.Time as RFC3339. See https://prometheus.io/docs/alerting/0.27/clients/

func (AlertManagerTime) MarshalJSON added in v1.3.0

func (a AlertManagerTime) MarshalJSON() ([]byte, error)

func (AlertManagerTime) String added in v1.3.0

func (a AlertManagerTime) String() string

func (*AlertManagerTime) UnmarshalJSON added in v1.3.0

func (a *AlertManagerTime) UnmarshalJSON(jsonRepr []byte) error

type Alertmanager added in v0.18.0

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

func NewAlertmanager added in v0.18.0

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

func (*Alertmanager) Post added in v0.18.0

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

type AzureDevOps added in v0.4.0

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

AzureDevOps is an Azure DevOps notifier.

func NewAzureDevOps added in v0.4.0

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

NewAzureDevOps creates and returns a new AzureDevOps notifier.

func (AzureDevOps) Post added in v0.4.0

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

Post Azure DevOps commit status

type AzureEventHub added in v0.14.0

type AzureEventHub struct {
	Hub *eventhub.Hub
}

AzureEventHub holds the eventhub client

func NewAzureEventHub added in v0.14.0

func NewAzureEventHub(ctx context.Context, endpointURL, token, eventHubNamespace, proxy, serviceAccountName, providerName, providerNamespace string, tokenClient client.Client, tokenCache *pkgcache.TokenCache) (*AzureEventHub, error)

NewAzureEventHub creates a eventhub client

func (*AzureEventHub) Post added in v0.14.0

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

Post all notification-controller messages to EventHub

type Bitbucket added in v0.2.1

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

Bitbucket is a Bitbucket Server notifier.

func NewBitbucket added in v0.2.1

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

NewBitbucket creates and returns a new Bitbucket notifier.

func (Bitbucket) Post added in v0.2.1

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

Post Bitbucket commit status

type BitbucketServer added in v1.2.0

type BitbucketServer struct {
	CommitStatus    string
	Url             *url.URL
	ProviderAddress string
	Username        string
	Password        string
	Token           string
	Client          *retryablehttp.Client
}

BitbucketServer is a notifier for BitBucket Server and Data Center.

func NewBitbucketServer added in v1.2.0

func NewBitbucketServer(commitStatus string, addr string, token string, certPool *x509.CertPool, username string, password string) (*BitbucketServer, error)

NewBitbucketServer creates and returns a new BitbucketServer notifier.

func (BitbucketServer) Post added in v1.2.0

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

Post Bitbucket Server build status

type DataDog added in v1.1.0

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

func NewDataDog added in v1.1.0

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 added in v1.1.0

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 {
	// contains filtered or unexported fields
}

func NewFactory

func NewFactory(ctx context.Context, url string, opts ...Option) *Factory

NewFactory creates a new notifier factory with the given URL and optional configurations.

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 added in v0.0.8

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

func NewGitHub added in v0.0.8

func NewGitHub(commitStatus string, addr string, token string, certPool *x509.CertPool, proxyURL string, providerName string, providerNamespace string, secretData map[string][]byte, tokenCache *pkgcache.TokenCache) (*GitHub, error)

func (*GitHub) Post added in v0.0.8

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

Post Github commit status

type GitHubDispatch added in v0.24.0

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

func NewGitHubDispatch added in v0.24.0

func NewGitHubDispatch(addr string, token string, certPool *x509.CertPool, proxyURL string, providerName string, providerNamespace string, secretData map[string][]byte, tokenCache *pkgcache.TokenCache) (*GitHubDispatch, error)

func (*GitHubDispatch) Post added in v0.24.0

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

Post GitHub Repository Dispatch webhook

type GitLab added in v0.0.11

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

func NewGitLab added in v0.0.11

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

func (*GitLab) Post added in v0.0.11

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

Post GitLab commit status

type Gitea added in v0.30.0

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

func NewGitea added in v0.30.0

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

func (*Gitea) Post added in v0.30.0

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

type GoogleChat added in v0.10.0

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

Slack holds the hook URL

func NewGoogleChat added in v0.10.0

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

NewGoogleChat validates the Google Chat URL and returns a GoogleChat object

func (*GoogleChat) Post added in v0.10.0

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

Post Google Chat message

type GoogleChatCard added in v0.10.0

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

type GoogleChatCardHeader added in v0.10.0

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

type GoogleChatCardSection added in v0.10.0

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

type GoogleChatCardWidget added in v0.10.0

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

type GoogleChatCardWidgetKeyValue added in v0.10.0

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 added in v0.10.0

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

type GoogleChatPayload added in v0.10.0

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

GoogleChatPayload holds the channel and attachments

type GooglePubSub added in v1.0.0

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

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

func NewGooglePubSub added in v1.0.0

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 added in v1.0.0

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

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

type Grafana added in v0.22.0

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

func NewGrafana added in v0.22.0

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 added in v0.22.0

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

Post annotation

type GraphitePayload added in v0.22.0

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

GraphitePayload represents a Grafana API annotation in Graphite format

type Interface

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

type Lark added in v0.16.0

type Lark struct {
	URL string
}

func NewLark added in v0.16.0

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

func (*Lark) Post added in v0.16.0

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

type LarkCard added in v0.16.0

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

	Header LarkHeader `json:"header"`

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

type LarkConfig added in v0.16.0

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

type LarkElement added in v0.16.0

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

type LarkHeader added in v0.16.0

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

type LarkPayload added in v0.16.0

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

type LarkText added in v0.16.0

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

type LarkTitle added in v0.16.0

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

type MSTeams

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

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 added in v0.16.0

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

func NewMatrix added in v0.16.0

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

func (*Matrix) Post added in v0.16.0

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

type MatrixPayload added in v0.16.0

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

type NATS added in v1.2.0

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

NATS holds a NATS client and target subject.

func NewNATS added in v1.2.0

func NewNATS(server string, subject string, username string, password string) (*NATS, error)

func (*NATS) Post added in v1.2.0

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

Post posts Flux events to a NATS subject.

type NopNotifier

type NopNotifier struct{}

func (*NopNotifier) Post

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

type Opsgenie added in v0.17.0

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

func NewOpsgenie added in v0.17.0

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

func (*Opsgenie) Post added in v0.17.0

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

Post opsgenie alert message

type OpsgenieAlert added in v0.17.0

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

type Option added in v1.6.0

type Option func(*notifierOptions)

Option represents a functional option for configuring a notifier.

func WithCertPool added in v1.6.0

func WithCertPool(certPool *x509.CertPool) Option

WithCertPool sets the certificate pool for the notifier.

func WithChannel added in v1.6.0

func WithChannel(channel string) Option

WithChannel sets the channel for the notifier.

func WithCommitStatus added in v1.6.0

func WithCommitStatus(commitStatus string) Option

WithCommitStatus sets the custom commit status for the notifier.

func WithHeaders added in v1.6.0

func WithHeaders(headers map[string]string) Option

WithHeaders sets the headers for the notifier.

func WithPassword added in v1.6.0

func WithPassword(password string) Option

WithPassword sets the password for the notifier.

func WithProviderName added in v1.6.0

func WithProviderName(name string) Option

WithProviderName sets the provider name for the notifier.

func WithProviderNamespace added in v1.6.0

func WithProviderNamespace(namespace string) Option

WithProviderNamespace sets the provider namespace for the notifier.

func WithProxyURL added in v1.6.0

func WithProxyURL(url string) Option

WithProxyURL sets the proxy URL for the notifier.

func WithSecretData added in v1.6.0

func WithSecretData(data map[string][]byte) Option

WithSecretData sets the secret data for the notifier.

func WithServiceAccount added in v1.6.0

func WithServiceAccount(serviceAccountName string) Option

WithServiceAccount sets the service account for the notifier.

func WithToken added in v1.6.0

func WithToken(token string) Option

WithToken sets the token for the notifier.

func WithTokenCache added in v1.6.0

func WithTokenCache(cache *pkgcache.TokenCache) Option

WithTokenCache sets the token cache for the notifier.

func WithTokenClient added in v1.6.0

func WithTokenClient(kubeClient client.Client) Option

WithTokenClient sets the token client for the notifier.

func WithUsername added in v1.6.0

func WithUsername(username string) Option

WithUsername sets the username for the notifier.

type PagerDuty added in v1.0.0

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

func NewPagerDuty added in v1.0.0

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

func (*PagerDuty) Post added in v1.0.0

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

type PureJWT added in v0.14.0

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

PureJWT just contains the jwt

func NewJWTProvider added in v0.14.0

func NewJWTProvider(jwt string) *PureJWT

NewJWTProvider create a pureJWT method

func (*PureJWT) GetToken added in v0.14.0

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 added in v0.12.0

type Sentry struct {
	Client *sentry.Client
}

Sentry holds the client instance

func NewSentry added in v0.12.0

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 added in v0.12.0

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 added in v0.16.0

type Telegram struct {
	Channel string
	Token   string
	// contains filtered or unexported fields
}

func NewTelegram added in v0.16.0

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

func (*Telegram) Post added in v0.16.0

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

type Webex added in v0.11.0

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 added in v0.11.0

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 added in v0.23.2

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

func (*Webex) Post added in v0.11.0

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

Post Webex message

type WebexPayload added in v0.11.0

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