updater

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package updater verifies and applies Codog update manifests and artifacts.

Package updater implements manifest-based Codog binary update operations.

The updater intentionally keeps policy outside the package: callers decide which manifest URL and public key to trust, while this package fetches, verifies, downloads, installs, and rolls back artifacts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PlatformKey

func PlatformKey() string

PlatformKey returns the manifest platform key for the current GOOS/GOARCH.

func VerifyManifest

func VerifyManifest(manifest Manifest, publicKey string) error

VerifyManifest validates the Ed25519 signature embedded in manifest.

Types

type ArtifactInfo

type ArtifactInfo struct {
	Name       string `json:"name"`
	Path       string `json:"path"`
	Size       int64  `json:"size"`
	ModifiedAt string `json:"modified_at"`
	Executable bool   `json:"executable"`
}

ArtifactInfo describes one downloaded updater artifact on disk.

func ListArtifacts

func ListArtifacts(dir string) ([]ArtifactInfo, error)

ListArtifacts returns downloaded updater artifacts from dir.

type CheckResult

type CheckResult struct {
	CurrentVersion  string   `json:"current_version"`
	LatestVersion   string   `json:"latest_version"`
	UpdateAvailable bool     `json:"update_available"`
	Manifest        Manifest `json:"manifest"`
	SignatureValid  bool     `json:"signature_valid,omitempty"`
}

CheckResult reports whether a manifest advertises a newer version.

func Check

func Check(ctx context.Context, currentVersion, manifestURL string) (CheckResult, error)

Check fetches an update manifest and compares it to the current version.

func CheckSigned

func CheckSigned(ctx context.Context, currentVersion, manifestURL, publicKey string) (CheckResult, error)

CheckSigned fetches an update manifest, verifies its signature, and compares it to the current version.

type DownloadResult

type DownloadResult struct {
	Version  string `json:"version"`
	Platform string `json:"platform"`
	URL      string `json:"url"`
	Path     string `json:"path"`
	SHA256   string `json:"sha256"`
	Verified bool   `json:"verified"`
}

DownloadResult describes a downloaded updater artifact and its verification.

func Download

func Download(ctx context.Context, manifestURL, platform, destDir string) (DownloadResult, error)

Download fetches a manifest and downloads the artifact for platform.

func DownloadManifest

func DownloadManifest(ctx context.Context, manifest Manifest, platform, destDir string) (DownloadResult, error)

DownloadManifest downloads the artifact selected from an already loaded manifest. If platform is empty, PlatformKey is used.

func DownloadSigned

func DownloadSigned(ctx context.Context, manifestURL, platform, destDir, publicKey string) (DownloadResult, error)

DownloadSigned verifies a signed manifest before downloading its artifact.

type InstallResult

type InstallResult struct {
	Source     string `json:"source"`
	Target     string `json:"target"`
	BackupPath string `json:"backup_path,omitempty"`
	Installed  bool   `json:"installed"`
	RolledBack bool   `json:"rolled_back,omitempty"`
}

InstallResult describes an installed artifact and any created rollback backup.

func Install

func Install(artifactPath, targetPath string) (InstallResult, error)

Install atomically replaces targetPath with artifactPath where the platform permits rename-based replacement. Existing targets are backed up as .bak.

type Manifest

type Manifest struct {
	Version   string            `json:"version"`
	Notes     string            `json:"notes,omitempty"`
	Downloads map[string]string `json:"downloads,omitempty"`
	Checksums map[string]string `json:"checksums,omitempty"`
	Signature string            `json:"signature,omitempty"`
	Source    string            `json:"-"`
}

Manifest describes a release index served by an update source.

Downloads maps platform keys such as "darwin-arm64" to artifact URLs. Relative URLs are resolved against Source, which is set by FetchManifest.

func FetchManifest

func FetchManifest(ctx context.Context, manifestURL string) (Manifest, error)

FetchManifest downloads and decodes a release manifest from manifestURL.

type RollbackResult

type RollbackResult struct {
	Target     string `json:"target"`
	BackupPath string `json:"backup_path"`
	RolledBack bool   `json:"rolled_back"`
}

RollbackResult describes a successful restore from a previous install backup.

func Rollback

func Rollback(targetPath string) (RollbackResult, error)

Rollback restores targetPath from the .bak file created by Install.

Jump to

Keyboard shortcuts

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