updatecheck

package
v0.16.86 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package updatecheck tells a self-hosted runtime whether a newer release is published: a periodic GET of the project's latest-release address, compared with the running version. It sends nothing but that request.

Index

Constants

View Source
const (
	// DefaultInterval is the time between checks.
	DefaultInterval = 12 * time.Hour
	// Timeout bounds one request.
	Timeout = 10 * time.Second
)
View Source
const DefaultURL = "https://api.github.com/repos/ly-solutions/harnessly/releases/latest"

DefaultURL is the project's latest published (non-draft, non-pre-release) release.

Variables

This section is empty.

Functions

func Comparable

func Comparable(current string) bool

Comparable says whether the running version can be compared with a release at all.

func Compare

func Compare(a, b Version) int

Compare returns -1, 0 or 1. A pre-release is older than its release.

Types

type Checker

type Checker struct {
	// Current is the running version, as built in ("dev" or unparsable means there is nothing to compare).
	Current string
	// URL is the latest-release address; empty means DefaultURL.
	URL string
	// Client makes the request; nil means one that honours the proxy environment and times out.
	Client *http.Client
	// Interval is the time between checks; zero means DefaultInterval.
	Interval time.Duration
	// Log gets one line per failed check; may be nil.
	Log func(msg string, err error)
	// contains filtered or unexported fields
}

Checker asks for the latest release and keeps the answer. Set Current.

func (*Checker) Check

func (c *Checker) Check(ctx context.Context) error

Check makes one request and updates Status. A 304 keeps the previous answer.

func (*Checker) Run

func (c *Checker) Run(ctx context.Context)

Run checks at once and then every Interval until ctx ends. Start it with go: the first request must not hold up anything.

func (*Checker) Status

func (c *Checker) Status() Status

Status is the last answer; before the first one, or when nothing is newer, UpdateAvailable is false.

type Status

type Status struct {
	Current         string `json:"current"`
	Latest          string `json:"latest,omitempty"`
	URL             string `json:"url,omitempty"`
	PublishedAt     string `json:"publishedAt,omitempty"`
	UpdateAvailable bool   `json:"updateAvailable"`
}

Status is what the page is told.

type Version

type Version struct {
	Major, Minor, Patch int
	Pre                 string
}

Version is a parsed semantic version: major.minor.patch with an optional pre-release (build metadata is dropped).

func Parse

func Parse(s string) (v Version, ok bool)

Parse reads "1.2.3", "v1.2.3" or "1.2.3-rc.1"; ok is false for anything else (including "dev").

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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