upgrade

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 12 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 upgrade is `harnessly upgrade plan|apply|rollback`: it reads a release manifest (internal/release), says what would change and which registered extensions the new core cannot speak to, and then replaces the programs of one release together, checks the result and puts the old programs back if the check fails.

It touches programs only. The machine's registration, the data folders and the hub's database are never opened here: a program that is put back runs on the data the new one left, which is why the migrations are additive (docs/hub/upgrade.md).

Index

Constants

This section is empty.

Variables

View Source
var ErrBlocked = errors.New("the release does not speak the protocol of a registered extension")

ErrBlocked: the plan has incompatible extensions.

Functions

func ProbeVersion

func ProbeVersion(t Target) string

ProbeVersion asks a program for its version (`<path> version`). The runtime is not asked: it has no such command and a bare start would run the server.

func Rollback

func Rollback(targets []Target) ([]string, error)

Rollback puts back the programs an earlier apply set aside (<path>.prev) and returns the paths restored.

Types

type AppCheck

type AppCheck struct {
	ID      string `json:"id"`
	Kind    string `json:"kind"`
	Version string `json:"version"`
	// Off: the app is switched off, so its problem is shown but does not stop apply.
	Off    bool     `json:"off,omitempty"`
	Errors []string `json:"errors,omitempty"`
	// Warnings never stop apply.
	Warnings []string `json:"warnings,omitempty"`
}

AppCheck is what the compatibility check of one installed app (harnessly app compat) says about the release.

type Extension

type Extension struct{ Name, Protocol string }

Extension is a registered extension: its name and the protocol it is registered with.

type Item

type Item struct {
	Component string `json:"component"`
	Path      string `json:"path"`
	// Action: update, install (not there yet), current (already the release's), skip (the release has no such file).
	Action string `json:"action"`
	// Have is the installed version when it could be read; Want is the release's.
	Have string `json:"have,omitempty"`
	Want string `json:"want"`
	// contains filtered or unexported fields
}

Item is one program in the plan.

type Options

type Options struct {
	// Fetch opens the file of the release by its download name; the hash is checked here, not by Fetch.
	Fetch func(ctx context.Context, key string) (io.ReadCloser, error)
	// Restart makes the replaced programs run; nil means the caller does it. It also runs after a rollback.
	Restart func(ctx context.Context) error
	// Verify is the check after the update; an error rolls back.
	Verify func(ctx context.Context, replaced []Item) error
	// Force applies although the plan is blocked.
	Force bool
	// Log gets one line per step; may be nil.
	Log func(string)
}

Options of Apply.

type Plan

type Plan struct {
	Version    string                   `json:"version"`
	Items      []Item                   `json:"items"`
	Extensions []release.ExtensionCheck `json:"extensions"`
	// Apps is the check of the apps installed on this machine against the release, when it was asked for.
	Apps []AppCheck   `json:"apps,omitempty"`
	Data release.Data `json:"data"`
	// Blocking lists what stops apply: an incompatible extension.
	Blocking []string `json:"blocking,omitempty"`
}

Plan is what apply would do.

func MakePlan

func MakePlan(m *release.Manifest, targets []Target, goos, goarch string, exts []Extension, probe func(Target) string) (*Plan, error)

MakePlan compares the installed programs with the release. It changes nothing.

func (*Plan) AddApps

func (p *Plan) AddApps(checks []AppCheck)

AddApps puts the check of the installed apps into the plan: an app that is on and does not fit stops apply.

func (*Plan) Blocked

func (p *Plan) Blocked() bool

Blocked says apply refuses.

func (*Plan) Changes

func (p *Plan) Changes() bool

Changes says whether any program would be replaced.

type Result

type Result struct {
	Replaced []string `json:"replaced"`
	// RolledBack: the check failed and the old programs are back.
	RolledBack bool `json:"rolledBack"`
}

Result of Apply.

func Apply

func Apply(ctx context.Context, p *Plan, o Options) (*Result, error)

Apply downloads and checks every file first, then replaces them one after another, restarts, verifies, and puts the old files back when anything fails. A failure before the first replacement leaves the machine as it was.

type Target

type Target struct {
	Component string
	Path      string
	// Optional: a missing file is installed, and a release without it is no error.
	Optional bool
}

Target is an installed program of a component.

Jump to

Keyboard shortcuts

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