updater

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReleaseInfo

type ReleaseInfo struct {
	Version      semver.Version `json:"version"`
	Channel      UpdateChannel  `json:"channel"`
	AssetURL     string         `json:"asset_url"`
	Signature    string         `json:"signature"`
	Checksum     string         `json:"checksum"`
	ReleaseNotes string         `json:"release_notes"`
}

ReleaseInfo contains information about a release

type RestartInfo

type RestartInfo struct {
	Args        []string  `json:"args"`
	Environment []string  `json:"environment"`
	WorkingDir  string    `json:"working_dir"`
	Timestamp   time.Time `json:"timestamp"`
}

RestartInfo contains information about the command to restart after update

type TelemetryData

type TelemetryData struct {
	Timestamp    time.Time     `json:"timestamp"`
	Success      bool          `json:"success"`
	FromVersion  string        `json:"from_version"`
	ToVersion    string        `json:"to_version"`
	Channel      UpdateChannel `json:"channel"`
	ErrorMessage string        `json:"error_message,omitempty"`
}

TelemetryData represents update telemetry information

type UpdateCache

type UpdateCache struct {
	LastCheck     time.Time     `json:"last_check"`
	LatestVersion string        `json:"latest_version"`
	Channel       UpdateChannel `json:"channel"`
	TTL           time.Duration `json:"ttl"`
}

UpdateCache stores information about the last update check

type UpdateChannel

type UpdateChannel string

UpdateChannel represents the release channel type

const (
	StableChannel UpdateChannel = "stable"
	BetaChannel   UpdateChannel = "beta"
)

type Updater

type Updater struct {
	CurrentVersion string
	GithubRepo     string
	CacheFile      string
	PublicKey      ed25519.PublicKey
	Channel        UpdateChannel
	TelemetryPath  string
	RestartPath    string
	// contains filtered or unexported fields
}

Updater handles the auto-update functionality

func New

func New(currentVersion, githubRepo string, channel UpdateChannel) (*Updater, error)

New creates a new Updater instance

func (*Updater) Check

func (u *Updater) Check() (*ReleaseInfo, error)

Check looks for available updates

func (*Updater) GetChangelog

func (u *Updater) GetChangelog(release *ReleaseInfo) string

GetChangelog retrieves the changelog for the release

func (*Updater) RestartAfterUpdate

func (u *Updater) RestartAfterUpdate() error

RestartAfterUpdate restarts the previously running command

func (*Updater) SaveRestartInfo

func (u *Updater) SaveRestartInfo() error

SaveRestartInfo saves the current command information for restart after update

func (*Updater) Update

func (u *Updater) Update(release *ReleaseInfo) error

Update performs the actual update

Jump to

Keyboard shortcuts

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