ocversion

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package ocversion knows which OpenCloud versions this plugin is tested against. The pins live in versions.yaml next to this file — the one place in the repository that names an OpenCloud image (compatibility-policy.md §3). The test fixture, CI and the README all derive from it, and the file is embedded so the build carries the window it was tested in.

Index

Constants

View Source
const (
	ChannelProduction = "production"
	ChannelRolling    = "rolling"
)

Channels OpenCloud publishes on that a leg may belong to. They decide the image a leg pulls and whether its line's later patches are covered; the support range itself is by version number. LTS is out of scope (compatibility-policy.md §3).

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	// Version is the release as OpenCloud reports it ("8.1.0"). Kept as a
	// string: a development build need not be MAJOR.MINOR.PATCH, and it
	// should still be logged as it is.
	Version string
	// Edition is "stable" on the Production channel and "rolling" on Rolling.
	Edition string
}

Info is what an OpenCloud instance says about itself.

type Leg

type Leg struct {
	// Name is the leg's role ("newest"), stable across version bumps
	// so CI job names can be required by a ruleset.
	Name    string `yaml:"name"`
	Channel string `yaml:"channel"`
	Image   string `yaml:"image"`
	Tag     string `yaml:"tag"`
	// Digest pins the image; empty only for the canary, which follows its tag.
	Digest string `yaml:"digest"`
}

Leg is one OpenCloud version the plugin is tested against.

func (Leg) Ref

func (l Leg) Ref() string

Ref is the reference a container runtime pulls: image:tag, plus @digest when the leg is pinned.

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor keeps track of the OpenCloud version and warns when it is outside the window compiled into the build. It never refuses anything: a household that upgraded OpenCloud a day before the plugin caught up must still get its nightly backup (compatibility-policy.md §3, "warns and runs").

func NewMonitor

func NewMonitor(source Source, window Window, logger *slog.Logger) *Monitor

NewMonitor returns a monitor that has not checked yet.

func (*Monitor) Check

func (m *Monitor) Check(ctx context.Context) error

Check asks OpenCloud once and logs the result. A failed fetch keeps the last known version: a transient outage says nothing about the version.

func (*Monitor) Run

func (m *Monitor) Run(ctx context.Context, interval, retry time.Duration)

Run checks now and then every interval until ctx ends. Until OpenCloud has answered once it retries every retry instead: the service may well start before OpenCloud does.

func (*Monitor) Status

func (m *Monitor) Status() Status

Status returns the latest result. Safe for concurrent use.

type Pins

type Pins struct {
	// Default is the leg the fixture starts when none is chosen.
	Default string `yaml:"default"`
	// Legs are the supported versions; CI runs every one of them, blocking.
	Legs []Leg `yaml:"legs"`
	// Canary follows the newest release by tag and is not supported.
	Canary Leg `yaml:"canary"`
}

Pins is the parsed versions.yaml.

func Embedded

func Embedded() (Pins, error)

Embedded returns the pins compiled into this build. The file is validated by the package's tests, so an error here means a broken build.

func Parse

func Parse(data []byte) (Pins, error)

Parse decodes and validates a versions.yaml document.

func (Pins) SupportedSentence

func (p Pins) SupportedSentence() string

SupportedSentence is the README's claim, generated so it cannot drift from what CI runs.

func (Pins) Window

func (p Pins) Window() Window

Window derives the support window from the pinned legs. Parse guarantees at least one Rolling leg.

type Source

type Source interface {
	Fetch(ctx context.Context) (Info, error)
}

Source tells which OpenCloud the service runs against.

type Status

type Status struct {
	// Known is false until OpenCloud has answered once.
	Known   bool
	Version string
	Edition string
	// InWindow is false for a version outside Window and for one that is not
	// MAJOR.MINOR.PATCH (a development or pre-release build was not tested).
	InWindow bool
	// Window is what this build was tested against.
	Window Window
}

Status is the monitor's latest answer.

type StatusSource

type StatusSource struct {
	BaseURL string
	Client  *http.Client
}

StatusSource reads GET <BaseURL>/status.php. Measured in the Phase 9 spike (phase-0-findings.md) on 7.2.4, 7.3.0, 7.5.0 and 8.1.0: it needs no credential, and `productversion` / `edition` carry the release on all of them. `version` and `versionstring` are a frozen ownCloud-compat "0.1.0" and are ignored.

func (StatusSource) Fetch

func (s StatusSource) Fetch(ctx context.Context) (Info, error)

Fetch implements Source.

type Version

type Version struct{ Major, Minor, Patch int }

Version is an OpenCloud release number, MAJOR.MINOR.PATCH.

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion reads "8.1.0" (a leading "v" is accepted). Pre-release and build suffixes are refused: no leg pins one, and a canary on one is not a supported version anyway.

func (Version) Compare

func (v Version) Compare(w Version) int

Compare returns -1, 0 or +1 as v is older than, equal to or newer than w.

func (Version) String

func (v Version) String() string

type Window

type Window struct {
	Oldest Version
	Newest Version
	// ProductionLines are MAJOR.MINOR pairs; Patch is ignored.
	ProductionLines []Version
}

Window is the set of OpenCloud versions a build supports (compatibility-policy.md §3): every release from the oldest to the newest Rolling leg, plus every patch release of the Production lines a leg pins.

Inside the range the channel does not matter: a Production release is a Rolling release OpenCloud kept patching on a side branch. The Production line is added on its own because those patches can be newer than the newest Rolling leg, and because the line stays supported while it is current even once it is older than the two majors the range spans.

A release newer than the newest leg is outside, even a patch release of it: supported means tested, and it was not.

func (Window) Contains

func (w Window) Contains(v Version) bool

Contains reports whether v is inside the window.

func (Window) String

func (w Window) String() string

String is the window in words, e.g. "7.3.0 to 8.1.0" or "8.0.0 to 9.1.0, plus every 8.2.x patch release". It is what the README states and what the admin view repeats.

Jump to

Keyboard shortcuts

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