slack

package
v0.0.0-...-5334da4 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_TITLE      string = "Kernel logs by fluent-bit"
	BLOCK_TYPE         string = "header"
	TEXT_TYPE          string = "plain_text"
	EMPTY_STRING       string = ""
	DEFAULT_COLOR      string = "#A9AAAA"
	UINT_ARR_TYPE      string = "[]uint8"
	KEY_COLOR          string = "color"
	BLOCK_TYPE_SECTION string = "section"
	TEXT_TYPE_MRKDWN   string = "mrkdwn"
)

Variables

This section is empty.

Functions

func Send

func Send(webhookUrl string, proxy string, payload Payload) []error

Types

type Accessory

type Accessory struct {
	Type        *string   `json:"type"`
	Placeholder *Text     `json:"placeholder,omitempty"`
	ActionId    *string   `json:"action_id,omitempty"`
	Options     *[]Option `json:"options,omitempty"`
	Value       *string   `json:"value,omitempty"`
	Url         *string   `json:"url,omitempty"`
	ImageUrl    *string   `json:"image_url,omitempty"`
	AltText     *string   `json:"alt_text,omitempty"`
	InitialDate *string   `json:"initial_date,omitempty"`
	InitialTime *string   `json:"initial_time,omitempty"`
}

type Action

type Action struct {
	Type  string `json:"type"`
	Text  string `json:"text"`
	Url   string `json:"url"`
	Style string `json:"style"`
}

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"`
	ImageUrl     *string   `json:"image_url,omitempty"`
	Fields       []*Field  `json:"fields,omitempty"`
	Footer       *string   `json:"footer,omitempty"`
	FooterIcon   *string   `json:"footer_icon,omitempty"`
	Timestamp    *int64    `json:"ts,omitempty"`
	MarkdownIn   *[]string `json:"mrkdwn_in,omitempty"`
	Actions      []*Action `json:"actions,omitempty"`
	CallbackID   *string   `json:"callback_id,omitempty"`
	ThumbnailUrl *string   `json:"thumb_url,omitempty"`
	Blocks       []*Block  `json:"blocks,omitempty"`
}

func (*Attachment) AddAction

func (attachment *Attachment) AddAction(action Action) *Attachment

func (*Attachment) AddBlock

func (attachment *Attachment) AddBlock(block Block) *Attachment

func (*Attachment) AddField

func (attachment *Attachment) AddField(field Field) *Attachment

type Block

type Block struct {
	Type      *string    `json:"type"`
	Text      *Text      `json:"text,omitempty"`
	Title     *Text      `json:"title,omitempty"`
	Fields    *[]Text    `json:"fields,omitempty"`
	Accessory *Accessory `json:"accessory,omitempty"`
	Elements  *[]Element `json:"elements,omitempty"`
	Label     *Text      `json:"label,omitempty"`
	ImageUrl  *string    `json:"image_url,omitempty"`
	AltText   *string    `json:"alt_text,omitempty"`
}

type Blocks

type Blocks struct {
	Blocks []Block `json:"blocks"`
}

type Element

type Element struct {
	Type                *string   `json:"type"`
	Text                *string   `json:"text,omitempty"`
	Emoji               *bool     `json:"emoji,omitempty"`
	ImageUrl            *string   `json:"image_url,omitempty"`
	AltText             *string   `json:"alt_text,omitempty"`
	Placeholder         *Text     `json:"placeholder,omitempty"`
	ActionId            *string   `json:"action_id,omitempty"`
	Options             *[]Option `json:"options,omitempty"`
	Filter              *Filter   `json:"filter,omitempty"`
	InitialConversation *string   `json:"initial_conversation,omitempty"`
	InitialUser         *string   `json:"initial_user,omitempty"`
	InitialChannel      *string   `json:"initial_channel,omitempty"`
	Value               *string   `json:"value,omitempty"`
	InitialDate         *string   `json:"initial_date,omitempty"`
	InitialTime         *string   `json:"initial_time,omitempty"`
}

type Field

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

type Filter

type Filter struct {
	Include *[]string `json:"include,omitempty"`
}

type Option

type Option struct {
	Value       *string `json:"value,omitempty"`
	Text        *Text   `json:"text,omitempty"`
	Description *Text   `json:"description,omitempty"`
}

type Payload

type Payload struct {
	Parse       string       `json:"parse,omitempty"`
	Username    string       `json:"username,omitempty"`
	IconUrl     string       `json:"icon_url,omitempty"`
	IconEmoji   string       `json:"icon_emoji,omitempty"`
	Channel     string       `json:"channel,omitempty"`
	Text        string       `json:"text,omitempty"`
	LinkNames   string       `json:"link_names,omitempty"`
	Attachments []Attachment `json:"attachments,omitempty"`
	UnfurlLinks bool         `json:"unfurl_links,omitempty"`
	UnfurlMedia bool         `json:"unfurl_media,omitempty"`
	Markdown    bool         `json:"mrkdwn,omitempty"`
	Blocks      []Block      `json:"blocks,omitempty"`
}

type SlackInfo

type SlackInfo struct {
	Webhook       string
	Channel       string
	Field         *string
	Title         *string
	MaxAttachment int
}

func (*SlackInfo) MakeAttachment

func (s *SlackInfo) MakeAttachment(data map[interface{}]interface{}) Attachment

func (*SlackInfo) SendSlack

func (s *SlackInfo) SendSlack(attachments []Attachment)

type Text

type Text struct {
	Type  *string `json:"type"`
	Text  *string `json:"text,omitempty"`
	Emoji *bool   `json:"emoji,omitempty"`
}

Jump to

Keyboard shortcuts

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