version

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Copyright © 2022 Diego Morales <dgmorales@gmail.com>

Index

Constants

This section is empty.

Variables

View Source
var Current string

Functions

This section is empty.

Types

type Assertion added in v0.3.0

type Assertion int

Assertion informs if our version is latest, can or must update.

Its values may be used as shell exit status codes for a version check command.

const (
	IsLatest   Assertion = 0
	CanUpdate  Assertion = 10
	MustUpdate Assertion = 20
	IsBeyond   Assertion = 30 // Beyond current version: development version
	IsUnknown  Assertion = 60
)

won't use iota bellow because values matter for use as exit codes Avoid using 1 and 2 that are frequently used as more general error exit codes for commands: https://tldp.org/LDP/abs/html/exitcodes.html

type Checker added in v0.3.0

type Checker interface {
	Minimal() string
	Current() string
	Latest() string
	Check() Assertion
	DownloadLatest() (filename string, err error)
}

type GitHubChecker added in v0.3.0

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

func NewGithubChecker added in v0.3.0

func NewGithubChecker(client *github.Client, owner string, repo string, minimalReq string, current string) (*GitHubChecker, error)

DiscoverLatest discovers what is the latest version from GitHub Releases

It already saves asset information, leaving everything ready for calling Download()

func (*GitHubChecker) Check added in v0.3.0

func (c *GitHubChecker) Check() Assertion

Check discovers if the current version can or must be updated.

More precisely, it checks in which version.Assertion case the current version falls in.

It tries to be resilient and always return the best assertion it can about the current version. So for example, if the minimal version is unknown it will ignore that check and check against the latest.

If it cannot tell anything, it returns is IsUnknown.

func (*GitHubChecker) Current added in v0.3.0

func (c *GitHubChecker) Current() string

Current returns current version as string

func (*GitHubChecker) DownloadLatest added in v0.3.0

func (c *GitHubChecker) DownloadLatest() (filename string, err error)

DownloadLatest downloads the saved GitHub Release Asset to a temporary file

func (*GitHubChecker) Latest added in v0.3.0

func (c *GitHubChecker) Latest() string

Latest returns latest version as string

func (*GitHubChecker) Minimal added in v0.3.0

func (c *GitHubChecker) Minimal() string

Minimal returns minimal required version as string

Jump to

Keyboard shortcuts

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