Documentation
¶
Overview ¶
Package slacknotify provides Slack webhook notification helpers shared across packages. Centralising the config and send helpers here breaks the import cycle that would otherwise arise when integration definitions (e.g. githubapp) need to send Slack messages using infrastructure that lives in ent/hooks.
Index ¶
- func LoadTemplate(ctx context.Context, fileOverride, embeddedTemplate string) (*template.Template, error)
- func NotificationsEnabled() bool
- func RenderGitHubAppInstallMessage(githubOrg, githubAccountType, openlaneOrgName, openlaneOrgID string) (string, error)
- func SendNotification(ctx context.Context, message string) error
- func SendNotificationWithEmail(ctx context.Context, email, overrideFile, embeddedTemplate string) error
- func SetConfig(c SlackConfig)
- func SubscriberTemplateOverride() string
- func UserTemplateOverride() string
- type SlackConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadTemplate ¶
func LoadTemplate(ctx context.Context, fileOverride, embeddedTemplate string) (*template.Template, error)
LoadTemplate resolves either an override template from disk or a bundled template
func NotificationsEnabled ¶
func NotificationsEnabled() bool
NotificationsEnabled reports whether a Slack webhook is configured
func RenderGitHubAppInstallMessage ¶
func RenderGitHubAppInstallMessage(githubOrg, githubAccountType, openlaneOrgName, openlaneOrgID string) (string, error)
RenderGitHubAppInstallMessage renders the GitHub App installation Slack message
func SendNotification ¶
SendNotification posts a plain Slack message when webhook notifications are configured
func SendNotificationWithEmail ¶
func SendNotificationWithEmail(ctx context.Context, email, overrideFile, embeddedTemplate string) error
SendNotificationWithEmail renders and posts a Slack message using explicit email and context values
func SetConfig ¶
func SetConfig(c SlackConfig)
SetConfig replaces the active Slack notification configuration
func SubscriberTemplateOverride ¶
func SubscriberTemplateOverride() string
SubscriberTemplateOverride returns the subscriber template override path if configured
func UserTemplateOverride ¶
func UserTemplateOverride() string
UserTemplateOverride returns the user template override path if configured
Types ¶
type SlackConfig ¶
type SlackConfig struct {
// WebhookURL is the endpoint to send messages to
WebhookURL string
// NewSubscriberMessageFile is an optional path to a bespoke Slack template for new subscriber notifications
NewSubscriberMessageFile string
// NewUserMessageFile is an optional path to a bespoke Slack template for new user notifications
NewUserMessageFile string
}
SlackConfig defines the runtime configuration for Slack notifications
func GetConfig ¶
func GetConfig() SlackConfig
GetConfig returns the active Slack notification configuration