Documentation
¶
Overview ¶
Package output provides notification outputs for tinkerdown. Outputs are destinations where notifications from Notify imperatives are sent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Type is the output type: "slack" or "email"
Type string `yaml:"type"`
// Channel is the Slack channel (for slack type), e.g., "#team-updates"
Channel string `yaml:"channel,omitempty"`
// To is the email recipient address (for email type)
To string `yaml:"to,omitempty"`
// Subject is the email subject template (for email type)
// Defaults to "Notification from Tinkerdown"
Subject string `yaml:"subject,omitempty"`
}
Config represents the configuration for an output.
type EmailOutput ¶
type EmailOutput struct {
// contains filtered or unexported fields
}
EmailOutput sends notifications via SMTP email.
func NewEmailOutput ¶
func NewEmailOutput(to, subject string) (*EmailOutput, error)
NewEmailOutput creates a new email output. SMTP configuration is read from environment variables:
- SMTP_HOST: SMTP server hostname
- SMTP_PORT: SMTP server port (default: 587)
- SMTP_USER: SMTP authentication username
- SMTP_PASS: SMTP authentication password
- SMTP_FROM: Sender email address
func NewEmailOutputWithConfig ¶
func NewEmailOutputWithConfig(to, from, subject, smtpHost, smtpPort, username, password string) (*EmailOutput, error)
NewEmailOutputWithConfig creates an email output with explicit configuration. This is primarily useful for testing.
func (*EmailOutput) Send ¶
func (e *EmailOutput) Send(ctx context.Context, message string) error
Send delivers an email with the given message as the body.
func (*EmailOutput) Subject ¶
func (e *EmailOutput) Subject() string
Subject returns the configured subject line.
func (*EmailOutput) To ¶
func (e *EmailOutput) To() string
To returns the configured recipient address.
type Output ¶
type Output interface {
// Name returns the output identifier (e.g., "slack", "email").
Name() string
// Send delivers a message to the output destination.
// The context can be used for cancellation and timeouts.
Send(ctx context.Context, message string) error
// Close releases any resources held by the output.
Close() error
}
Output represents a notification destination. Implementations include Slack, Email, and other messaging services.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages a collection of outputs. It is safe for concurrent use.
type SlackOutput ¶
type SlackOutput struct {
// contains filtered or unexported fields
}
SlackOutput sends notifications to a Slack channel via webhook.
func NewSlackOutput ¶
func NewSlackOutput(channel string) (*SlackOutput, error)
NewSlackOutput creates a new Slack output. The webhook URL is read from the SLACK_WEBHOOK_URL environment variable. Channel should be in the format "#channel-name".
func NewSlackOutputForTesting ¶
func NewSlackOutputForTesting(channel, webhookURL string) (*SlackOutput, error)
NewSlackOutputForTesting creates a Slack output for testing purposes. This bypasses webhook URL validation to allow mock servers. Do not use in production code.
func NewSlackOutputWithURL ¶
func NewSlackOutputWithURL(channel, webhookURL string) (*SlackOutput, error)
NewSlackOutputWithURL creates a Slack output with an explicit webhook URL. The URL must be a valid Slack webhook URL (starting with https://hooks.slack.com/). For testing, use NewSlackOutputForTesting instead.
func (*SlackOutput) Channel ¶
func (s *SlackOutput) Channel() string
Channel returns the configured channel name.