notification

package
v2.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: BSD-3-Clause Imports: 32 Imported by: 0

Documentation

Overview

Package notification owns notification settings, dispatch, and HTTP routes.

Index

Constants

View Source
const ErrUnauthorizedNotificationDispatch = errors.Sentinel("unauthorized notification dispatch")
View Source
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 DeleteNotificationSettingsInput

type DeleteNotificationSettingsInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Provider      string `path:"provider" doc:"Provider"`
}

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 GetNotificationSettingsInput

type GetNotificationSettingsInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Provider      string `path:"provider" doc:"Provider"`
}

type GetNotificationSettingsOutput

type GetNotificationSettingsOutput struct {
	Body notification.Response
}

type Module

type Module struct {
	// contains filtered or unexported fields
}

func New

func New(service *NotificationService, cfg *config.Config) *Module

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(api huma.API)

func (*Module) Service

func (m *Module) Service() *NotificationService

type NotificationHandler

type NotificationHandler struct {
	// contains filtered or unexported fields
}

func (*NotificationHandler) DeleteNotificationSettings

func (*NotificationHandler) DispatchNotification

func (*NotificationHandler) GetAllNotificationSettings

func (*NotificationHandler) GetNotificationSettings

func (*NotificationHandler) TestNotification

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 (*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 (*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 NotificationTarget struct {
	EnvironmentID   string
	EnvironmentName string
}

type TestNotificationInput

type TestNotificationInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Provider      string `path:"provider" doc:"Provider"`
	Type          string `query:"type" default:"simple"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL