update

package
v0.1.0-rc.76 Latest Latest
Warning

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

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

Documentation

Overview

Package update implements `w17ctl update`.

Index

Constants

View Source
const InstallerURL = "https://get.w17.dev/install.sh"

InstallerURL is the canonical installer. It is the ONE place that knows how to resolve "which release is newest", and this command does not learn a second way — see Cmd.

Variables

View Source
var ErrUpdateDeclined = errors.New("codegen: stopped before generating — nothing was written")

ErrUpdateDeclined is codegen stopping because the operator chose to.

View Source
var Interactive = func() bool {
	if os.Getenv("CI") != "" {
		return false
	}
	return term.IsTerminal(int(os.Stdin.Fd())) && term.IsTerminal(int(os.Stdout.Fd()))
}

Interactive reports whether codegen may ask: a person at a terminal, not a pipeline. CI is never asked — there the floor refusal codegen already has is the answer, and a prompt would hang the job.

NewPrompter is the input source for the codegen prompt; a seam for tests.

View Source
var PreGenerateTimeout = 20 * time.Second

PreGenerate is the check `w17ctl codegen` runs before generating.

At a terminal only. A REQUIRED update (the project pins an sdk/go older than the floor the code is generated against) is offered, and declining stops codegen: the code it would write cannot build, and codegen would refuse it afterwards anyway. An AVAILABLE update is offered with "continue anyway" in the alpha phase, where any release may carry a breaking fix and the advice to adopters is to stay current; from v1 it is one line and codegen goes on.

If the binary itself was replaced, codegen stops so it is re-run by the new one — this process is the old client. PreGenerateTimeout bounds the check codegen runs first. It asks the network (the installer, the module proxy, every plugin's registry) and codegen did not use to; a captive portal or a stalled proxy must cost codegen this much at most, never a hang.

View Source
var RunInstallerFn = runInstaller

RunInstallerFn shells out to the installer. Indirected so tests can drive the command without a network or a write to a real bin directory.

Functions

func OnPrereleaseTrack

func OnPrereleaseTrack() bool

OnPrereleaseTrack reports whether this binary should be offered prereleases — i.e. whether the installer gets `--pre`.

TRUE while this binary is itself a prerelease, which is the state every consumer is in today: `latest` means the newest STABLE release, so a client that only ever offered stable upgrades would tell every current user there is nothing to install. It flips off by itself the moment a stable release is what is running — no flag day, no second thing to remember.

An unset Version is a local build (`core.VersionString` reports "dev") and counts as a prerelease: a developer running a self-built binary who asks what is newest wants the newest thing that exists, and the stable track would resolve to nothing at all during rc.

Exported because `version --check` asks the same question, and it has to get the SAME answer. Two copies of this rule would mean `--check` could report a release `update` would not install — a disagreement nobody would notice until it mattered.

func PreGenerate

func PreGenerate(console, root string) error

Types

type Cmd

type Cmd struct {
	Version string `help:"Install this exact release instead of the newest (e.g. v0.1.0-rc.46)." placeholder:"TAG"`
	Dir     string `help:"Install into this directory instead of the one this binary is running from." placeholder:"PATH"`
	Stable  bool   `help:"Refuse prereleases. Off by default while this binary is itself a prerelease — see the note in --help."`
	DryRun  bool   `name:"dry-run" help:"Resolve the release that WOULD be installed and print it, changing nothing."`

	Check   bool   `` /* 187-byte string literal not displayed */
	All     bool   `` /* 137-byte string literal not displayed */
	Console string `` /* 182-byte string literal not displayed */
}

Cmd upgrades this binary in place by invoking the canonical installer.

It does NOT resolve the release itself, and that restraint is the whole design. `install.sh` picks the newest release with an awk key that exists because of a real incident: on 2026-09-08 taking the GitHub API's first row returned `v0.1.0-rc.9` while `rc.10` existed — the list is ordered by creation, not by version — so the older build was installed, and it carried a security defect the newer one fixed. A Go reimplementation would be a second place for that to come back, and the two would drift without ever disagreeing loudly. So: one resolver, invoked.

The installer also verifies the download against the release's SHA256SUMS and cannot be told not to. Inheriting that is the other half of the reason this command is a caller rather than a downloader.

func (*Cmd) Run

func (c *Cmd) Run() error

Jump to

Keyboard shortcuts

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