upgrade

package
v0.9.23 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package upgrade provides automatic update functionality for csghub-lite

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(result *Result, progress ProgressFunc) error

Apply downloads and installs the update

func ApplyWithVersion

func ApplyWithVersion(result *Result, progress ProgressFunc) error

ApplyWithVersion applies the update with version context

func Restart

func Restart() error

Restart restarts the application with the new binary

func RestartAfter

func RestartAfter(delay time.Duration) error

RestartAfter starts a replacement process and exits the current process after delay. On Unix, a small shell helper waits for this process to exit before starting the new binary so the server port can be rebound cleanly.

func SetVersion

func SetVersion(v string)

SetVersion sets the current application version

Types

type GitHubRelease

type GitHubRelease struct {
	TagName     string    `json:"tag_name"`
	Name        string    `json:"name"`
	Body        string    `json:"body"`
	PublishedAt time.Time `json:"published_at"`
	Assets      []struct {
		Name               string `json:"name"`
		BrowserDownloadURL string `json:"browser_download_url"`
	} `json:"assets"`
}

GitHubRelease represents a GitHub release

type GitLabPackage

type GitLabPackage struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

GitLabPackage represents a GitLab package

type Progress

type Progress struct {
	Downloaded int64
	Total      int64
}

Progress represents download progress

type ProgressFunc

type ProgressFunc func(Progress)

ProgressFunc is a callback for download progress

type Region

type Region string

Region represents the deployment region

const (
	RegionCN   Region = "CN"
	RegionINTL Region = "INTL"
)

type Result

type Result struct {
	CurrentVersion  string    `json:"current_version"`
	LatestVersion   string    `json:"latest_version"`
	Available       bool      `json:"available"`
	ReleaseNotes    string    `json:"release_notes"`
	PublishedAt     time.Time `json:"published_at"`
	DownloadURL     string    `json:"download_url"`
	GitLabMirrorURL string    `json:"gitlab_mirror_url"`
}

Result contains information about an available update

func Check

func Check() (*Result, error)

Check checks if a new version is available

func CheckWithVersion

func CheckWithVersion(currentVersion string) (*Result, error)

CheckWithVersion checks if a new version is available for a specific version

type Updater

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

Updater handles the upgrade process

func NewUpdater

func NewUpdater(currentVersion string) *Updater

NewUpdater creates a new Updater instance

func (*Updater) CheckForUpdate

func (u *Updater) CheckForUpdate(ctx context.Context) (*Result, error)

CheckForUpdate checks if a new version is available

func (*Updater) GetLatestVersion

func (u *Updater) GetLatestVersion(ctx context.Context) (string, error)

GetLatestVersion fetches the latest version string

func (*Updater) PerformUpgrade

func (u *Updater) PerformUpgrade(ctx context.Context, result *Result) error

PerformUpgrade downloads and installs the latest version

func (*Updater) PerformUpgradeWithProgress

func (u *Updater) PerformUpgradeWithProgress(ctx context.Context, result *Result, progress ProgressFunc) error

PerformUpgradeWithProgress downloads and installs the latest version with progress callback

func (*Updater) WithRegion

func (u *Updater) WithRegion(region Region) *Updater

WithRegion sets a specific region for the updater

Jump to

Keyboard shortcuts

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