Documentation
¶
Index ¶
- func MakeMessage(target string, msg string, attachments []Attachment) message.Composer
- func MakeSender(opts *SlackOptions) (send.Sender, error)
- func NewMessage(p level.Priority, target string, msg string, attachments []Attachment) message.Composer
- type Attachment
- type AttachmentField
- type Message
- type SlackOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeMessage ¶
func MakeMessage(target string, msg string, attachments []Attachment) message.Composer
MakeMessage creates a composer for message to slack without a priority
func MakeSender ¶
func MakeSender(opts *SlackOptions) (send.Sender, error)
MakeSlackLogger is equivalent to NewSlackLogger, but constructs a Sender reading the slack token from the environment variable "GRIP_SLACK_CLIENT_TOKEN".
func NewMessage ¶
func NewMessage(p level.Priority, target string, msg string, attachments []Attachment) message.Composer
NewMessage creates a composer for messages to slack
Types ¶
type Attachment ¶
type Attachment struct {
Color string `bson:"color,omitempty" json:"color,omitempty" yaml:"color,omitempty"`
Fallback string `bson:"fallback" json:"fallback" yaml:"fallback"`
AuthorName string `bson:"author_name,omitempty" json:"author_name,omitempty" yaml:"author_name,omitempty"`
AuthorIcon string `bson:"author_icon,omitempty" json:"author_icon,omitempty" yaml:"author_icon,omitempty"`
Title string `bson:"title,omitempty" json:"title,omitempty" yaml:"title,omitempty"`
TitleLink string `bson:"title_link,omitempty" json:"title_link,omitempty" yaml:"title_link,omitempty"`
Text string `bson:"text" json:"text" yaml:"text"`
Fields []*AttachmentField `bson:"fields,omitempty" json:"fields,omitempty" yaml:"fields,omitempty"`
MarkdownIn []string `bson:"mrkdwn_in,omitempty" json:"mrkdwn_in,omitempty" yaml:"mrkdwn_in,omitempty"`
}
Attachment is a single attachment to a slack message. This type is the same as bluele/slack.Attachment
type AttachmentField ¶
type AttachmentField struct {
Title string `bson:"title" json:"title" yaml:"title"`
Value string `bson:"value" json:"value" yaml:"value"`
Short bool `bson:"short" json:"short" yaml:"short"`
}
AttachmentField is one of the optional fields that can be attached to a slack message. This type is the same as bluele/slack.AttachmentField
type Message ¶
type Message struct {
Target string `bson:"target" json:"target" yaml:"target"`
Msg string `bson:"msg" json:"msg" yaml:"msg"`
Attachments []*slack.Attachment `bson:"attachments" json:"attachments" yaml:"attachments"`
}
Message is a message to a Message channel or user
type SlackOptions ¶
type SlackOptions struct {
// Channel, Name, and Hostname are basic configurations
// options for the sender, and control where the messages are
// sent, which hostname the sender reports itself as, and the
// name of the journaler.
Channel string `bson:"channel" json:"channel" yaml:"channel"`
Hostname string `bson:"hostname" json:"hostname" yaml:"hostname"`
Name string `bson:"name" json:"name" yaml:"name"`
// Username and IconURL allow the slack sender to set a display
// name and icon. Setting either parameter will force as_user to false.
Username string `bson:"username" json:"username" yaml:"username"`
IconURL string `bson:"icon_url" json:"icon_url" yaml:"icon_url"`
// Configuration options for appending structured data to the
// message sent to slack. The BasicMetadata option appends
// priority and host information to the message. The Fields
// option appends structured data if the Raw method of a
// Composer returns a message.Fields map. If you specify a set
// of fields in the FieldsSet value, only those fields will be
// attached to the message.
BasicMetadata bool `bson:"add_basic_metadata" json:"add_basic_metadata" yaml:"add_basic_metadata"`
Fields bool `bson:"use_fields" json:"use_fields" yaml:"use_fields"`
AllFields bool `bson:"all_fields" json:"all_fields" yaml:"all_fields"`
FieldsSet map[string]bool `bson:"fields" json:"fields" yaml:"fields"`
// contains filtered or unexported fields
}
SlackOptions configures the behavior for constructing messages sent to slack.
func (*SlackOptions) Validate ¶
func (o *SlackOptions) Validate() error
Validate inspects the contents SlackOptions struct and returns an error that reports on missing required fields (e.g. Channel and Name); if the hostname is missing and the os.Hostname() syscall fails (but supplies the Hostname as reported by Hostname if there is no Hostname is specified). Validate also prepends a missing "#" to the channel setting if the "#" character is not set.