update

package
v0.2.10 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: 24 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 update looks for newer versions of Matinee and, where the server can, installs them: Settings → Server health → Updates.

There are two channels. Releases are the tagged versions (v1.2.3), the default. Main is every commit on main once its checks pass and its image is published (the edge branch), a beta that can break.

How an update is installed depends on how Matinee was installed (see Detect). Under Argo CD it moves the Application to the new revision and Argo CD rolls it out; a plain binary replaces itself and restarts. In a container, from a package manager, or inside the Mac or Windows app, whatever installed Matinee updates it, so the server only says what's new and how.

Index

Constants

View Source
const (
	ChannelRelease = "release"
	ChannelMain    = "main"
)

The channels.

View Source
const (
	KindArgoCD     = "argocd"     // the Helm chart through Argo CD, which Matinee can move
	KindKubernetes = "kubernetes" // the Helm chart without Argo CD
	KindDocker     = "docker"     // a container: Docker, Compose, Unraid, TrueNAS and the like
	KindApt        = "apt"        // the .deb package
	KindDnf        = "dnf"        // the .rpm package
	KindHomebrew   = "homebrew"
	KindApp        = "app" // inside Matinee Server for Mac or the Windows installer, which update themselves
	KindBinary     = "binary"
	KindSource     = "source" // built from source, or a version that can't be compared
)

How Matinee was installed, which decides who updates it.

View Source
const (
	PackageRequest = "/var/lib/matinee/update/request"
	PackageLog     = "/var/log/matinee-update.log"
)

PackageRequest is where the server asks the Linux packages' root helper (matinee-update.path) to upgrade the matinee package, and PackageLog is where the helper says how it went. The log is outside the server's data directory, which the helper, as root, never writes into.

View Source
const DefaultRepo = "https://api.github.com/repos/yeixio/matinee"

DefaultRepo is Matinee's repository.

View Source
const EdgeBranch = "edge"

EdgeBranch is the branch CI moves to each commit on main once its checks pass and its image is published, so it never points at a build without one.

Variables

View Source
var DefaultSettings = Settings{Channel: ChannelRelease}

DefaultSettings: releases, installed by hand.

View Source
var ErrCantApply = errors.New("this server can't install updates itself")

ErrCantApply is Apply where whatever installed Matinee updates it.

View Source
var ErrNothing = errors.New("there's no update to install")

ErrNothing is Apply with no update found.

Functions

func ArgoApplication

func ArgoApplication(app string) (namespace, name string)

ArgoApplication splits namespace/name; a bare name is in argocd.

func Newer

func Newer(a, b string) bool

Newer is whether version a comes after version b (both like 1.2.3, with or without a v). A pre-release comes before its release.

Types

type Argo

type Argo interface {
	Source(ctx context.Context) (kube.Source, error)
	SetSource(ctx context.Context, s kube.Source) error
}

Argo is the Argo CD Application Matinee is installed from (kube.ArgoApp).

type Build

type Build struct {
	Version string `json:"version"`
	// Release is a tagged version without its v, such as 0.2.3 or 0.3.0-beta.1.
	Release string `json:"release,omitempty"`
	// Commit is a build of main: CI builds them as main-<commit>.
	Commit string `json:"commit,omitempty"`
}

Build is the version that's running, from version.Version.

func ParseBuild

func ParseBuild(v string) Build

ParseBuild reads a version. Anything else, such as dev or a local build (git describe's v0.2.2-3-gabc1234), is a build nothing can be compared with, so it's never offered updates.

func (Build) Channel

func (b Build) Channel() string

Channel is the channel the build came from.

func (Build) ImageTag

func (b Build) ImageTag() string

ImageTag is the build's container image: CI tags each main commit's sha-<7 characters>, and the release workflow each release's version.

func (Build) Known

func (b Build) Known() bool

Known is whether the build is a release or a main commit.

func (Build) Revision

func (b Build) Revision() string

Revision is the git revision the build was made from: its tag, or its commit.

type Candidate

type Candidate struct {
	Channel string `json:"channel"`
	// Version is how Settings shows it: v1.2.3, or main-<commit> for a build of main.
	Version string `json:"version"`
	// Revision is the git revision: the release's tag, or the commit.
	Revision string `json:"revision"`
	// ImageTag is its container image's tag.
	ImageTag string `json:"imageTag"`
	// URL is the release's notes, or the commits since this build.
	URL       string    `json:"url"`
	Published time.Time `json:"published,omitzero"`
	// Commits is how many commits main has since this build.
	Commits int `json:"commits,omitempty"`
	// contains filtered or unexported fields
}

Candidate is a newer version to update to.

type Env

type Env struct {
	Getenv func(string) string
	Exists func(string) bool
	// Executable is the server's own path.
	Executable string
	GOOS       string
	// Writable is whether the server can replace a file in dir.
	Writable func(dir string) bool
}

Env reads the environment; tests give their own.

func OSEnv

func OSEnv() Env

OSEnv is the real environment.

type GitHub

type GitHub struct {
	// Base is the repository's API address.
	Base string
	HTTP *http.Client
}

GitHub reads Matinee's releases and the edge branch from GitHub's API, without signing in. GitHub allows 60 such requests an hour from one address; a check makes one or two.

func (*GitHub) Find

func (g *GitHub) Find(ctx context.Context, b Build, channel string) (*Candidate, error)

Find looks for a version newer than b on the channel. It returns nil when there's none, and never offers a version older than b, so a build of main waits on the release channel for a release that has everything it has.

type Install

type Install struct {
	Kind string `json:"kind"`
	// CanApply is whether the server can install an update itself.
	CanApply bool `json:"canApply"`
	// Channels are the channels this install can follow: only container
	// images are built for each commit on main.
	Channels []string `json:"channels"`
	// Application is the Argo CD Application, as namespace/name.
	Application string `json:"application,omitempty"`
	// Prefix is Homebrew's prefix, such as /opt/homebrew.
	Prefix string `json:"-"`
}

Install is how Matinee was installed and what it can do about updates.

func Detect

func Detect(b Build, env Env) Install

Detect works out how Matinee was installed. MATINEE_INSTALL says so outright (the image, the chart and the Linux packages set it); otherwise it's worked out from where the server runs.

type Manager

type Manager struct {
	Store   SettingStore
	Log     *slog.Logger
	Build   Build
	Install Install
	GitHub  *GitHub
	// Argo is set for KindArgoCD.
	Argo Argo
	// Executable and Restart are for the installs that replace the server's
	// own file (a binary, Homebrew): Restart stops the server and starts exe
	// in its place.
	Executable string
	Restart    func(exe string)
	// Busy is whether anyone is watching or listening, which holds off an
	// automatic update until they're done.
	Busy func() bool
	HTTP *http.Client
	// Every is how often it looks; an hour by default.
	Every time.Duration
	Now   func() time.Time
	// contains filtered or unexported fields
}

Manager checks for updates and installs them.

func (*Manager) Apply

func (m *Manager) Apply(ctx context.Context) error

Apply installs the update that was found.

func (*Manager) Check

func (m *Manager) Check(ctx context.Context)

Check looks for a newer version now, and installs it if the admin chose automatic updates.

func (*Manager) Failed

func (m *Manager) Failed(err error)

Failed shows err in Settings.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run looks for updates a minute after the server starts, then every hour.

func (*Manager) SaveSettings

func (m *Manager) SaveSettings(ctx context.Context, s Settings) (Settings, error)

SaveSettings stores the settings and looks for updates on the channel. Under Argo CD it also sets the Application to match: following edge for main installed automatically, otherwise pinned to the version running now until an update is installed.

func (*Manager) Settings

func (m *Manager) Settings(ctx context.Context) Settings

Settings reads the admin's settings, keeping them to what this install can do.

func (*Manager) Status

func (m *Manager) Status(ctx context.Context) Status

Status is what Settings shows.

type SettingStore

type SettingStore interface {
	Setting(ctx context.Context, key string) (string, error)
	SetSetting(ctx context.Context, key, value string) error
}

SettingStore keeps the settings (store.Store).

type Settings

type Settings struct {
	// Channel is release (the default) or main, the beta.
	Channel string `json:"channel"`
	// Auto installs updates as they're found, where the server can.
	Auto bool `json:"auto"`
}

Settings are the admin's choices.

type Status

type Status struct {
	Build     Build      `json:"build"`
	Install   Install    `json:"install"`
	Settings  Settings   `json:"settings"`
	Checked   time.Time  `json:"checked,omitzero"`
	Available *Candidate `json:"available,omitempty"`
	// Source is what the Argo CD Application installs now.
	Source *kube.Source `json:"source,omitempty"`
	// Following is whether Argo CD follows main by itself.
	Following bool   `json:"following,omitempty"`
	Applying  string `json:"applying,omitempty"`
	// Waiting is an automatic update that installs once nobody is watching.
	Waiting   bool   `json:"waiting,omitempty"`
	LastError string `json:"lastError,omitempty"`
}

Status is what Settings shows.

Jump to

Keyboard shortcuts

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