Documentation
¶
Overview ¶
Package notification owns notification settings, dispatch, and HTTP routes.
Index ¶
- Variables
- func RedactNotificationConfigCredentials(provider notifications.NotificationProvider, localConfig database.JSON) database.JSON
- func RegisterNotifications(api huma.API, notificationSvc *NotificationService, cfg *config.Config)
- type CreateOrUpdateNotificationSettingsInput
- type CreateOrUpdateNotificationSettingsOutput
- type DeleteNotificationSettingsInput
- type DispatchNotificationInput
- type GetAllNotificationSettingsInput
- type GetAllNotificationSettingsOutput
- type GetNotificationSettingsInput
- type GetNotificationSettingsOutput
- type Module
- type NotificationHandler
- func (h *NotificationHandler) CreateOrUpdateNotificationSettings(ctx context.Context, input *CreateOrUpdateNotificationSettingsInput) (*CreateOrUpdateNotificationSettingsOutput, error)
- func (h *NotificationHandler) DeleteNotificationSettings(ctx context.Context, input *DeleteNotificationSettingsInput) (*handlerutil.Out[base.MessageResponse], error)
- func (h *NotificationHandler) DispatchNotification(ctx context.Context, input *DispatchNotificationInput) (*handlerutil.Out[notification.DispatchResponse], error)
- func (h *NotificationHandler) GetAllNotificationSettings(ctx context.Context, input *GetAllNotificationSettingsInput) (*GetAllNotificationSettingsOutput, error)
- func (h *NotificationHandler) GetNotificationSettings(ctx context.Context, input *GetNotificationSettingsInput) (*GetNotificationSettingsOutput, error)
- func (h *NotificationHandler) TestNotification(ctx context.Context, input *TestNotificationInput) (*handlerutil.Out[notification.TestResponse], error)
- type NotificationService
- func (s *NotificationService) CreateOrUpdateSettings(ctx context.Context, provider notifications.NotificationProvider, enabled bool, ...) (*NotificationSettings, error)
- func (s *NotificationService) DeleteSettings(ctx context.Context, provider notifications.NotificationProvider) error
- func (s *NotificationService) DispatchNotification(ctx context.Context, accessToken string, payload notification.DispatchRequest) (notification.DispatchResponse, error)
- func (s *NotificationService) DispatchNotificationForEnvironment(ctx context.Context, environmentID string, ...) (notification.DispatchResponse, error)
- func (s *NotificationService) GetAllSettings(ctx context.Context) ([]NotificationSettings, error)
- func (s *NotificationService) GetSettingsByProvider(ctx context.Context, provider notifications.NotificationProvider) (*NotificationSettings, error)
- func (s *NotificationService) ResolveNotificationTarget(ctx context.Context, environmentID string) (NotificationTarget, error)
- func (s *NotificationService) SendAutoHealNotification(ctx context.Context, containerName, containerID string) error
- func (s *NotificationService) SendBatchContainerUpdateNotification(ctx context.Context, entries []notifications.ContainerUpdateBatchEntry) error
- func (s *NotificationService) SendBatchImageUpdateNotification(ctx context.Context, updates map[string]*imageupdate.Response) (int, error)
- func (s *NotificationService) SendContainerUpdateNotification(ctx context.Context, containerName, imageRef, oldDigest, newDigest string) error
- func (s *NotificationService) SendImageUpdateNotification(ctx context.Context, imageRef string, updateInfo *imageupdate.Response, ...) (int, error)
- func (s *NotificationService) SendPruneReportNotification(ctx context.Context, result *system.PruneAllResult) error
- func (s *NotificationService) SendVulnerabilityNotification(ctx context.Context, payload VulnerabilityNotificationPayload) error
- func (s *NotificationService) TestNotification(ctx context.Context, environmentID string, ...) (string, error)
- type NotificationSettings
- type NotificationTarget
- type TestNotificationInput
- type VulnerabilityNotificationPayload
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedDispatchKind = errors.New("unsupported notification dispatch kind") )
Functions ¶
func RedactNotificationConfigCredentials ¶
func RedactNotificationConfigCredentials(provider notifications.NotificationProvider, localConfig database.JSON) database.JSON
RedactNotificationConfigCredentials returns a copy of config with provider credential fields blanked for API responses.
func RegisterNotifications ¶
func RegisterNotifications(api huma.API, notificationSvc *NotificationService, cfg *config.Config)
RegisterNotifications registers notification endpoints.
Types ¶
type CreateOrUpdateNotificationSettingsInput ¶
type CreateOrUpdateNotificationSettingsInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
Body notification.Update
}
type CreateOrUpdateNotificationSettingsOutput ¶
type CreateOrUpdateNotificationSettingsOutput struct {
Body notification.Response
}
type DispatchNotificationInput ¶
type DispatchNotificationInput struct {
APIKey string `header:"X-API-Key" doc:"Remote environment access token"`
Body notification.DispatchRequest
}
type GetAllNotificationSettingsInput ¶
type GetAllNotificationSettingsInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
}
type GetAllNotificationSettingsOutput ¶
type GetAllNotificationSettingsOutput struct {
Body []notification.Response
}
type GetNotificationSettingsOutput ¶
type GetNotificationSettingsOutput struct {
Body notification.Response
}
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) RegisterRoutes ¶
func (*Module) Service ¶
func (m *Module) Service() *NotificationService
type NotificationHandler ¶
type NotificationHandler struct {
// contains filtered or unexported fields
}
func (*NotificationHandler) CreateOrUpdateNotificationSettings ¶
func (h *NotificationHandler) CreateOrUpdateNotificationSettings(ctx context.Context, input *CreateOrUpdateNotificationSettingsInput) (*CreateOrUpdateNotificationSettingsOutput, error)
func (*NotificationHandler) DeleteNotificationSettings ¶
func (h *NotificationHandler) DeleteNotificationSettings(ctx context.Context, input *DeleteNotificationSettingsInput) (*handlerutil.Out[base.MessageResponse], error)
func (*NotificationHandler) DispatchNotification ¶
func (h *NotificationHandler) DispatchNotification(ctx context.Context, input *DispatchNotificationInput) (*handlerutil.Out[notification.DispatchResponse], error)
func (*NotificationHandler) GetAllNotificationSettings ¶
func (h *NotificationHandler) GetAllNotificationSettings(ctx context.Context, input *GetAllNotificationSettingsInput) (*GetAllNotificationSettingsOutput, error)
func (*NotificationHandler) GetNotificationSettings ¶
func (h *NotificationHandler) GetNotificationSettings(ctx context.Context, input *GetNotificationSettingsInput) (*GetNotificationSettingsOutput, error)
func (*NotificationHandler) TestNotification ¶
func (h *NotificationHandler) TestNotification(ctx context.Context, input *TestNotificationInput) (*handlerutil.Out[notification.TestResponse], error)
type NotificationService ¶
type NotificationService struct {
// contains filtered or unexported fields
}
func NewNotificationService ¶
func NewNotificationService(db *database.DB, cfg *config.Config, environmentSvc *environment.EnvironmentService, eventSvc *event.EventService, apnsSvc *apns.ApnsService) *NotificationService
func (*NotificationService) CreateOrUpdateSettings ¶
func (s *NotificationService) CreateOrUpdateSettings(ctx context.Context, provider notifications.NotificationProvider, enabled bool, localConfig database.JSON) (*NotificationSettings, error)
func (*NotificationService) DeleteSettings ¶
func (s *NotificationService) DeleteSettings(ctx context.Context, provider notifications.NotificationProvider) error
func (*NotificationService) DispatchNotification ¶
func (s *NotificationService) DispatchNotification(ctx context.Context, accessToken string, payload notification.DispatchRequest) (notification.DispatchResponse, error)
func (*NotificationService) DispatchNotificationForEnvironment ¶
func (s *NotificationService) DispatchNotificationForEnvironment(ctx context.Context, environmentID string, payload notification.DispatchRequest) (notification.DispatchResponse, error)
DispatchNotificationForEnvironment dispatches for an agent already identified by its edge tunnel session (#3002).
func (*NotificationService) GetAllSettings ¶
func (s *NotificationService) GetAllSettings(ctx context.Context) ([]NotificationSettings, error)
func (*NotificationService) GetSettingsByProvider ¶
func (s *NotificationService) GetSettingsByProvider(ctx context.Context, provider notifications.NotificationProvider) (*NotificationSettings, error)
func (*NotificationService) ResolveNotificationTarget ¶
func (s *NotificationService) ResolveNotificationTarget(ctx context.Context, environmentID string) (NotificationTarget, error)
func (*NotificationService) SendAutoHealNotification ¶
func (s *NotificationService) SendAutoHealNotification(ctx context.Context, containerName, containerID string) error
SendAutoHealNotification sends a notification when a container is auto-healed.
func (*NotificationService) SendBatchContainerUpdateNotification ¶ added in v2.9.0
func (s *NotificationService) SendBatchContainerUpdateNotification(ctx context.Context, entries []notifications.ContainerUpdateBatchEntry) error
SendBatchContainerUpdateNotification dispatches one notification covering all containers updated in an auto-update run.
func (*NotificationService) SendBatchImageUpdateNotification ¶
func (s *NotificationService) SendBatchImageUpdateNotification(ctx context.Context, updates map[string]*imageupdate.Response) (int, error)
SendBatchImageUpdateNotification returns how many providers the notification was delivered to. Zero means no provider has this event enabled, so callers must not mark the updates notified.
func (*NotificationService) SendContainerUpdateNotification ¶
func (s *NotificationService) SendContainerUpdateNotification(ctx context.Context, containerName, imageRef, oldDigest, newDigest string) error
func (*NotificationService) SendImageUpdateNotification ¶
func (s *NotificationService) SendImageUpdateNotification(ctx context.Context, imageRef string, updateInfo *imageupdate.Response, eventType notifications.NotificationEventType) (int, error)
SendImageUpdateNotification returns how many providers the notification was delivered to. Zero means no provider has this event enabled, so callers must not mark the update notified.
func (*NotificationService) SendPruneReportNotification ¶
func (s *NotificationService) SendPruneReportNotification(ctx context.Context, result *system.PruneAllResult) error
func (*NotificationService) SendVulnerabilityNotification ¶
func (s *NotificationService) SendVulnerabilityNotification(ctx context.Context, payload VulnerabilityNotificationPayload) error
SendVulnerabilityNotification notifies providers subscribed to vulnerability_found events. Only daily summary payloads are sent; legacy per-CVE payloads are ignored.
func (*NotificationService) TestNotification ¶
func (s *NotificationService) TestNotification(ctx context.Context, environmentID string, provider notifications.NotificationProvider, testType string) (string, error)
TestNotification sends a test message even to a disabled provider (testing before enabling is legitimate) and returns a warning when a real notification of the tested kind would not send.
type NotificationSettings ¶ added in v2.8.1
type NotificationSettings struct {
ID uint `json:"id" gorm:"primaryKey"`
Provider notifications.NotificationProvider `json:"provider" gorm:"not null;index;type:varchar(50)"`
Enabled bool `json:"enabled" gorm:"default:false"`
Config database.JSON `json:"config" gorm:"type:jsonb"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (NotificationSettings) TableName ¶ added in v2.8.1
func (NotificationSettings) TableName() string
type NotificationTarget ¶
type TestNotificationInput ¶
type VulnerabilityNotificationPayload ¶
type VulnerabilityNotificationPayload struct {
CVEID string // e.g. CVE-2024-1234
CVELink string // e.g. https://nvd.nist.gov/vuln/detail/CVE-2024-1234
Severity string // CRITICAL, HIGH, MEDIUM, LOW, UNKNOWN
ImageName string // e.g. nginx:latest
FixedVersion string
PkgName string // optional
InstalledVersion string // optional
}
VulnerabilityNotificationPayload is the data sent to all providers for vulnerability_found events. Only vulnerabilities with a fixed version should trigger this notification.