updatecheck

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package updatecheck periodically checks the configured update channel's latest release against the running build, when an operator has opted into auto-update checking (update_settings.auto_update_enabled, migrations/0258_update_settings.sql). It only checks and records the result; it never applies an update itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Channel         string
	CurrentVersion  string
	LatestVersion   string
	UpdateAvailable bool
	ReleaseURL      string
	CheckedAt       time.Time
}

Result is the outcome of the most recently completed check.

type Scheduler

type Scheduler struct {
	Store    Store
	Fetchers upgrade.Fetchers
	Logger   *slog.Logger
	// contains filtered or unexported fields
}

Scheduler checks, on its own tick, whether update_settings has auto-update enabled and, if so, fetches the configured channel's latest release via Fetchers (kit/upgrade), the identical lookup+comparison logic GET /api/v1/updates itself uses (internal/api/updates.go's handleGetUpdates). Run's own tick-forever shape mirrors backup.Scheduler.Run/alerting.Engine.Run.

func NewScheduler

func NewScheduler(st Store, logger *slog.Logger, repo string) *Scheduler

NewScheduler builds a Scheduler ready to Tick or Run. logger defaults to slog.Default() if nil, the same convention backup.NewScheduler already establishes.

func (*Scheduler) Result

func (s *Scheduler) Result() Result

Result returns the outcome of the last completed check, the zero Result if none has run yet (or auto-update has never been enabled).

func (*Scheduler) Run

func (s *Scheduler) Run(ctx context.Context, interval time.Duration) error

Run calls Tick on interval until ctx is done.

func (*Scheduler) Tick

func (s *Scheduler) Tick(ctx context.Context) error

Tick reads update_settings and, only when auto_update_enabled is set, fetches the configured channel's latest release and records it. A disabled setting is not an error: Tick is simply a no-op until an operator opts in, the same "absence is a real, valid state" stance this codebase takes elsewhere (e.g. IngressSettings.PrimaryDomain).

type Store

type Store interface {
	GetUpdateSettings(ctx context.Context) (store.UpdateSettings, error)
}

Store is the narrow store surface Scheduler needs. *store.DB satisfies this structurally, the same "consumer defines its own narrow interface" convention internal/backup.ScheduleStore already establishes for its own store dependency.

Jump to

Keyboard shortcuts

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