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
- Variables
- func ArgoApplication(app string) (namespace, name string)
- func Newer(a, b string) bool
- type Argo
- type Build
- type Candidate
- type Env
- type GitHub
- type Install
- type Manager
- func (m *Manager) Apply(ctx context.Context) error
- func (m *Manager) Check(ctx context.Context)
- func (m *Manager) Failed(err error)
- func (m *Manager) Run(ctx context.Context)
- func (m *Manager) SaveSettings(ctx context.Context, s Settings) (Settings, error)
- func (m *Manager) Settings(ctx context.Context) Settings
- func (m *Manager) Status(ctx context.Context) Status
- type SettingStore
- type Settings
- type Status
Constants ¶
const ( ChannelRelease = "release" ChannelMain = "main" )
The channels.
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.
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.
const DefaultRepo = "https://api.github.com/repos/yeixio/matinee"
DefaultRepo is Matinee's repository.
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 ¶
var DefaultSettings = Settings{Channel: ChannelRelease}
DefaultSettings: releases, installed by hand.
var ErrCantApply = errors.New("this server can't install updates itself")
ErrCantApply is Apply where whatever installed Matinee updates it.
var ErrNothing = errors.New("there's no update to install")
ErrNothing is Apply with no update found.
Functions ¶
func ArgoApplication ¶
ArgoApplication splits namespace/name; a bare name is in argocd.
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 ¶
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) ImageTag ¶
ImageTag is the build's container image: CI tags each main commit's sha-<7 characters>, and the release workflow each release's version.
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.
type GitHub ¶
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.
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.
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) Check ¶
Check looks for a newer version now, and installs it if the admin chose automatic updates.
func (*Manager) SaveSettings ¶
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.
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.