Documentation
¶
Overview ¶
Package notification owns notification settings, dispatch, and HTTP routes.
Index ¶
- Constants
- func RedactNotificationConfigCredentials(provider notifications.NotificationProvider, config database.JSON) database.JSON
- func RegisterNotifications(api huma.API, notificationSvc *NotificationService, cfg *config.Config)
- type CreateOrUpdateNotificationSettingsInput
- type CreateOrUpdateNotificationSettingsOutput
- type DeleteNotificationSettingsInput
- type DeleteNotificationSettingsOutput
- type DispatchNotificationInput
- type DispatchNotificationOutput
- 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) (*DeleteNotificationSettingsOutput, error)
- func (h *NotificationHandler) DispatchNotification(ctx context.Context, input *DispatchNotificationInput) (*DispatchNotificationOutput, 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) (*TestNotificationOutput, 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, ...) (notificationdto.DispatchResponse, error)
- func (s *NotificationService) DispatchNotificationForEnvironment(ctx context.Context, environmentID string, ...) (notificationdto.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) 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 TestNotificationOutput
- type VulnerabilityNotificationPayload
Constants ¶
const ErrUnsupportedDispatchKind = errors.Sentinel("unsupported notification dispatch kind")
Variables ¶
This section is empty.
Functions ¶
func RedactNotificationConfigCredentials ¶
func RedactNotificationConfigCredentials(provider notifications.NotificationProvider, config 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 DeleteNotificationSettingsOutput ¶
type DeleteNotificationSettingsOutput struct {
Body base.ApiResponse[base.MessageResponse]
}
type DispatchNotificationInput ¶
type DispatchNotificationInput struct {
APIKey string `header:"X-API-Key" doc:"Remote environment access token"`
Body notification.DispatchRequest
}
type DispatchNotificationOutput ¶
type DispatchNotificationOutput struct {
Body base.ApiResponse[notification.DispatchResponse]
}
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) (*DeleteNotificationSettingsOutput, error)
func (*NotificationHandler) DispatchNotification ¶
func (h *NotificationHandler) DispatchNotification(ctx context.Context, input *DispatchNotificationInput) (*DispatchNotificationOutput, 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) (*TestNotificationOutput, 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) *NotificationService
func (*NotificationService) CreateOrUpdateSettings ¶
func (s *NotificationService) CreateOrUpdateSettings(ctx context.Context, provider notifications.NotificationProvider, enabled bool, config 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 notificationdto.DispatchRequest) (notificationdto.DispatchResponse, error)
func (*NotificationService) DispatchNotificationForEnvironment ¶
func (s *NotificationService) DispatchNotificationForEnvironment(ctx context.Context, environmentID string, payload notificationdto.DispatchRequest) (notificationdto.DispatchResponse, error)
DispatchNotificationForEnvironment dispatches on behalf of an agent whose identity was already established by its edge tunnel session, so no access token is exchanged (#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) SendBatchImageUpdateNotification ¶
func (s *NotificationService) SendBatchImageUpdateNotification(ctx context.Context, updates map[string]*imageupdate.Response) (int, error)
SendBatchImageUpdateNotification dispatches a batched image-update notification and returns the number of eligible providers it was delivered to (0 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 dispatches a single-image update notification and returns the number of eligible providers it was delivered to (0 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 all enabled providers that have vulnerability_found event enabled. 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 to the provider regardless of its enabled state (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 TestNotificationOutput ¶
type TestNotificationOutput struct {
Body base.ApiResponse[notification.TestResponse]
}
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.