Documentation ¶
Index ¶
- Constants
- type Callback
- type Deliverer
- type Delivery
- type DirectDeliverer
- type Event
- type Locker
- type MockStore
- func (m *MockStore) CollectNotifications(ctx context.Context) error
- func (m *MockStore) Created(ctx context.Context) ([]uuid.UUID, error)
- func (m *MockStore) Deleted(ctx context.Context) ([]uuid.UUID, error)
- func (m *MockStore) Failed(ctx context.Context) ([]uuid.UUID, error)
- func (m *MockStore) Notifications(ctx context.Context, id uuid.UUID, page *Page) ([]Notification, Page, error)
- func (m *MockStore) PutNotifications(ctx context.Context, opts PutOpts) error
- func (m *MockStore) PutReceipt(ctx context.Context, updater string, r Receipt) error
- func (m *MockStore) Receipt(ctx context.Context, id uuid.UUID) (Receipt, error)
- func (m *MockStore) ReceiptByUOID(ctx context.Context, id uuid.UUID) (Receipt, error)
- func (m *MockStore) SetDeleted(ctx context.Context, id uuid.UUID) error
- func (m *MockStore) SetDelivered(ctx context.Context, id uuid.UUID) error
- func (m *MockStore) SetDeliveryFailed(ctx context.Context, id uuid.UUID) error
- type Notification
- type NotificationHandle
- type Notificationer
- type Page
- type Poller
- type PollerOpt
- type Processor
- type PutOpts
- type Reason
- type Receipt
- type Receipter
- type Service
- type Status
- type Store
- type VulnSummary
Constants ¶
const (
// max number of UOIDs that we will queue in a channel
MaxChanSize = 1024
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback struct { NotificationID uuid.UUID `json:"notification_id"` Callback url.URL `json:"callback"` }
Callback holds the details for clients to call back the Notifier and receive notifications.
func (Callback) MarshalJSON ¶
func (*Callback) UnmarshalJSON ¶
type Deliverer ¶
type Deliverer interface { // A unique name for the deliverer implementation Name() string // Deliver will push the notification ID to subscribed clients. // // If delivery fails a clairerror.ErrDeliveryFailed error must be returned. Deliver(ctx context.Context, nID uuid.UUID) error }
Deliverer provides the method set for delivering notifications
type Delivery ¶
type Delivery struct { // a Deliverer implementation to invoke. Deliverer Deliverer // contains filtered or unexported fields }
Delivery handles the business logic of delivering notifications.
func NewDelivery ¶
type DirectDeliverer ¶
type DirectDeliverer interface {
Notifications(ctx context.Context, n []Notification) error
}
DirectDeliverer implementations are used in coordination with the Deliverer interface.
DirectDeliverer(s) expect this method to be called prior to their Deliverer methods. Implementations must still implement both Deliverer and DirectDeliverer methods for correct use.
Implementations will be provided a list of notifications in which they can directly deliver to subscribed clients.
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is delivered on the poller's channel when a new UpdateOperation is discovered.
type Locker ¶ added in v4.3.0
type Locker interface { TryLock(context.Context, string) (context.Context, context.CancelFunc) Lock(context.Context, string) (context.Context, context.CancelFunc) Close(context.Context) error }
Locker is any context-based locking API.
type MockStore ¶
type MockStore struct { Notifications_ func(ctx context.Context, id uuid.UUID, page *Page) ([]Notification, Page, error) PutNotifications_ func(ctx context.Context, opts PutOpts) error PutReceipt_ func(ctx context.Context, updater string, r Receipt) error CollectNotitfications_ func(ctx context.Context) error Receipt_ func(ctx context.Context, id uuid.UUID) (Receipt, error) ReceiptByUOID_ func(ctx context.Context, id uuid.UUID) (Receipt, error) Created_ func(ctx context.Context) ([]uuid.UUID, error) Failed_ func(ctx context.Context) ([]uuid.UUID, error) Deleted_ func(ctx context.Context) ([]uuid.UUID, error) SetDelivered_ func(ctx context.Context, id uuid.UUID) error SetDeliveredFailed_ func(ctx context.Context, id uuid.UUID) error SetDeleted_ func(ctx context.Context, id uuid.UUID) error }
MockStore implements a mock Store.
func (*MockStore) CollectNotifications ¶ added in v4.4.0
CollectNotifications garbage collects all notifications.
func (*MockStore) Notifications ¶
func (m *MockStore) Notifications(ctx context.Context, id uuid.UUID, page *Page) ([]Notification, Page, error)
Notifications retrieves the list of notifications associated with a notification id
func (*MockStore) PutNotifications ¶
PutNotifications persists the provided notifications and associates them with the provided notification id
PutNotifications must update the latest update operation for the provided updater in such a way that UpdateOperation returns the the provided update operation id when queried with the updater name
PutNotifications must create a Receipt with status created status on successful persistence of notifications in such a way that Receipter.Created() returns the persisted notification id.
func (*MockStore) PutReceipt ¶
PutReceipt allows for the caller to directly add a receipt to the store without notifications being created.
After this method returns all methods on the Receipter interface must work accordingly.
func (*MockStore) ReceiptByUOID ¶
ReceiptByUOID returns the Receipt for a given UOID
func (*MockStore) SetDeleted ¶
SetDeleted marks the provided notification id as deleted
func (*MockStore) SetDelivered ¶
SetDelivered marks the provided notification id as delivered
type Notification ¶
type Notification struct { ID uuid.UUID `json:"id"` Manifest claircore.Digest `json:"manifest"` Reason Reason `json:"reason"` Vulnerability VulnSummary `json:"vulnerability"` }
Notification summarizes a change in the vulnerabilities affecting a manifest.
The mentioned Vulnerability will be the most severe vulnerability discovered in an update operation.
Receiving clients are expected to filter notifications by severity in such a way that they receive all vulnerabilities at or above a particular claircore.Severity level.
type NotificationHandle ¶
NotificationHandle is a handle a client may use to retrieve a list of associated notification models
type Notificationer ¶
type Notificationer interface { // Notifications retrieves the list of notifications associated with a // notification id // // If a Page is provided the returned notifications will be a subset of the total // and it's len will be no larger then Page.Size. // // This method should interpret the page.Next field as the requested page and // set the returned page.Next field to the next page to receive or -1 if // paging has been exhausted. // // Page maybe nil to receive all notifications. Notifications(ctx context.Context, id uuid.UUID, page *Page) ([]Notification, Page, error) // PutNotifications persists the provided notifications and associates // them with the provided notification id // // PutNotifications must update the latest update operation for the provided // updater in such a way that UpdateOperation returns the the provided update // operation id when queried with the updater name // // PutNotifications must create a Receipt with status created status on // successful persistence of notifications in such a way that Receipter.Created() // returns the persisted notification id. PutNotifications(ctx context.Context, opts PutOpts) error // PutReceipt allows for the caller to directly add a receipt to the store // without notifications being created. // // After this method returns all methods on the Receipter interface must work accordingly. PutReceipt(ctx context.Context, updater string, r Receipt) error // CollectNotifications garbage collects all notifications. // // Normally Receipter.SetDeleted will be issues first, however // application logic may decide to GC notifications which have not been // set deleted after some period of time, thus this condition should not // be checked. CollectNotifications(ctx context.Context) error }
Notificationer implements persistence methods for Notification models
type Page ¶
type Page struct { // the next id to retrieve Next *uuid.UUID `json:"next,omitempty"` // the max number of elements returned in a page Size int `json:"size"` }
Page communicates a bare-minimum paging protocol with clients.
type Poller ¶
type Poller struct {
// contains filtered or unexported fields
}
Poller implements new Update Operation discovery via an event channel.
type Processor ¶
type Processor struct { // NoSummary controls whether per-manifest vulnerability summarization // should happen. // // The zero value makes the default behavior to do the summary. NoSummary bool // contains filtered or unexported fields }
Processor listen for new UOIDs, creates notifications, and persists these notifications for later retrieval.
Processor(s) create atomic boundaries, no two Processor(s) will be creating notifications for the same UOID at once.
func NewProcessor ¶
type PutOpts ¶
type PutOpts struct { // the updater triggering a notification Updater string // the update operation id triggering the notification UpdateID uuid.UUID // the notification id clients will use to retrieve the // list of notifications NotificationID uuid.UUID // a slice of notifications to persist. these notifications // will be retrievable via the notification id Notifications []Notification }
PutOpts is provided to Notificationer.Put with fields necessary to persist a notification id
type Receipt ¶
type Receipt struct { // The update operation associated with this receipt UOID uuid.UUID // the id a client may use to retrieve a set of notifications NotificationID uuid.UUID // the current status of the notification Status Status // the timestamp of the last status update TS time.Time }
Receipt represents the current status of a notification
type Receipter ¶
type Receipter interface { // Receipt returns the Receipt for a given notification id Receipt(ctx context.Context, id uuid.UUID) (Receipt, error) // ReceiptByUOID returns the Receipt for a given UOID ReceiptByUOID(ctx context.Context, id uuid.UUID) (Receipt, error) // Created returns a slice of notification ids in created status Created(ctx context.Context) ([]uuid.UUID, error) // Failed returns a slice of notification ids to in delivery failed status Failed(ctx context.Context) ([]uuid.UUID, error) // Deleted returns a slice of notification ids in deleted status Deleted(ctx context.Context) ([]uuid.UUID, error) // SetDelivered marks the provided notification id as delivered SetDelivered(ctx context.Context, id uuid.UUID) error // SetDeliveryFailed marks the provided notification id failed to be delivered SetDeliveryFailed(ctx context.Context, id uuid.UUID) error // SetDeleted marks the provided notification id as deleted SetDeleted(ctx context.Context, id uuid.UUID) error }
Receipter implements persistence methods for Receipt models
type Service ¶ added in v4.4.0
type Service interface { // Retrieves an optional paginated set of notifications given an notification id Notifications(ctx context.Context, id uuid.UUID, page *Page) ([]Notification, Page, error) // Deletes the provided notification id DeleteNotifications(ctx context.Context, id uuid.UUID) error }
Service is an interface wrapping ClairV4's notifier functionality.
This remains an interface so remote clients may implement as well.
type Status ¶
type Status string
Status defines the possible states of a notification.
const ( // A notification is created and ready to be delivered to a client Created Status = "created" // A notification has been successfully delivered to a client Delivered Status = "delivered" // A notification failed to be delivered DeliveryFailed Status = "delivery_failed" // The client has read the notification and issued a delete Deleted Status = "deleted" )
type Store ¶
type Store interface { Notificationer Receipter }
Store is an aggregate interface implementing all methods necessary for a notifier persistence layer
type VulnSummary ¶
type VulnSummary struct { Name string `json:"name"` Description string `json:"description"` Package *claircore.Package `json:"package,omitempty"` Distribution *claircore.Distribution `json:"distribution,omitempty"` Repo *claircore.Repository `json:"repo,omitempty"` Severity string `json:"severity"` FixedInVersion string `json:"fixed_in_version"` Links string `json:"links"` }
VulnSummary summarizes a vulnerability which triggered a notification
func (*VulnSummary) FromVulnerability ¶
func (vs *VulnSummary) FromVulnerability(v *claircore.Vulnerability)