ghupdate

package
v0.18.7 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package ghupdate implements a new command to self update the current executable with the latest GitHub release. This is based on PocketBase's ghupdate package with modifications.

Index

Constants

View Source
const (
	ColorYellow = "\033[33m"
	ColorGreen  = "\033[32m"
)

Minimal color functions using ANSI escape codes

Variables

This section is empty.

Functions

func ColorPrint

func ColorPrint(color, text string)

func ColorPrintf

func ColorPrintf(color, format string, args ...any)

func FetchLatestRelease added in v0.18.5

func FetchLatestRelease(ctx context.Context, client HttpClient, url string) (*release, error)

func HandleSELinuxContext added in v0.18.3

func HandleSELinuxContext(path string) error

HandleSELinuxContext restores or applies the correct SELinux label to the binary.

func Update

func Update(config Config) (updated bool, err error)

Types

type Config

type Config struct {
	// Owner specifies the account owner of the repository (default to "pocketbase").
	Owner string

	// Repo specifies the name of the repository (default to "pocketbase").
	Repo string

	// ArchiveExecutable specifies the name of the executable file in the release archive
	// (default to "pocketbase"; an additional ".exe" check is also performed as a fallback).
	ArchiveExecutable string

	// Optional context to use when fetching and downloading the latest release.
	Context context.Context

	// The HTTP client to use when fetching and downloading the latest release.
	// Defaults to `http.DefaultClient`.
	HttpClient HttpClient

	// The data directory to use when fetching and downloading the latest release.
	DataDir string

	// UseMirror specifies whether to use the beszel.dev mirror instead of GitHub API.
	// When false (default), always uses api.github.com. When true, uses gh.beszel.dev.
	UseMirror bool
}

Config defines the config options of the ghupdate plugin.

NB! This plugin is considered experimental and its config options may change in the future.

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HttpClient is a base HTTP client interface (usually used for test purposes).

Jump to

Keyboard shortcuts

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