version

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

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

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
)

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, error)
	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, error)

Check checks if current version can or must be updated

It is OK for the version information on cliInfo to be unset (nil), maybe because of previous errors parsing it. That is a noop and will return IsLatest and nil error on that case.

It does return error on some very abnormal cases (gross programming errors)

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)

Download 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