updater

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: MIT Imports: 8 Imported by: 0

README

Updater

Check for Update

updater -github keys-pub/app -app-name Keys -current 0.0.17

{
  "version": "0.0.18",
  "publishedAt": 1583275443689,
  "asset": {
    "name": "Keys-0.0.18-mac.zip",
    "url": "https://github.com/keys-pub/app/releases/latest/download/Keys-0.0.18-mac.zip",
    "digest": "9fe462603acbd84e55e5dfa6a02f40d0483551c88bd053b4b3827aba67d7fe3e53414a2214f6387a02e0bfc667d464ed0cc494f14b6ca04ae5ca81a20d503618",
    "digestType": "sha512",
    "localPath": ""
  },
  "needUpdate": true
}

Download Update

updater -github keys-pub/app -app-name Keys -current 0.0.17 -download

{
  "version": "0.0.18",
  "publishedAt": 1583275443689,
  "asset": {
    "name": "Keys-0.0.18-mac.zip",
    "url": "https://github.com/keys-pub/app/releases/latest/download/Keys-0.0.18-mac.zip",
    "digest": "9fe462603acbd84e55e5dfa6a02f40d0483551c88bd053b4b3827aba67d7fe3e53414a2214f6387a02e0bfc667d464ed0cc494f14b6ca04ae5ca81a20d503618",
    "digestType": "sha512",
    "localPath": "/var/folders/84/7q50__3j4yscqtt4qmrv8rtr0000gn/T/updater/Keys/Keys-0.0.18-mac.zip"
  },
  "needUpdate": true
}

Apply Update

updater -github keys-pub/app -app-name Keys -current 0.0.17 -download -apply /Applications/Keys.app

Documentation

Index

Constants

View Source
const Version = "0.2.3"

Version is the updater version

Variables

This section is empty.

Functions

func Cleanup added in v0.1.5

func Cleanup(appName string, except string)

Cleanup files, except for a path (presumably the update). You can do this after you download an update, so that if the update already exists it doesn't have to be re-downloaded, which removes all other files except the current update.

func SetLogger

func SetLogger(l Logger)

SetLogger sets logger for the package.

Types

type Asset

type Asset struct {
	// Name of file.
	Name string `json:"name"`
	// URL to request from.
	URL string `json:"url"`
	// Digest is hex encoded digest.
	Digest string `json:"digest"`
	// DigestType is sha256 by default. Also supports "sha512".
	DigestType string `json:"digestType"`
	// LocalPath is where downloaded file resides.
	LocalPath string `json:"localPath"`
}

Asset describes a downloadable file

type ContextLogger

type ContextLogger interface {
	Debugf(ctx context.Context, format string, args ...interface{})
	Infof(ctx context.Context, format string, args ...interface{})
	Warningf(ctx context.Context, format string, args ...interface{})
	Errorf(ctx context.Context, format string, args ...interface{})
}

ContextLogger interface used in this package with request context.

func NewContextLogger

func NewContextLogger(lev LogLevel) ContextLogger

NewContextLogger ...

type LogLevel

type LogLevel int

LogLevel ...

const (
	// DebugLevel ...
	DebugLevel LogLevel = 3
	// InfoLevel ...
	InfoLevel LogLevel = 2
	// WarnLevel ...
	WarnLevel LogLevel = 1
	// ErrLevel ...
	ErrLevel LogLevel = 0
)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger interface used in this package.

func NewLogger

func NewLogger(lev LogLevel) Logger

NewLogger ...

type Property

type Property struct {
	Name  string `codec:"name" json:"name"`
	Value string `codec:"value" json:"value"`
}

Property is a generic key value pair for custom properties

type Update

type Update struct {
	Version     string     `json:"version"`
	PublishedAt int64      `json:"publishedAt"`
	Props       []Property `codec:"props" json:"props,omitempty"`
	Asset       *Asset     `json:"asset,omitempty"`
	NeedUpdate  bool       `json:"needUpdate"`
	Applied     string     `json:"applied"`
}

Update describes an update. If update is needed, NeedUpdate will be true. If update is downloaded, Asset.LocalPath will be set. If update was applied, Applied is set to the destination.

type UpdateOptions

type UpdateOptions struct {
	// Version is the current version of the app
	Version string `json:"version"`
	// AppName is name of the app
	AppName string `json:"appName"`
	// Prerelease will request latest prerelease
	Prerelease bool `json:"prerelease"`
}

UpdateOptions are options used to find an update

type UpdateSource

type UpdateSource interface {
	// Description is a short description about the update source
	Description() string
	// FindUpdate finds an update given options
	FindUpdate(options UpdateOptions) (*Update, error)
}

UpdateSource defines where the updater can find updates

type Updater

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

Updater knows how to find and apply updates

func NewUpdater

func NewUpdater(source UpdateSource) *Updater

NewUpdater constructs an Updater

func (*Updater) CheckForUpdate

func (u *Updater) CheckForUpdate(options UpdateOptions) (*Update, error)

CheckForUpdate checks a update source for an update.

func (*Updater) Download

func (u *Updater) Download(update *Update, options UpdateOptions) error

Download an update. If downloaded update.Asset.LocalPath is set to downloaded path.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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