update

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package update implements the explicit javdb self-update workflow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupPendingWindowsUpdate

func CleanupPendingWindowsUpdate() error

CleanupPendingWindowsUpdate has no work outside Windows.

func NewReleaseHTTPClient

func NewReleaseHTTPClient(proxy string) (*http.Client, error)

NewReleaseHTTPClient creates the GitHub client used only by javdb update. A blank proxy preserves the Go transport's documented HTTPS_PROXY/ALL_PROXY behavior.

Types

type BinaryChecker

type BinaryChecker interface {
	Check(context.Context, string, string) error
}

BinaryChecker validates a downloaded binary before it can replace javdb.

type BinaryCheckerFunc

type BinaryCheckerFunc func(context.Context, string, string) error

BinaryCheckerFunc adapts a function for installer tests.

func (BinaryCheckerFunc) Check

func (f BinaryCheckerFunc) Check(ctx context.Context, path, version string) error

Check invokes the wrapped binary checker.

type CommandRunner

type CommandRunner interface {
	Run(context.Context, string, ...string) error
}

CommandRunner executes package-manager commands without shell interpolation.

func NewCommandRunner

func NewCommandRunner(stdout, stderr io.Writer) CommandRunner

NewCommandRunner returns the production package-manager runner.

type Coordinator

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

Coordinator chooses a safe update strategy for the detected installation source.

func NewCoordinator

func NewCoordinator(options CoordinatorOptions) (*Coordinator, error)

NewCoordinator validates the dependencies shared by command and tests.

func (*Coordinator) Execute

func (c *Coordinator) Execute(ctx context.Context, request Request) (Result, error)

Execute checks for a newer release and, unless --check was requested, installs it.

type CoordinatorOptions

type CoordinatorOptions struct {
	SourceDetector   SourceDetector
	ReleaseChecker   ReleaseChecker
	CommandRunner    CommandRunner
	ReleaseInstaller ReleaseInstaller
}

CoordinatorOptions provides external dependencies for a testable update flow.

type GitHubReleaseClient

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

GitHubReleaseClient reads GitHub's public Releases API.

func NewGitHubReleaseClient

func NewGitHubReleaseClient(options ReleaseClientOptions) (*GitHubReleaseClient, error)

NewGitHubReleaseClient constructs an unauthenticated Release reader.

func (*GitHubReleaseClient) Check

func (c *GitHubReleaseClient) Check(ctx context.Context, includePrerelease bool) (*Release, error)

Check returns the highest SemVer release. GitHub page links are followed until exhausted so a repository with more than one API page is not silently truncated.

type InstallSource

type InstallSource string

InstallSource describes the package manager or artifact that owns javdb.

const (
	InstallSourceDevelopment InstallSource = "development"
	InstallSourceHomebrew    InstallSource = "homebrew"
	InstallSourceGoInstall   InstallSource = "go-install"
	InstallSourceRelease     InstallSource = "release"
)

func DetectInstallSource

func DetectInstallSource(info buildinfo.Info) (InstallSource, error)

DetectInstallSource identifies managed binaries before a write is attempted.

type Release

type Release struct {
	TagName    string         `json:"tag_name"`
	Prerelease bool           `json:"prerelease"`
	Assets     []ReleaseAsset `json:"assets"`
}

Release is a verified candidate returned by the GitHub Releases API.

type ReleaseAsset

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

ReleaseAsset is the subset of GitHub Release asset metadata used by updater.

type ReleaseChecker

type ReleaseChecker interface {
	Check(context.Context, bool) (*Release, error)
}

ReleaseChecker resolves the highest compatible published GitHub Release.

type ReleaseClientOptions

type ReleaseClientOptions struct {
	HTTPClient *http.Client
	Endpoint   string
}

ReleaseClientOptions exposes the API endpoint for deterministic tests.

type ReleaseInstaller

type ReleaseInstaller interface {
	Install(context.Context, Release) error
}

ReleaseInstaller installs an already selected release for the current platform.

func NewReleaseInstaller

func NewReleaseInstaller(options ReleaseInstallerOptions) ReleaseInstaller

NewReleaseInstaller creates the production archive updater. Every write is delayed until the archive checksum and the embedded binary version both match.

type ReleaseInstallerOptions

type ReleaseInstallerOptions struct {
	HTTPClient        *http.Client
	ExecutablePath    func() (string, error)
	GOOS              string
	GOARCH            string
	BinaryChecker     BinaryChecker
	Replacer          func(string, string) error
	AssetURLValidator func(Release, ReleaseAsset) error
}

ReleaseInstallerOptions injects system boundaries for deterministic tests.

type Request

type Request struct {
	BuildInfo         buildinfo.Info
	Check             bool
	IncludePrerelease bool
}

Request describes an explicit javdb update invocation.

type Result

type Result struct {
	Source           InstallSource `json:"source"`
	CurrentVersion   string        `json:"current_version"`
	LatestVersion    *string       `json:"latest_version"`
	LatestPrerelease bool          `json:"latest_prerelease"`
	UpdateAvailable  bool          `json:"update_available"`
}

Result is stable status output for human and JSON update checks.

type SourceDetector

type SourceDetector interface {
	Detect(buildinfo.Info) (InstallSource, error)
}

SourceDetector determines which installer owns the currently running binary.

type SourceDetectorFunc

type SourceDetectorFunc func(buildinfo.Info) (InstallSource, error)

SourceDetectorFunc adapts a function for coordinator tests and composition.

func (SourceDetectorFunc) Detect

Detect calls the wrapped source detector.

Jump to

Keyboard shortcuts

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