updates

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const DefaultInterval = 6 * time.Hour

DefaultInterval applies until an administrator chooses another.

Variables

View Source
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")
)
View Source
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) Interval

func (c *Checker) Interval(ctx context.Context, env string) (time.Duration, error)

Interval returns the environment's check interval.

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.

func (*Checker) Run

func (c *Checker) Run(ctx context.Context)

Run checks every environment when its interval has passed, until ctx ends.

func (*Checker) SetInterval

func (c *Checker) SetInterval(ctx context.Context, env string, d time.Duration) error

SetInterval stores the environment's check interval.

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.

Jump to

Keyboard shortcuts

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