selfupdate

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadAndApply

func DownloadAndApply(i CliInfo, gh *github.Client) error

func NewClient

func NewClient() *github.Client

NewClient creates a new GitHub client

func StringToVersionHookFunc

func StringToVersionHookFunc(from reflect.Type, to reflect.Type, data interface{}) (interface{}, error)

StringToVersionHookFunc is a mapstructure HookFunc to convert a string to a hashicorp/go-version Version pointer

This will be passed to mapstructure.Decoder and called for every field in the source structure being mapped, so we must "passthrough" if the field types don't match

func Uncompress

func Uncompress(filename string) (io.Reader, func(), error)

Types

type CliInfo

type CliInfo struct {
	RepositoryOwner        string
	RepositoryName         string
	MinimalRequiredVersion *semver.Version
	LatestVersion          *semver.Version
	// contains filtered or unexported fields
}

type UpdateDecision added in v0.2.1

type UpdateDecision int

UpdateDecision 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   UpdateDecision = 0
	CanUpdate  UpdateDecision = 10
	MustUpdate UpdateDecision = 20
)

won't use iota bellow because values matter

func Check

func Check(i *CliInfo, gh *github.Client) (UpdateDecision, error)

checkVersion checks if current version can or must be updated

check is internal and meant to be easily testable 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)

Jump to

Keyboard shortcuts

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