updater

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultServerTokenEnv = "MOLTNET_UPDATE_SERVER_TOKEN"

Variables

This section is empty.

Functions

func AssetName

func AssetName(platform Platform) (string, error)

func CompareVersions

func CompareVersions(left string, right string) (int, error)

func ExtractMoltnetBinary

func ExtractMoltnetBinary(archive []byte, destinationDir string) (string, error)

func IsDevelopmentVersion

func IsDevelopmentVersion(version string) bool

func NormalizeVersion

func NormalizeVersion(version string) string

func ReplaceBinary

func ReplaceBinary(installPath string, replacementPath string) (string, error)

func VerifyChecksum

func VerifyChecksum(assetName string, archive []byte, manifest []byte) error

func WriteResult

func WriteResult(writer io.Writer, result Result) error

Types

type DefaultInstallDetector

type DefaultInstallDetector struct{}

func (DefaultInstallDetector) DetectInstall

func (DefaultInstallDetector) DetectInstall(_ context.Context, currentVersion string) (Install, error)

type HTTPClient

type HTTPClient interface {
	Do(request *http.Request) (*http.Response, error)
}

type HTTPReleaseSource

type HTTPReleaseSource struct {
	APIBase         string
	Client          HTTPClient
	DownloadBaseURL string
	GitHubBase      string
	OwnerRepo       string
}

func NewHTTPReleaseSource

func NewHTTPReleaseSource(client HTTPClient) HTTPReleaseSource

func (HTTPReleaseSource) Archive

func (s HTTPReleaseSource) Archive(ctx context.Context, version string, assetName string) ([]byte, error)

func (HTTPReleaseSource) Checksums

func (s HTTPReleaseSource) Checksums(ctx context.Context, version string) ([]byte, error)

func (HTTPReleaseSource) InstallMetadata

func (s HTTPReleaseSource) InstallMetadata() ReleaseSourceMetadata

func (HTTPReleaseSource) LatestVersion

func (s HTTPReleaseSource) LatestVersion(ctx context.Context) (string, error)

type HTTPServerProbe

type HTTPServerProbe struct {
	Client HTTPClient
}

func (HTTPServerProbe) ProbeServer

func (p HTTPServerProbe) ProbeServer(ctx context.Context, probe ServerProbeRequest) (ServerInfo, error)

type Install

type Install struct {
	Method            InstallMethod
	Path              string
	SelfUpdateAllowed bool
}

type InstallDetector

type InstallDetector interface {
	DetectInstall(ctx context.Context, currentVersion string) (Install, error)
}

type InstallMethod

type InstallMethod string
const (
	InstallMethodReleaseTarball InstallMethod = "release-tarball"
	InstallMethodSource         InstallMethod = "source"
	InstallMethodContainer      InstallMethod = "container"
	InstallMethodUnknown        InstallMethod = "unknown"
)

type Options

type Options struct {
	CheckOnly      bool
	CurrentVersion string
	Detector       InstallDetector
	DryRun         bool
	LockPath       string
	LockStaleAfter time.Duration
	Platform       Platform
	ReleaseSource  ReleaseSource
	ServerProbe    ServerProbe
	ServerToken    string
	ServerTokenEnv string
	ServerURL      string
	TargetVersion  string
	TempDir        string
	Yes            bool
}

type Platform

type Platform struct {
	Arch string
	OS   string
}

func CurrentPlatform

func CurrentPlatform() Platform

func (Platform) WithDefaults

func (p Platform) WithDefaults() Platform

type ReleaseSource

type ReleaseSource interface {
	LatestVersion(ctx context.Context) (string, error)
	Archive(ctx context.Context, version string, assetName string) ([]byte, error)
	Checksums(ctx context.Context, version string) ([]byte, error)
}

type ReleaseSourceMetadata

type ReleaseSourceMetadata struct {
	DownloadBaseURL string
	OwnerRepo       string
}

type Result

type Result struct {
	AssetName         string
	BackupPath        string
	ChecksumAvailable bool
	CheckOnly         bool
	CurrentVersion    string
	DryRun            bool
	Install           Install
	LatestVersion     string
	MutationRefused   bool
	Server            ServerInfo
	TargetVersion     string
	Updated           bool
	UpdateAvailable   bool
	Warnings          []string
}

func Run

func Run(ctx context.Context, options Options) (Result, error)

func (Result) String

func (r Result) String() string

type ServerInfo

type ServerInfo struct {
	URL     string
	Version string
	Warning string
}

type ServerProbe

type ServerProbe interface {
	ProbeServer(ctx context.Context, request ServerProbeRequest) (ServerInfo, error)
}

type ServerProbeRequest

type ServerProbeRequest struct {
	Token string
	URL   string
}

Jump to

Keyboard shortcuts

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