Documentation
¶
Index ¶
- Constants
- func AssetName(platform Platform) (string, error)
- func CompareVersions(left string, right string) (int, error)
- func ExtractMoltnetBinary(archive []byte, destinationDir string) (string, error)
- func IsDevelopmentVersion(version string) bool
- func NormalizeVersion(version string) string
- func ReplaceBinary(installPath string, replacementPath string) (string, error)
- func ResolveHome() string
- func VerifyChecksum(assetName string, archive []byte, manifest []byte) error
- func WriteResult(writer io.Writer, result Result, verbose bool) error
- type CommandRunner
- type DefaultInstallDetector
- type HTTPClient
- type HTTPReleaseSource
- func (s HTTPReleaseSource) Archive(ctx context.Context, version string, assetName string) ([]byte, error)
- func (s HTTPReleaseSource) Checksums(ctx context.Context, version string) ([]byte, error)
- func (s HTTPReleaseSource) InstallMetadata() ReleaseSourceMetadata
- func (s HTTPReleaseSource) LatestVersion(ctx context.Context) (string, error)
- type HTTPServerProbe
- type Install
- type InstallDetector
- type InstallMethod
- type Options
- type Platform
- type ReleaseSource
- type ReleaseSourceMetadata
- type Result
- type ServerInfo
- type ServerProbe
- type ServerProbeRequest
- type SourceUpdatePlan
Constants ¶
const DefaultServerTokenEnv = "MOLTNET_UPDATE_SERVER_TOKEN"
Variables ¶
This section is empty.
Functions ¶
func ExtractMoltnetBinary ¶
func IsDevelopmentVersion ¶
func NormalizeVersion ¶
func ResolveHome ¶ added in v0.1.15
func ResolveHome() string
ResolveHome returns the directory updater reads and writes install/update state in (install.json, update.lock): MOLTNET_HOME when set, otherwise ~/.moltnet. It is exported so `moltnet uninstall` can detect a MOLTNET_HOME override that points outside the ~/.moltnet it already handles, using the exact same resolution this package uses to read/write that state, so the two can never drift apart.
func WriteResult ¶
WriteResult writes result's report to writer. verbose additionally includes a source update's per-step detail (git pull, make build, binary replace, version verify); every other field already prints unconditionally, matching this CLI family's "core facts always show, extra narration is --verbose-only" convention.
Types ¶
type CommandRunner ¶ added in v0.1.15
type CommandRunner interface {
Run(ctx context.Context, dir string, name string, args ...string) ([]byte, error)
}
CommandRunner executes one external command (git or make) rooted at dir and returns its combined output. Production code uses defaultCommandRunner; tests inject a fake so they never touch a real git binary or a real make against the checkout this package lives in.
type DefaultInstallDetector ¶
type DefaultInstallDetector struct{}
func (DefaultInstallDetector) DetectInstall ¶
type HTTPReleaseSource ¶
type HTTPReleaseSource struct {
APIBase string
Client HTTPClient
DownloadBaseURL string
GitHubBase string
OwnerRepo string
}
func NewHTTPReleaseSource ¶
func NewHTTPReleaseSource(client HTTPClient) HTTPReleaseSource
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
// SourceCheckout is the source checkout path for a source-method
// install, populated by Run from Options.SourceCheckout. Empty when the
// install method is not source, or when the binary carries no stamp.
SourceCheckout string
}
type InstallDetector ¶
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
CommandRunner CommandRunner
CurrentVersion string
Detector InstallDetector
DryRun bool
LockPath string
LockStaleAfter time.Duration
Platform Platform
ReleaseSource ReleaseSource
ServerProbe ServerProbe
ServerToken string
ServerTokenEnv string
ServerURL string
// SourceCheckout is the ldflags-stamped source checkout path from the
// running binary (main.sourceCheckout in cmd/moltnet), forwarded here so
// Run can attempt a source-install update. Empty on a binary built
// without the stamp, which degrades to the plain source-install refusal.
SourceCheckout string
TargetVersion string
TempDir string
Yes bool
}
type Platform ¶
func CurrentPlatform ¶
func CurrentPlatform() Platform
func (Platform) WithDefaults ¶
type ReleaseSource ¶
type ReleaseSourceMetadata ¶
type Result ¶
type Result struct {
AssetName string
BackupPath string
ChecksumAvailable bool
CheckOnly bool
CurrentVersion string
DryRun bool
Install Install
LatestVersion string
MutationRefused bool
// RefusalReason is the exact reason a real (mutating) run refused,
// set whenever MutationRefused is true. It is deliberately kept out of
// Warnings for a real run: main.go already prints the returned error
// (this same text) to stderr, so also queuing it as a stdout warning
// would print the identical sentence twice. --check/--dry-run never set
// this — a refusal there is informational only and stays in Warnings,
// since no error is returned to echo it.
RefusalReason string
Server ServerInfo
// SourceUpdate is set only when the resolved install is a source build
// with a usable stamped checkout: it carries the git status a source
// update inspected or acted on. Nil for release-tarball, container, and
// unknown installs, and for source installs with no usable checkout.
SourceUpdate *SourceUpdatePlan
TargetVersion string
Updated bool
UpdateAvailable bool
Warnings []string
}
type ServerInfo ¶
type ServerProbe ¶
type ServerProbe interface {
ProbeServer(ctx context.Context, request ServerProbeRequest) (ServerInfo, error)
}
type ServerProbeRequest ¶
type SourceUpdatePlan ¶ added in v0.1.15
type SourceUpdatePlan struct {
Branch string
Checkout string
Clean bool
Detached bool
LocalCommit string
PulledCommit string
RebuildNeeded bool
Steps []string
UpstreamCommit string
UpstreamKnown bool
}
SourceUpdatePlan reports what a source install's `moltnet update` found or did: the git status it inspected, and — only once a mutation actually ran — the steps it took, in order.