inventory

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 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 inventory keeps track of the artifacts drop installs in the local system. The data lives in a single versioned JSON document in the user's configuration directory and records, for every installed app, what was installed and enough metadata to later verify, update or uninstall it.

Index

Constants

View Source
const FileName = "installed.json"

FileName is the name of the inventory database file.

View Source
const Version = 1

Version is the current schema version of the inventory file.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the location of the inventory database in the user's configuration directory.

Types

type Inventory

type Inventory struct {
	Version  int                `json:"version"`
	Installs map[string]*Record `json:"installs"`
	// contains filtered or unexported fields
}

Inventory is the database of artifacts installed by drop.

func Open

func Open() (*Inventory, error)

Open loads the inventory from its default location, returning an empty inventory if no database exists yet.

func OpenFile

func OpenFile(path string) (*Inventory, error)

OpenFile loads the inventory from a file, returning an empty inventory bound to the path if the file does not exist yet.

func (*Inventory) Add

func (inv *Inventory) Add(record *Record)

Add upserts a record into the inventory. When the app is already recorded, the original installation timestamp is preserved.

func (*Inventory) Get

func (inv *Inventory) Get(key string) *Record

Get returns the record stored under a key or nil if there is none.

func (*Inventory) Remove

func (inv *Inventory) Remove(key string) bool

Remove deletes the record stored under a key, returning true if it existed.

func (*Inventory) Save

func (inv *Inventory) Save() error

Save atomically writes the inventory back to the file it was loaded from.

type Record

type Record struct {
	// Repository coordinates and installable name identifying the app.
	Host string `json:"host"`
	Org  string `json:"org"`
	Repo string `json:"repo"`
	Name string `json:"name"`

	// Version is the release tag the installed artifact came from.
	Version string `json:"version"`

	// Kind is the artifact type that was installed (binary, package or
	// archive).
	Kind string `json:"kind"`

	// Asset is the exact release asset that was downloaded.
	Asset string `json:"asset"`

	// Digest captures the hashes of the verified artifact, keyed by
	// algorithm. For binaries it can be checked against the installed
	// file, for packages integrity checks are delegated to the package
	// manager and the digest ties the record to the verified file.
	Digest map[string]string `json:"digest,omitempty"`

	// BinPath is the path where the binary was installed (binaries and
	// archives only).
	BinPath string `json:"binPath,omitempty"`

	// ArchiveEntry is the path inside the release archive of the file that
	// was installed (archives only). Updates reuse it to pick the same
	// file without asking again.
	ArchiveEntry string `json:"archiveEntry,omitempty"`

	// PackageFormat is the package type handed to the package manager
	// (packages only).
	PackageFormat string `json:"packageFormat,omitempty"`

	// Verified records if the artifact passed policy verification or was
	// installed with verification disabled.
	Verified bool `json:"verified"`

	InstalledAt time.Time `json:"installedAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

Record stores the data of one installed app.

func (*Record) Key

func (r *Record) Key() string

Key returns the string keying the record in the inventory.

Jump to

Keyboard shortcuts

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