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 ¶
var ErrBlocked = errors.New("the release does not speak the protocol of a registered extension")
ErrBlocked: the plan has incompatible extensions.
Functions ¶
func ProbeVersion ¶
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.
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.
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.