Documentation
¶
Index ¶
- Variables
- type AttachmentSender
- type ErrorLimitingSender
- type HookResult
- type Mail
- type MailDialer
- type Notifier
- type Null
- type Sender
- type Slack
- func (s *Slack) BuildAttachment(message string) objects.Attachment
- func (s *Slack) BuildHookAttachment(hookType string, result *HookResult) objects.Attachment
- func (s *Slack) Send(ctx context.Context, message string)
- func (s *Slack) SendHookResult(ctx context.Context, hookType string, result *HookResult)
- func (s *Slack) SetSender(sender SlackSender)
- type SlackSender
Constants ¶
This section is empty.
Variables ¶
var ( // SlackUsername variable. SlackUsername = "Dewy" // SlackIconURL variable. SlackIconURL = "https://raw.githubusercontent.com/linyows/dewy/main/misc/dewy-icon.512.png" SlackFooterIcon = "https://raw.githubusercontent.com/linyows/dewy/main/misc/dewy-icon.32.png" )
Functions ¶
This section is empty.
Types ¶
type AttachmentSender ¶ added in v0.20.0
type AttachmentSender interface {
SendHookResult(ctx context.Context, hookType string, result *HookResult)
}
AttachmentSender interface for sending messages with attachments.
type ErrorLimitingSender ¶
type ErrorLimitingSender struct {
// contains filtered or unexported fields
}
ErrorLimitingSender wraps a Sender implementation with error limiting functionality.
func (*ErrorLimitingSender) ResetErrorCount ¶
func (e *ErrorLimitingSender) ResetErrorCount()
ResetErrorCount resets error count when operation succeeds.
func (*ErrorLimitingSender) Send ¶
func (e *ErrorLimitingSender) Send(ctx context.Context, message string)
Send sends a message only if error count is 0.
func (*ErrorLimitingSender) SendError ¶
func (e *ErrorLimitingSender) SendError(ctx context.Context, err error)
SendError handles error notifications with count limiting.
func (*ErrorLimitingSender) SendHookResult ¶ added in v0.20.0
func (e *ErrorLimitingSender) SendHookResult(ctx context.Context, hookType string, result *HookResult)
SendHookResult sends hook result notification.
type HookResult ¶ added in v0.20.0
type HookResult struct {
Command string
Stdout string
Stderr string
ExitCode int
Duration time.Duration
Success bool
}
HookResult represents the result of executing a deploy hook.
type Mail ¶
type Mail struct {
Host string `schema:"host"`
Port int `schema:"port"`
Username string `schema:"username"`
Password string `schema:"password"`
From string `schema:"from"`
To string `schema:"to"`
Subject string `schema:"subject"`
TLS bool `schema:"tls"`
// contains filtered or unexported fields
}
Mail struct.
func (*Mail) SendHookResult ¶ added in v0.20.0
func (m *Mail) SendHookResult(ctx context.Context, hookType string, result *HookResult)
SendHookResult sends hook result via email.
func (*Mail) SetDialer ¶
func (m *Mail) SetDialer(dialer MailDialer)
SetDialer sets the mail dialer for testing purposes.
type MailDialer ¶
MailDialer interface for dependency injection and testing.
type Notifier ¶
type Notifier interface {
Sender
AttachmentSender
SendError(ctx context.Context, err error)
ResetErrorCount()
}
Notifier interface extends Sender with error handling and hook result notifications.
type Null ¶
type Null struct {
}
func (*Null) SendHookResult ¶ added in v0.20.0
func (n *Null) SendHookResult(ctx context.Context, hookType string, result *HookResult)
type Slack ¶
type Slack struct {
Channel string `schema:"-"`
Title string `schema:"title"`
TitleURL string `schema:"url"`
// contains filtered or unexported fields
}
Slack struct.
func (*Slack) BuildAttachment ¶
func (s *Slack) BuildAttachment(message string) objects.Attachment
BuildAttachment returns attachment for slack.
func (*Slack) BuildHookAttachment ¶ added in v0.20.0
func (s *Slack) BuildHookAttachment(hookType string, result *HookResult) objects.Attachment
BuildHookAttachment returns attachment for hook result.
func (*Slack) SendHookResult ¶ added in v0.20.0
func (s *Slack) SendHookResult(ctx context.Context, hookType string, result *HookResult)
SendHookResult sends hook result with detailed attachment.
func (*Slack) SetSender ¶
func (s *Slack) SetSender(sender SlackSender)
SetSender sets the slack sender for testing purposes.
type SlackSender ¶
type SlackSender interface {
SendMessage(ctx context.Context, channel, username, iconURL, text string, attachment *objects.Attachment) error
}
SlackSender interface for dependency injection and testing.