receipt

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package receipt reads and writes the records of the trees sofcat placed for zip items: one JSON file per tree at <dir>/<placement>/<item>.json. The service keeps its receipts under <data dir>/receipts; other callers, such as a per-user helper, pass their own directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(dir, placement, item string) error

Delete removes the receipt for item in placement. A missing receipt is not an error.

func MachineDir

func MachineDir(dataDir string) string

MachineDir is the service's receipt directory inside its data directory.

func Write

func Write(dir string, r Receipt) error

Write saves r, replacing any receipt for the same placement and item. It writes a temporary file beside the receipt and renames it into place, so a reader never sees a partial receipt.

Types

type Receipt

type Receipt struct {
	Item      string `json:"item"`
	Version   string `json:"version"`
	Placement string `json:"placement"`
	// Path is the tree's directory: <placement root>/<item>, or
	// <placement root>/plugins/<item> in a marketplace.
	Path string `json:"path"`
	// TreeHash is the catalog's hash of the archive's contents.
	TreeHash string `json:"tree_hash"`
	// PlacedHash is the hash of the tree as sofcat wrote it, rendered files
	// included: TreeHash when nothing was rendered. Read fills it from
	// TreeHash for a receipt written before it existed.
	PlacedHash string `json:"placed_hash"`
	// Rendered records each file sofcat rendered inside the tree, in path
	// order. Write saves it as [] when there is none, never omits it.
	Rendered []Rendered `json:"rendered"`
	// Managed is true when a manifest lists the item in managed_installs.
	Managed        bool      `json:"managed"`
	InstalledAtUTC time.Time `json:"installed_at_utc"`
}

Receipt records one placed tree.

func ForItem

func ForItem(dir, item string) ([]Receipt, error)

ForItem returns item's receipts under dir, in List order.

func List

func List(dir string) ([]Receipt, error)

List returns every receipt under dir, sorted by placement and then item. A missing dir has none. A receipt that cannot be read fails the whole list: a caller deciding what to remove must not act on a partial view.

func Read

func Read(dir, placement, item string) (r Receipt, ok bool, err error)

Read returns the receipt for item in placement. ok is false, with a nil error, when there is none.

type Rendered

type Rendered struct {
	// File and Template are slash-separated paths relative to the tree.
	File     string `json:"file"`
	Template string `json:"template"`
	// Inputs is what the render used: os, scope, user, item (name, version,
	// managed) and the facts the template read. It is kept as written, so a
	// number compares as written when the next run asks whether the inputs
	// changed.
	Inputs json.RawMessage `json:"inputs"`
}

Rendered records one file sofcat rendered inside a tree from a template the tree ships.

Jump to

Keyboard shortcuts

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