notification

package
v0.0.0-...-b219a09 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNotificationAnnotations

func GetNotificationAnnotations(gh *ghapi.GitHook) map[string]string

func ShouldNotify

func ShouldNotify(annotations map[string]string) bool

func ShouldNotifyStarted

func ShouldNotifyStarted(annotations map[string]string) bool

Types

type Config

type Config struct {
	Github map[string]GithubConfig `json:"github"`
	Slack  map[string]SlackConfig  `json:"slack"`
}

func LoadConfig

func LoadConfig(configFile string) (*Config, error)

func (Config) Notify

func (c Config) Notify(status string, kind string, namespace string, name string, annotations map[string]string)

type GithubConfig

type GithubConfig struct {
	URL   string `json:"url"`
	Token string `json:"token"`
	API   string `json:"api"`
}

func (GithubConfig) Notify

func (g GithubConfig) Notify(status string, kind string, namespace string, name string, annotations map[string]string) error

type GithubStatus

type GithubStatus struct {
	State       string `json:"state,omitempty"`
	TargetURL   string `json:"target_url,omitempty"`
	Description string `json:"description,omitempty"`
	Context     string `json:"context,omitempty"`
}

func (GithubStatus) SendGithubStatus

func (s GithubStatus) SendGithubStatus(token string, apiURL string) error

type PatchAnnotations

type PatchAnnotations struct {
	Op   string `json:"op"`
	Path string `json:"path"`
}

func NewRemoveNotificationPatch

func NewRemoveNotificationPatch(annotations map[string]string) []PatchAnnotations

func NewRemoveStartedPatch

func NewRemoveStartedPatch() []PatchAnnotations

type SlackAttachment

type SlackAttachment struct {
	Color     string `json:"color,omitempty"`
	Title     string `json:"title,omitempty"`
	TitleLink string `json:"title_link,omitempty"`
	Text      string `json:"text,omitempty"`
	Fallback  string `json:"fallback,omitempty"`

	Fields []SlackAttachmentField `json:"fields,omitempty"`
}

type SlackAttachmentField

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

type SlackConfig

type SlackConfig struct {
	URL        string `json:"url"`
	WebhookURL string `json:"webhookURL"`
	Channel    string `json:"channel"`
}

func (SlackConfig) Notify

func (s SlackConfig) Notify(status string, kind string, namespace string, name string, annotations map[string]string) error

type SlackMessage

type SlackMessage struct {
	Channel  string `json:"channel,omitempty"`
	Username string `json:"username,omitempty"`
	IconURL  string `json:"icon_url,omitempty"`

	Attachments []SlackAttachment `json:"attachments"`
}

func NewSlackMessage

func NewSlackMessage(color, channel, url, title, text, fallback, repository, author, branch, commit string) SlackMessage

func (SlackMessage) SendSlackMessage

func (m SlackMessage) SendSlackMessage(webhookURL string) error

Jump to

Keyboard shortcuts

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