Documentation
¶
Overview ¶
Package updates finds images whose tag points to a newer digest in the registry (#53, ADR-0030). Only the registry digest is stored; whether an update is available is decided when reading, against the local image at that moment, so a pull clears it at once.
Index ¶
- Constants
- Variables
- type Checker
- func (c *Checker) Check(ctx context.Context, env *environment.Environment, ref string) (Report, error)
- func (c *Checker) Interval(ctx context.Context, env string) (time.Duration, error)
- func (c *Checker) Overview(ctx context.Context, env *environment.Environment, ns string) (Overview, error)
- func (c *Checker) Run(ctx context.Context)
- func (c *Checker) SetInterval(ctx context.Context, env string, d time.Duration) error
- type Overview
- type Report
- type Status
- type Store
Constants ¶
const DefaultInterval = 6 * time.Hour
DefaultInterval applies until an administrator chooses another.
Variables ¶
var ( // ErrInvalidInterval is returned for intervals outside Intervals. ErrInvalidInterval = errors.New("invalid interval") // ErrBusy is returned while a check of the environment runs. ErrBusy = errors.New("a check is already running") )
var Intervals = []time.Duration{0, time.Hour, 6 * time.Hour, 12 * time.Hour, 24 * time.Hour}
Intervals are the allowed check intervals; 0 turns scheduled checks off.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
Environments *environment.Registry
Store Store
Logger *slog.Logger
Now func() time.Time
// contains filtered or unexported fields
}
Checker checks the images used by containers on a schedule and on request.
func (*Checker) Check ¶
func (c *Checker) Check(ctx context.Context, env *environment.Environment, ref string) (Report, error)
Check resolves in the registry the references used by containers of every namespace, or only ref when given (used or not).
func (*Checker) Overview ¶
func (c *Checker) Overview(ctx context.Context, env *environment.Environment, ns string) (Overview, error)
Overview reports the stored checks of the references present in a namespace: those used by containers, and any other image of the namespace that was checked.
type Overview ¶
type Overview struct {
IntervalSeconds int64 `json:"intervalSeconds"`
LastCheck *time.Time `json:"lastCheck,omitempty"`
NextCheck *time.Time `json:"nextCheck,omitempty"`
Running bool `json:"running"`
Images []Status `json:"images"`
}
Overview is the state of an environment's update checks for one namespace.
type Report ¶
type Report struct {
Checked int `json:"checked"`
Updates int `json:"updates"`
Failed int `json:"failed"`
}
Report summarizes a check.
type Status ¶
type Status struct {
Ref string `json:"ref"`
LocalDigest string `json:"localDigest"`
RemoteDigest string `json:"remoteDigest,omitempty"`
CheckedAt time.Time `json:"checkedAt"`
Error string `json:"error,omitempty"`
// UpdateAvailable: the registry's digest differs from the local one.
UpdateAvailable bool `json:"updateAvailable"`
// Containers counts the namespace's containers created from the reference.
Containers int `json:"containers"`
}
Status is the update state of one image reference in a namespace.
type Store ¶
type Store interface {
ListImageUpdates(ctx context.Context, environment string) ([]db.ImageUpdate, error)
SetImageUpdate(ctx context.Context, arg db.SetImageUpdateParams) error
LastImageUpdateCheck(ctx context.Context, environment string) (int64, error)
GetSetting(ctx context.Context, key string) (string, error)
SetSetting(ctx context.Context, arg db.SetSettingParams) error
}
Store is the database used by the checker; *db.Queries of the write connection implements it.