selfupdate

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBinaryTemplate = "wings_linux_{arch}"

Variables

View Source
var (
	// ErrUnsupportedArch indicates that the current runtime architecture is not supported.
	ErrUnsupportedArch = errors.New("selfupdate: unsupported architecture")

	// ErrChecksumNotFound indicates that the requested checksum could not be found in the checksum file.
	ErrChecksumNotFound = errors.New("selfupdate: checksum not found for binary")

	// ErrChecksumRequired indicates that a checksum must be supplied for direct downloads.
	ErrChecksumRequired = errors.New("selfupdate: checksum required for direct download")
)

Functions

func DetermineBinaryName

func DetermineBinaryName(template string) (string, error)

DetermineBinaryName resolves the binary asset name using the provided template. The template may include the placeholder "{arch}", which will be replaced with the runtime architecture (amd64 or arm64). When template is empty, a default value is used.

func RunRestartCommand

func RunRestartCommand(ctx context.Context, command string) (string, error)

RunRestartCommand executes the provided restart command using /bin/sh -c and returns combined output.

func UpdateFromGitHub

func UpdateFromGitHub(ctx context.Context, owner string, repo string, release ReleaseInfo, binaryTemplate string, skipChecksum bool) (string, error)

func UpdateFromURL

func UpdateFromURL(ctx context.Context, downloadURL string, binaryName string, expectedChecksum string, skipChecksum bool) error

UpdateFromURL downloads a binary from the specified URL and replaces the current binary. If expectedChecksum is provided it will be validated prior to replacing the binary unless skipChecksum is true.

Types

type HTTPError

type HTTPError struct {
	StatusCode int
	URL        string
}

HTTPError represents a non-successful HTTP response from an upstream service.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type ReleaseAsset

type ReleaseAsset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

type ReleaseInfo

type ReleaseInfo struct {
	TagName string         `json:"tag_name"`
	Assets  []ReleaseAsset `json:"assets"`
}

func FetchLatestReleaseInfo

func FetchLatestReleaseInfo(ctx context.Context, owner string, repo string) (ReleaseInfo, error)

func FetchReleaseByTag

func FetchReleaseByTag(ctx context.Context, owner string, repo string, tag string) (ReleaseInfo, error)

Jump to

Keyboard shortcuts

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