Documentation
¶
Overview ¶
Package update exposes the HTTP handler for the /v1/update API endpoint.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
Path string
// contains filtered or unexported fields
}
Handler is an API handler used for triggering container update scans
func New ¶
New is a factory function creating a new Handler instance. The updateFn callback returns a Response that is serialised as the HTTP response body, so scripts driving the endpoint can tell how the scan went without scraping logs.
func (*Handler) Handle ¶
func (handle *Handler) Handle(w http.ResponseWriter, r *http.Request)
Handle is the actual http.Handle function doing all the heavy lifting. Returns 200 with a JSON Response body on success; 429 with a "skipped" body when another update is already running. Targeted updates (an `image=` query parameter) block until the in-flight update completes rather than 429-ing, because the caller almost always wants the specified images updated eventually.
type Response ¶ added in v1.12.0
type Response struct {
// Status is one of "completed" or "skipped".
Status string `json:"status"`
// Reason explains why the request was skipped. Only set when
// Status == "skipped".
Reason string `json:"reason,omitempty"`
// Scanned is the number of containers inspected during the update.
Scanned int `json:"scanned,omitempty"`
// Updated is the number of containers recreated with a newer image.
Updated int `json:"updated,omitempty"`
// Failed is the number of containers whose update failed.
Failed int `json:"failed,omitempty"`
}
Response is the JSON body returned by the /v1/update handler. Status is always populated; Scanned/Updated/Failed are only meaningful when Status == "completed".