ext

package
v0.0.0-...-1eec387 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorInfo    = "#439FE0"
	ColorGood    = "good"
	ColorWarning = "warning"
	ColorDanger  = "danger"
)

Reserved colors in Slack API

Variables

This section is empty.

Functions

func GitHubHTTPClient

func GitHubHTTPClient(ctx context.Context, st storage.Storage) (*http.Client, error)

GitHubHTTPClient returns a *http.Client to access Internet with GitHub personal access token. It returns *http.Client of ProxyHTTPClient() when token does not exist.

func LocalHTTPClient

func LocalHTTPClient() *http.Client

LocalHTTPClient returns a *http.Client to access intranet services.

func ProxyHTTPClient

func ProxyHTTPClient(ctx context.Context, st storage.Storage) (*http.Client, error)

ProxyHTTPClient returns a *http.Client to access Internet.

Types

type Attachment

type Attachment struct {
	Fallback   string            `json:"fallback,omitempty"`
	Color      string            `json:"color,omitempty"`
	Pretext    string            `json:"pretext,omitempty"`
	AuthorName string            `json:"author_name,omitempty"`
	AuthorLink string            `json:"author_link,omitempty"`
	AuthorIcon string            `json:"author_icon,omitempty"`
	Title      string            `json:"title,omitempty"`
	TitleLink  string            `json:"title_link,omitempty"`
	Text       string            `json:"text,omitempty"`
	Fields     []AttachmentField `json:"fields,omitempty"`
	ImageURL   string            `json:"image_url,omitempty"`
	ThumbURL   string            `json:"thumb_url,omitempty"`
	Footer     string            `json:"footer,omitempty"`
	FooterIcon string            `json:"footer_icon,omitempty"`
}

Attachment represents an attachment in the slack payload

type AttachmentField

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

AttachmentField represents fields in a Attachment

type Notifier

type Notifier interface {
	NotifyInfo(req neco.UpdateRequest, message string) error
	NotifySucceeded(req neco.UpdateRequest) error
	NotifyFailure(req neco.UpdateRequest, message string) error
}

Notifier notifies the result of update to the outside.

func NewNotifier

func NewNotifier(ctx context.Context, st storage.Storage) (Notifier, error)

NewNotifier creates a new Notifier.

type Payload

type Payload struct {
	Attachments []Attachment `json:"attachments"`
}

Payload represents a slack payload

type SlackClient

type SlackClient struct {
	URL     string
	HTTP    *http.Client
	Cluster string
}

SlackClient is a slack client

func (SlackClient) NotifyFailure

func (c SlackClient) NotifyFailure(req neco.UpdateRequest, message string) error

NotifyFailure sends a failure notification about the update process

func (SlackClient) NotifyInfo

func (c SlackClient) NotifyInfo(req neco.UpdateRequest, message string) error

NotifyInfo sends a notification about the beginning of the update process

func (SlackClient) NotifySucceeded

func (c SlackClient) NotifySucceeded(req neco.UpdateRequest) error

NotifySucceeded sends a successful notification about the update process

func (SlackClient) PostWebHook

func (c SlackClient) PostWebHook(payload Payload) error

PostWebHook posts a payload to slack

Jump to

Keyboard shortcuts

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