services

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: Apache-2.0 Imports: 47 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingConfig = errors.New("config is missing")
	ErrMissingApiKey = errors.New("apiKey is missing")
)
View Source
var GetQueueURL = func(c context.Context, api SQSSendMessageAPI, input *sqs.GetQueueUrlInput) (*sqs.GetQueueUrlOutput, error) {
	return api.GetQueueUrl(c, input)
}
View Source
var SendMsg = func(c context.Context, api SQSSendMessageAPI, input *sqs.SendMessageInput) (*sqs.SendMessageOutput, error) {
	return api.SendMessage(c, input)
}

Functions

func NewConsoleService

func NewConsoleService(stdout io.Writer) *consoleService

func NewEmailService

func NewEmailService(opts EmailOptions) *emailService

func NewGitHubService

func NewGitHubService(opts GitHubOptions) (*gitHubService, error)

Types

type AlertmanagerNotification added in v0.3.0

type AlertmanagerNotification struct {
	Labels       map[string]string `json:"labels"`
	Annotations  map[string]string `json:"annotations"`
	GeneratorURL string            `json:"generatorURL"`
	StartsAt     time.Time         `json:"startsAt"`
}

AlertmanagerNotification message body is similar to Prometheus alertmanager postableAlert model

func (AlertmanagerNotification) GetTemplater added in v0.3.0

GetTemplater parse text template

type AlertmanagerOptions added in v0.3.0

type AlertmanagerOptions struct {
	Targets            []string   `json:"targets"`
	Scheme             string     `json:"scheme"`
	APIPath            string     `json:"apiPath"`
	BasicAuth          *BasicAuth `json:"basicAuth"`
	BearerToken        string     `json:"bearerToken"`
	InsecureSkipVerify bool       `json:"insecureSkipVerify"`
	Timeout            int        `json:"timeout"`
}

AlertmanagerOptions cluster configuration

type AwsAccess added in v0.5.0

type AwsAccess struct {
	Key    string `json:"key"`
	Secret string `json:"secret"`
}

type AwsSqsNotification added in v0.5.0

type AwsSqsNotification struct {
	MessageAttributes map[string]string `json:"messageAttributes"`
	MessageGroupId    string            `json:"messageGroupId,omitempty"`
}

func (*AwsSqsNotification) GetTemplater added in v0.5.0

func (n *AwsSqsNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type AwsSqsOptions added in v0.5.0

type AwsSqsOptions struct {
	Queue       string `json:"queue"`
	Account     string `json:"account"`
	Region      string `json:"region"`
	EndpointUrl string `json:"endpointUrl,omitempty"`
	AwsAccess
}

type BasicAuth

type BasicAuth struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Destination

type Destination struct {
	Service   string `json:"service"`
	Recipient string `json:"recipient"`
}

Destination holds notification destination details

type Destinations

type Destinations map[string][]Destination

Destinations holds notification destinations group by trigger

func (Destinations) Dedup

func (s Destinations) Dedup() Destinations

func (Destinations) Merge

func (s Destinations) Merge(other Destinations)

type EmailNotification

type EmailNotification struct {
	Subject string `json:"subject,omitempty"`
	Body    string `json:"body,omitempty"`
}

func (*EmailNotification) GetTemplater

func (n *EmailNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type EmailOptions

type EmailOptions struct {
	Host               string `json:"host"`
	Port               int    `json:"port"`
	InsecureSkipVerify bool   `json:"insecure_skip_verify"`
	Username           string `json:"username"`
	Password           string `json:"password"`
	From               string `json:"from"`
	Html               bool   `json:"html"`
}

type GitHubCheckRun added in v0.5.0

type GitHubCheckRun struct {
	// head_sha  - this will be the revision path
	// external_id - this should have the details of argocd server
	Name        string                `json:"name,omitempty"`
	DetailsURL  string                `json:"details_url,omitempty"`
	Status      string                `json:"status,omitempty"`
	Conclusion  string                `json:"conclusion,omitempty"`
	StartedAt   string                `json:"started_at,omitempty"`
	CompletedAt string                `json:"completed_at,omitempty"`
	Output      *GitHubCheckRunOutput `json:"output,omitempty"`
}

type GitHubCheckRunOutput added in v0.5.0

type GitHubCheckRunOutput struct {
	Title   string `json:"title,omitempty"`
	Summary string `json:"summary,omitempty"`
	Text    string `json:"text,omitempty"`
}

type GitHubDeployment added in v0.5.0

type GitHubDeployment struct {
	State                string   `json:"state,omitempty"`
	Environment          string   `json:"environment,omitempty"`
	EnvironmentURL       string   `json:"environmentURL,omitempty"`
	LogURL               string   `json:"logURL,omitempty"`
	RequiredContexts     []string `json:"requiredContexts"`
	AutoMerge            *bool    `json:"autoMerge,omitempty"`
	TransientEnvironment *bool    `json:"transientEnvironment,omitempty"`
	Reference            string   `json:"reference,omitempty"`
}

type GitHubNotification

type GitHubNotification struct {
	Status             *GitHubStatus             `json:"status,omitempty"`
	Deployment         *GitHubDeployment         `json:"deployment,omitempty"`
	PullRequestComment *GitHubPullRequestComment `json:"pullRequestComment,omitempty"`
	RepoURLPath        string                    `json:"repoURLPath,omitempty"`
	RevisionPath       string                    `json:"revisionPath,omitempty"`
	CheckRun           *GitHubCheckRun           `json:"checkRun,omitempty"`
	// contains filtered or unexported fields
}

func (*GitHubNotification) GetTemplater

func (g *GitHubNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type GitHubOptions

type GitHubOptions struct {
	AppID             interface{} `json:"appID"`
	InstallationID    interface{} `json:"installationID"`
	PrivateKey        string      `json:"privateKey"`
	EnterpriseBaseURL string      `json:"enterpriseBaseURL"`
}

type GitHubPullRequestComment added in v0.5.0

type GitHubPullRequestComment struct {
	Content    string `json:"content,omitempty"`
	CommentTag string `json:"commentTag,omitempty"`
}

type GitHubStatus

type GitHubStatus struct {
	State     string `json:"state,omitempty"`
	Label     string `json:"label,omitempty"`
	TargetURL string `json:"targetURL,omitempty"`
}

type GoogleChatNotification added in v0.3.0

type GoogleChatNotification struct {
	Cards     string `json:"cards"`
	CardsV2   string `json:"cardsV2"`
	ThreadKey string `json:"threadKey,omitempty"`
}

func (*GoogleChatNotification) GetTemplater added in v0.3.0

func (n *GoogleChatNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type GoogleChatOptions added in v0.3.0

type GoogleChatOptions struct {
	WebhookUrls map[string]string `json:"webhooks"`
}

type GrafanaAnnotation

type GrafanaAnnotation struct {
	Time     int64    `json:"time"` // unix ts in ms
	IsRegion bool     `json:"isRegion"`
	Tags     []string `json:"tags"`
	Text     string   `json:"text"`
}

type GrafanaOptions

type GrafanaOptions struct {
	ApiUrl             string `json:"apiUrl"`
	ApiKey             string `json:"apiKey"`
	InsecureSkipVerify bool   `json:"insecureSkipVerify"`
}
type Header struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type MattermostNotification

type MattermostNotification struct {
	Attachments string `json:"attachments,omitempty"`
}

func (*MattermostNotification) GetTemplater

func (n *MattermostNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type MattermostOptions

type MattermostOptions struct {
	ApiURL             string `json:"apiURL"`
	Token              string `json:"token"`
	InsecureSkipVerify bool   `json:"insecureSkipVerify"`
}

type NewrelicNotification added in v0.4.0

type NewrelicNotification struct {
	Revision    string `json:"revision"`
	Changelog   string `json:"changelog,omitempty"`
	Description string `json:"description,omitempty"`
	User        string `json:"user,omitempty"`
}

func (*NewrelicNotification) GetTemplater added in v0.4.0

func (n *NewrelicNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type NewrelicOptions added in v0.4.0

type NewrelicOptions struct {
	ApiKey string `json:"apiKey"`
	ApiURL string `json:"apiURL"`
}

type Notification

type Notification struct {
	Message      string                    `json:"message,omitempty"`
	AwsSqs       *AwsSqsNotification       `json:"awssqs,omitempty"`
	Email        *EmailNotification        `json:"email,omitempty"`
	Slack        *SlackNotification        `json:"slack,omitempty"`
	Mattermost   *MattermostNotification   `json:"mattermost,omitempty"`
	RocketChat   *RocketChatNotification   `json:"rocketchat,omitempty"`
	Teams        *TeamsNotification        `json:"teams,omitempty"`
	Webhook      WebhookNotifications      `json:"webhook,omitempty"`
	Opsgenie     *OpsgenieNotification     `json:"opsgenie,omitempty"`
	GitHub       *GitHubNotification       `json:"github,omitempty"`
	Alertmanager *AlertmanagerNotification `json:"alertmanager,omitempty"`
	GoogleChat   *GoogleChatNotification   `json:"googlechat,omitempty"`
	Pagerduty    *PagerDutyNotification    `json:"pagerduty,omitempty"`
	PagerdutyV2  *PagerDutyV2Notification  `json:"pagerdutyv2,omitempty"`
	Newrelic     *NewrelicNotification     `json:"newrelic,omitempty"`
}

func (*Notification) GetTemplater

func (n *Notification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

func (*Notification) Preview

func (n *Notification) Preview() string

type NotificationService

type NotificationService interface {
	Send(notification Notification, dest Destination) error
}

NotificationService defines notification service interface

func NewAlertmanagerService added in v0.3.0

func NewAlertmanagerService(opts AlertmanagerOptions) NotificationService

NewAlertmanagerService new service

func NewAwsSqsService added in v0.5.0

func NewAwsSqsService(opts AwsSqsOptions) NotificationService

func NewGoogleChatService added in v0.3.0

func NewGoogleChatService(opts GoogleChatOptions) NotificationService

func NewGrafanaService

func NewGrafanaService(opts GrafanaOptions) NotificationService

func NewMattermostService

func NewMattermostService(opts MattermostOptions) NotificationService

func NewNewrelicService added in v0.4.0

func NewNewrelicService(opts NewrelicOptions) NotificationService

func NewOpsgenieService

func NewOpsgenieService(opts OpsgenieOptions) NotificationService

func NewPagerdutyService added in v0.4.0

func NewPagerdutyService(opts PagerdutyOptions) NotificationService

func NewPagerdutyV2Service added in v0.5.0

func NewPagerdutyV2Service(opts PagerdutyV2Options) NotificationService

func NewPushoverService added in v0.3.0

func NewPushoverService(opts PushoverOptions) NotificationService

func NewRocketChatService

func NewRocketChatService(opts RocketChatOptions) NotificationService

func NewService

func NewService(serviceType string, optsData []byte) (NotificationService, error)

func NewSlackService

func NewSlackService(opts SlackOptions) NotificationService

func NewTeamsService

func NewTeamsService(opts TeamsOptions) NotificationService

func NewTelegramService

func NewTelegramService(opts TelegramOptions) NotificationService

func NewWebexService added in v0.4.0

func NewWebexService(opts WebexOptions) NotificationService

func NewWebhookService

func NewWebhookService(opts WebhookOptions) NotificationService

type OpsgenieNotification

type OpsgenieNotification struct {
	Description string            `json:"description"`
	Priority    string            `json:"priority,omitempty"`
	Alias       string            `json:"alias,omitempty"`
	Note        string            `json:"note,omitempty"`
	Actions     []string          `json:"actions,omitempty"`
	Tags        []string          `json:"tags,omitempty"`
	Details     map[string]string `json:"details,omitempty"`
	Entity      string            `json:"entity,omitempty"`
	VisibleTo   []alert.Responder `json:"visibleTo,omitempty"`
	User        string            `json:"user,omitempty"`
}

func (*OpsgenieNotification) GetTemplater

func (n *OpsgenieNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type OpsgenieOptions

type OpsgenieOptions struct {
	ApiUrl  string            `json:"apiUrl"`
	ApiKeys map[string]string `json:"apiKeys"`
}

type PagerDutyNotification added in v0.4.0

type PagerDutyNotification struct {
	Title      string `json:"title"`
	Body       string `json:"body,omitempty"`
	Urgency    string `json:"urgency,omitempty"`
	PriorityId string `json:"priorityId,omitempty"`
}

func (*PagerDutyNotification) GetTemplater added in v0.4.0

func (p *PagerDutyNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type PagerDutyV2Notification added in v0.5.0

type PagerDutyV2Notification struct {
	Summary   string `json:"summary"`
	Severity  string `json:"severity"`
	Source    string `json:"source"`
	Component string `json:"component,omitempty"`
	Group     string `json:"group,omitempty"`
	Class     string `json:"class,omitempty"`
	URL       string `json:"url"`
}

func (*PagerDutyV2Notification) GetTemplater added in v0.5.0

func (p *PagerDutyV2Notification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type PagerdutyOptions added in v0.4.0

type PagerdutyOptions struct {
	Token     string `json:"token"`
	From      string `json:"from,omitempty"`
	ServiceID string `json:"serviceId"`
}

type PagerdutyV2Options added in v0.5.0

type PagerdutyV2Options struct {
	ServiceKeys map[string]string `json:"serviceKeys"`
}

type PushoverOptions added in v0.3.0

type PushoverOptions struct {
	Token string `json:"token"`
}

type RocketChatNotification

type RocketChatNotification struct {
	Attachments string `json:"attachments,omitempty"`
}

func (*RocketChatNotification) GetTemplater

func (n *RocketChatNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type RocketChatOptions

type RocketChatOptions struct {
	Alias     string `json:"alias"`
	Email     string `json:"email"`
	Password  string `json:"password"`
	Icon      string `json:"icon"`
	Avatar    string `json:"avatar"`
	ServerUrl string `json:"serverUrl"`
}

type SQSSendMessageAPI added in v0.5.0

type SQSSendMessageAPI interface {
	GetQueueUrl(ctx context.Context,
		params *sqs.GetQueueUrlInput,
		optFns ...func(*sqs.Options)) (*sqs.GetQueueUrlOutput, error)

	SendMessage(ctx context.Context,
		params *sqs.SendMessageInput,
		optFns ...func(*sqs.Options)) (*sqs.SendMessageOutput, error)
}

type SlackNotification

type SlackNotification struct {
	Username        string                   `json:"username,omitempty"`
	Icon            string                   `json:"icon,omitempty"`
	Attachments     string                   `json:"attachments,omitempty"`
	Blocks          string                   `json:"blocks,omitempty"`
	GroupingKey     string                   `json:"groupingKey"`
	NotifyBroadcast bool                     `json:"notifyBroadcast"`
	DeliveryPolicy  slackutil.DeliveryPolicy `json:"deliveryPolicy"`
}

func (*SlackNotification) GetTemplater

func (n *SlackNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type SlackOptions

type SlackOptions struct {
	Username           string   `json:"username"`
	Icon               string   `json:"icon"`
	Token              string   `json:"token"`
	SigningSecret      string   `json:"signingSecret"`
	Channels           []string `json:"channels"`
	InsecureSkipVerify bool     `json:"insecureSkipVerify"`
	ApiURL             string   `json:"apiURL"`
	DisableUnfurl      bool     `json:"disableUnfurl"`
}

type TeamsNotification

type TeamsNotification struct {
	Template        string `json:"template,omitempty"`
	Title           string `json:"title,omitempty"`
	Summary         string `json:"summary,omitempty"`
	Text            string `json:"text,omitempty"`
	ThemeColor      string `json:"themeColor,omitempty"`
	Facts           string `json:"facts,omitempty"`
	Sections        string `json:"sections,omitempty"`
	PotentialAction string `json:"potentialAction,omitempty"`
}

func (*TeamsNotification) GetTemplater

func (n *TeamsNotification) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type TeamsOptions

type TeamsOptions struct {
	RecipientUrls map[string]string `json:"recipientUrls"`
}

type TelegramOptions

type TelegramOptions struct {
	Token string `json:"token"`
}

type Templater

type Templater func(notification *Notification, vars map[string]interface{}) error

type TemplaterSource

type TemplaterSource interface {
	GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)
}

type WebexOptions added in v0.4.0

type WebexOptions struct {
	Token  string `json:"token"`
	ApiURL string `json:"apiURL"`
}

type WebhookNotification

type WebhookNotification struct {
	Method string `json:"method"`
	Body   string `json:"body"`
	Path   string `json:"path"`
}

type WebhookNotifications

type WebhookNotifications map[string]WebhookNotification

func (WebhookNotifications) GetTemplater

func (n WebhookNotifications) GetTemplater(name string, f texttemplate.FuncMap) (Templater, error)

type WebhookOptions

type WebhookOptions struct {
	URL                string        `json:"url"`
	Headers            []Header      `json:"headers"`
	BasicAuth          *BasicAuth    `json:"basicAuth"`
	InsecureSkipVerify bool          `json:"insecureSkipVerify"`
	RetryWaitMin       time.Duration `json:"retryWaitMin"`
	RetryWaitMax       time.Duration `json:"retryWaitMax"`
	RetryMax           int           `json:"retryMax"`
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.