Documentation
¶
Index ¶
Constants ¶
const DefaultSource = "https://raw.githubusercontent.com/9Ashwin/sticker-ext/main"
DefaultSource is the public source used when --source is omitted.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
Kind string
Subtype string
Message string
Hint string
Retryable bool
Err error
}
Error is the stable failure contract for source discovery. Callers should branch on Kind and Subtype rather than Message.
type InstallOptions ¶
type InstallOptions struct {
Home string
Source string
PackID string
HTTPClient *http.Client
Backoff func(context.Context, time.Duration) error
Now func() time.Time
}
InstallOptions controls a complete pack installation. Image transfer is performed before the library lock is acquired; only the final validation and state publication run under that lock.
type InstallPlan ¶
type InstallPlan struct {
Source string `json:"source"`
Target string `json:"target"`
Pack Pack `json:"pack"`
Revision string `json:"revision"`
Added int `json:"added"`
Reused int `json:"reused"`
DownloadBytes int64 `json:"download_bytes"`
}
InstallPlan is the aggregate work estimate returned by a preflight.
func Plan ¶
func Plan(ctx context.Context, options PlanOptions) (InstallPlan, error)
Plan validates one explicitly selected pack and compares every referenced image with the local content. A missing image is counted as added; an existing image must pass both hashes, its declared size, and its format signature before it can be reused.
type InstallResult ¶
type InstallResult struct {
Source string `json:"source"`
Target string `json:"target"`
Pack Pack `json:"pack"`
Revision string `json:"revision"`
Added int `json:"added"`
Reused int `json:"reused"`
DownloadBytes int64 `json:"download_bytes"`
}
InstallResult describes the files published by one installation.
func Install ¶
func Install(ctx context.Context, options InstallOptions) (InstallResult, error)
Install downloads, validates, and publishes one selected pack. The source snapshot is fixed by its manifest revision. Incomplete transfers stay in a private staging directory and never make an installed state visible.
type Options ¶
type Options struct {
Home string
Source string
Offline bool
Now func() time.Time
HTTPClient *http.Client
Backoff func(context.Context, time.Duration) error
}
Options controls source discovery. Home is only used for the cache and may be empty, in which case DefaultHome resolves the platform data directory.
type Pack ¶
type Pack struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Revision string `json:"revision"`
Count int `json:"count"`
Size int64 `json:"size"`
Installed bool `json:"installed"`
}
Pack is the metadata shown by packs list. It intentionally excludes item bytes and image paths; discovering a source only reads catalog metadata.
type PlanOptions ¶
type PlanOptions struct {
Home string
Source string
PackID string
HTTPClient *http.Client
Backoff func(context.Context, time.Duration) error
}
PlanOptions controls an installation preflight. Planning reads the selected source manifest and the local library, but never downloads an image or creates local library, lock, or catalog files.
type RemoveOptions ¶
RemoveOptions controls removal of one installed pack relationship.
type RemoveResult ¶
type RemoveResult struct {
Removed bool `json:"removed"`
RetainedBytes int64 `json:"retained_bytes"`
Committed bool `json:"committed"`
StateCorrupt bool `json:"state_corrupt,omitempty"`
DryRun bool `json:"dry_run,omitempty"`
}
RemoveResult describes the state relationship removed by one operation. Original image bytes are retained for personal favorites and other packs.
func Remove ¶
func Remove(ctx context.Context, options RemoveOptions) (RemoveResult, error)
Remove uninstalls one pack by deleting only its installed state. It never deletes image files, so favorites and other installed packs remain usable. Repeating the operation after the state is absent is a successful no-op.
type RepairOptions ¶ added in v0.1.1
RepairOptions controls recovery of one invalid installed pack state.
type RepairResult ¶ added in v0.1.1
type RepairResult struct {
Repaired bool `json:"repaired"`
RetainedBytes int64 `json:"retained_bytes"`
Committed bool `json:"committed"`
DryRun bool `json:"dry_run,omitempty"`
}
RepairResult describes whether an invalid pack state was cleared. Original image files are retained and can be reused by a later installation.
func Repair ¶ added in v0.1.1
func Repair(ctx context.Context, options RepairOptions) (RepairResult, error)
Repair clears only a corrupt installed state. A valid state and an absent state are left untouched, making the command safe to run before reinstall.
type Result ¶
type Result struct {
Source string `json:"source"`
Items []Pack `json:"items"`
FetchedAt time.Time `json:"-"`
Stale bool `json:"stale"`
}
Result is the data returned by a catalog discovery operation.
func Discover ¶
Discover reads and validates a source catalog, using a source-keyed cache. Online discovery fetches packs.json and the referenced manifests, but never fetches any image files. Offline discovery reads only an existing cache.
func (Result) FetchedAtString ¶
FetchedAtString returns the stable wire representation used by the CLI.
type Source ¶
Source identifies a public HTTPS source or a local source directory.
type UpdateOptions ¶
type UpdateOptions struct {
Home string
PackID string
HTTPClient *http.Client
Backoff func(context.Context, time.Duration) error
Now func() time.Time
}
UpdateOptions controls a refresh of one installed pack. The source is read from the installed state so an update cannot silently switch origins.
type UpdatePlan ¶
type UpdatePlan = InstallPlan
UpdatePlan is the preflight result for an explicitly requested update. It has the same fields as an installation plan so callers can render both operations with one result contract.
func PlanUpdate ¶
func PlanUpdate(ctx context.Context, options UpdateOptions) (UpdatePlan, error)
PlanUpdate reads the saved source for an installed pack, fetches its latest validated manifest, and counts local work without creating library state or staging files.
type UpdateResult ¶
type UpdateResult = InstallResult
UpdateResult is the result of one explicitly requested pack update.
func Update ¶
func Update(ctx context.Context, options UpdateOptions) (UpdateResult, error)
Update downloads and validates a new manifest revision before replacing the installed state. The old state remains authoritative until every image in the new manifest has been persisted and verified.