Documentation
¶
Overview ¶
Package update answers whether a newer release exists and how to put it in place.
Index ¶
- Constants
- Variables
- func Account(root string) (uint32, uint32, bool)
- func Banner(st db.UpdateState, s Settings, now time.Time) (time.Time, bool)
- func CheckInstance(root string) error
- func CheckRunPath(dir string) string
- func ChownTree(path, root string) error
- func CopyFile(from, to string) error
- func CopyTree(src, dst string) error
- func ExecutableName(goos string) string
- func ExtractExecutable(archive, dest, goos string) error
- func FreeBytes(dir string) (uint64, error)
- func HealthHandler(check func(context.Context) Health) http.Handler
- func IsPrivate(path string) bool
- func ListenHealth() (net.Listener, error)
- func Lock(dir string) (func(), error)
- func MaintenanceHandler(bundle *i18n.Bundle, assets *static.Assets, files http.Handler) http.Handler
- func Newer(candidate, current string) bool
- func NewlyFound(previous string, st db.UpdateState, current string) bool
- func NoExec(dir string) bool
- func OldExecutable(current string) string
- func Owner(path string) (uint32, uint32, bool)
- func PackageDir(version, goos, goarch string) string
- func PackageFile(version, goos, goarch string) string
- func PostgresMajor(version string) string
- func Postpone(st *db.UpdateState, now time.Time)
- func PrivateDir(root string) (string, error)
- func PrivatePath(root string) string
- func RecordCheck(st *db.UpdateState, now time.Time, fetch func() (Manifest, error))
- func RecordInstance(private, root, exe string) error
- func RecordedExecutable(running string) string
- func RemoveCheckRun(dir string)
- func Replace(current, next string) error
- func RollbackDir(root string) string
- func Skip(st *db.UpdateState) string
- func StartNow(st *db.UpdateState, f Facts) bool
- func Startable(st db.UpdateState, f Facts) bool
- func Tick(st *db.UpdateState, s Settings, f Facts, fetch func() (Manifest, error)) string
- func TreeSize(dir string) (int64, error)
- func Writable(dir string) bool
- func WriteCheckRun(dir string, run CheckRun) error
- func WriteRuntime(dir string, r Runtime) error
- type Applier
- type Board
- func (b *Board) CheckNow(ctx context.Context) (db.UpdateState, error)
- func (b *Board) Facts(now time.Time) Facts
- func (b *Board) Notices(ctx context.Context) []Notice
- func (b *Board) Postpone(ctx context.Context) error
- func (b *Board) Problem(ctx context.Context) (CheckProblem, bool)
- func (b *Board) Skip(ctx context.Context) error
- func (b *Board) StartNow(ctx context.Context) error
- func (b *Board) Startable(ctx context.Context) bool
- func (b *Board) State(ctx context.Context) db.UpdateState
- func (b *Board) Wrap(next http.Handler) http.Handler
- type CheckProblem
- type CheckRun
- type Facts
- type Health
- type Instance
- type Machine
- type Manifest
- type Notice
- type NoticeKind
- type Outcome
- type Package
- type Preflight
- type Reason
- type RollbackPoint
- type Runner
- type Runtime
- type Settings
- type Source
- type Target
- type Version
- type Window
Constants ¶
const ( RollbackNone = "binary" RollbackPGData = "pgdata" RollbackBackup = "backup" )
const ( TimerQuiet = time.Hour StartupCalm = 30 * time.Minute )
const ( ProblemFailed = "failed" ProblemStopped = "stopped" ProblemFetch = "fetch" ProblemInstall = "install" )
const ( PrivateStaging = "staging" PrivateRollback = "rollback" PrivateBin = "bin" )
const ( ManifestName = "latest.json" ChecksumsName = "SHA256SUMS" ManifestFormat = 1 )
const ( RuntimeFile = "serve.json" HealthPath = "/-/health" )
const ( AnnounceAhead = 10 * time.Minute CheckEvery = time.Hour DefaultWindow = "03:00-05:00" DefaultMinAge = time.Duration(0) MissedAfter = 2 * time.Hour RollbackKept = 7 * 24 * time.Hour PostponeFor = 24 * time.Hour UpdatedShown = 24 * time.Hour )
const ( OutcomeUpdated = "updated" OutcomeRolledBack = "rolled-back" OutcomeFailed = "failed" )
const ( GitHubReleases = "https://github.com/WikitTeam/ProjectWikit/releases" EnvReleases = "PWIKIT_RELEASES_URL" )
const NoFollow = syscall.O_NOFOLLOW
Variables ¶
var ErrBusy = errors.New("another pwikit update is running")
var ErrCannotHandOver = errors.New("the filesystem does not let root change who owns a file")
Functions ¶
func CheckInstance ¶
func CheckRunPath ¶
func ExecutableName ¶
func ExtractExecutable ¶
func ListenHealth ¶
func MaintenanceHandler ¶
func NewlyFound ¶
func NewlyFound(previous string, st db.UpdateState, current string) bool
A release is announced once, when a check first finds it, and only when it is newer than what runs, so a rollback back onto an old number stays quiet.
func OldExecutable ¶
func PackageDir ¶
func PackageFile ¶
func PostgresMajor ¶
func PrivateDir ¶
func PrivatePath ¶
func RecordCheck ¶
func RecordInstance ¶
func RecordedExecutable ¶
func RemoveCheckRun ¶
func RemoveCheckRun(dir string)
func Replace ¶
Windows refuses to overwrite a running program but lets it be renamed, and the updater is itself that program.
func RollbackDir ¶
func Skip ¶
func Skip(st *db.UpdateState) string
func Startable ¶
func Startable(st db.UpdateState, f Facts) bool
Asking by hand sets aside the window, the age of the release and any earlier skip, postponement or hold, so only what rules an update out is checked.
func WriteCheckRun ¶
func WriteRuntime ¶
Types ¶
type Applier ¶
type Applier struct {
Root string
PGData string
Executable string
Bundled bool
Current string
Database []string
Private string
RootCopy string
Offline bool
Source Source
Machine Machine
Run Runner
Maintenance func(ctx context.Context) (stop func(), err error)
Logf func(format string, args ...any)
HealthWithin time.Duration
}
func (*Applier) CurrentPostgres ¶
type Board ¶
type CheckProblem ¶
type CheckRun ¶
type CheckRun struct {
At time.Time `json:"at"`
Error string `json:"error,omitempty"`
InstallVersion string `json:"install_version,omitempty"`
InstallError string `json:"install_error,omitempty"`
}
func ReadCheckRun ¶
type Health ¶
type Health struct {
Version string `json:"version"`
Database bool `json:"database"`
Page int `json:"page"`
Problem string `json:"problem,omitempty"`
}
func WaitHealthy ¶
type Instance ¶
type Instance struct {
Root string `json:"root"`
Executable string `json:"executable"`
Dev uint64 `json:"dev"`
Ino uint64 `json:"ino"`
}
func ReadInstance ¶
type Manifest ¶
type Manifest struct {
Format int `json:"format"`
Version string `json:"version"`
PublishedAt string `json:"published_at"`
Notes string `json:"notes"`
Postgres string `json:"postgres"`
Packages map[string]Package `json:"packages"`
}
func ParseManifest ¶
type Notice ¶
type NoticeKind ¶
type NoticeKind string
const ( NoticeScheduled NoticeKind = "scheduled" NoticeAvailable NoticeKind = "available" NoticeUpdated NoticeKind = "updated" NoticeRolledBack NoticeKind = "rolled-back" )
type RollbackPoint ¶
type RollbackPoint struct {
From string `json:"from"`
To string `json:"to"`
Kind string `json:"kind"`
CreatedAt time.Time `json:"created_at"`
}
func ReadRollback ¶
func ReadRollback(dir string) (RollbackPoint, error)
type Runtime ¶
type Runtime struct {
PID int `json:"pid"`
Version string `json:"version"`
StartedAt time.Time `json:"started_at"`
Health string `json:"health"`
Mode string `json:"mode"`
Plain string `json:"plain"`
Secure string `json:"secure"`
CertFile string `json:"cert_file"`
KeyFile string `json:"key_file"`
CacheDir string `json:"cache_dir"`
Email string `json:"email"`
Directory string `json:"directory"`
Hosts []string `json:"hosts"`
}
func ReadRuntime ¶
type Settings ¶
type Source ¶
type Source struct {
Releases string
Mirror string
Log func(string)
// contains filtered or unexported fields
}