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 ¶
const FileName = "installed.json"
FileName is the name of the inventory database file.
const Version = 1
Version is the current schema version of the inventory file.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
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 ¶
Open loads the inventory from its default location, returning an empty inventory if no database exists yet.
func OpenFile ¶
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 ¶
Add upserts a record into the inventory. When the app is already recorded, the original installation timestamp is preserved.
func (*Inventory) Dir ¶ added in v0.2.2
Dir returns the directory of the file the inventory is bound to, where the files it refers to are kept. It is empty when the inventory is not bound to a file.
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"`
// OS and Arch are the platform of the asset, when the release tells.
// The policies an asset is verified with can read them, so verifying
// it again takes them.
OS string `json:"os,omitempty"`
Arch string `json:"arch,omitempty"`
// 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"`
// FileDigest captures the hashes of the file that was installed, keyed
// by algorithm (binaries and archives only). For a binary it is the
// digest of the verified artifact; for an archive, that of the file
// extracted from it. It is what tells if the installed file is still
// the one that was installed.
FileDigest map[string]string `json:"fileDigest,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"`
// Verification points to the results of the verification the artifact
// passed when it was installed, kept with the evidence it was verified
// on. It is absent when the artifact was installed without verifying
// it, or recorded before the results were kept.
Verification *Verification `json:"verification,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) InstalledDigest ¶ added in v0.2.2
InstalledDigest returns the hashes the installed file is expected to have, nil when the record does not tell: a package, whose files are the package manager's, or an archive recorded before the digest of the extracted file was kept. A binary recorded without it has the digest of its artifact, which is the file that was installed.
type Verification ¶ added in v0.2.2
type Verification struct {
// Path of the results attestation, relative to the directory of the
// inventory.
Path string `json:"path"`
// Digest captures the hashes of the results attestation, keyed by
// algorithm.
Digest map[string]string `json:"digest,omitempty"`
}
Verification locates the results of the verification of an installed artifact: an attestation of the results that carries the evidence they were reached on, enough to run the verification again.