update

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package update is how a self-hosted platform learns of its new releases and applies one when its owner asks, the way GitLab tells an instance's admins "update available": the platform checks the releases of devopus-server now and then and shows the owner what is out. Applying needs root, which the platform does not have: it leaves a request in its data folder, and a systemd unit installed with it (devopus-server-upgrade.path) runs 'devopus-server upgrade --requested' as root — backup, download checked against the checksums, replace, restart, roll back if the new release does not come up — writing how it goes next to the request.

Index

Constants

View Source
const (
	RequestFile = "request.json"
	StatusFile  = "status.json"
)

The files of the update folder.

View Source
const (
	Requested = "requested"
	Running   = "running"
	Failed    = "failed"
	Done      = "done"
)

States of applying a release.

View Source
const ReleasesAPI = "https://api.github.com/repos/amalychev/devopus-server/releases/latest"

ReleasesAPI is where the newest release of devopus-server is told.

Variables

This section is empty.

Functions

func Newer

func Newer(a, b string) bool

Newer reports whether release a is newer than the running version b. A build that is no release (dev, a test build) has nothing newer: it is not upgraded.

func Valid

func Valid(v string) bool

Valid reports whether v is a release's version: 1.2.3 or v1.2.3.

func WriteRequest

func WriteRequest(dir string, r Request) error

WriteRequest leaves the request the upgrade unit picks up.

func WriteStatus

func WriteStatus(dir string, s Status) error

WriteStatus records how applying goes; the platform reads it.

Types

type Release

type Release struct {
	Version string // 0.2.0
	URL     string // its notes
}

Release is a release of devopus-server.

func Latest

func Latest(ctx context.Context, api string) (Release, error)

Latest asks the releases API for the newest release.

type Request

type Request struct {
	Version string    `json:"version"`
	By      string    `json:"by"`
	At      time.Time `json:"at"`
}

Request is the owner's request to apply a release.

func TakeRequest

func TakeRequest(dir string) (Request, error)

TakeRequest reads the request and removes it, so the unit does not run again for it.

type Status

type Status struct {
	State   string    `json:"state"`
	Target  string    `json:"target"`
	Message string    `json:"message,omitempty"`
	At      time.Time `json:"at"`
}

Status is how applying the last requested release goes.

func ReadStatus

func ReadStatus(dir string) (Status, error)

ReadStatus is the status in a folder; zero when nothing was asked yet.

func (Status) Busy

func (s Status) Busy(now time.Time) bool

Busy reports whether a release is being applied; a state older than an hour is left over from a run that died.

Jump to

Keyboard shortcuts

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