artifact

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: 14 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 artifact defines the zip artifact format: the tree hash and the deterministic zip writer that makecatalogs and the agent share (see site/src/content/docs/guides/zip-items.md). Keep it free of agent dependencies, like pkg/catalog.

Index

Constants

View Source
const (
	Darwin  = "darwin"
	Windows = "windows"
)

Target OS names. Any other value keeps the files' executable bits, as darwin does; windows records every file as 644.

View Source
const TemplateSuffix = ".tmpl"

TemplateSuffix marks a file in a tree as the template of the file of the same name without it, which sofcat renders beside it on the device (zip-items guide, "Tree templates").

Variables

This section is empty.

Functions

func ShippedTemplates

func ShippedTemplates(paths []string) ([]string, error)

ShippedTemplates is Templates for a tree as an archive ships it, which must not hold both x and x.tmpl: the render would overwrite x. A directory x (files under x/) is refused too: the render could not write x at all. makecatalogs refuses such a tree at pack time and in the repository's zips, and the device refuses it when placing.

func Templates

func Templates(paths []string) ([]string, error)

Templates returns, in order, the templates among paths, a tree's slash-separated file paths. It refuses a file named just .tmpl and an x.tmpl.tmpl, which the render would have nowhere to put. A placed tree holds each template beside its output; see ShippedTemplates for a tree as an archive ships it.

func TreeHash

func TreeHash(dir, goos string) (string, error)

TreeHash reads dir for goos and returns its tree hash.

Types

type Packed

type Packed struct {
	Hash     string `json:"hash"`      // lowercase hex sha256 of the zip
	TreeHash string `json:"tree_hash"` // "sha256:<hex>"
}

Packed is what Pack reports about the zip it wrote.

func PackFile

func PackFile(dir, goos, out string) (Packed, error)

PackFile packs dir for goos into the zip file out. It writes a temporary file beside out and renames it into place, so a failure leaves no partial zip at out.

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree is a directory read for hashing or packing: its regular files, sorted by slash-separated relative path in byte order.

func Read

func Read(dir, goos string) (*Tree, error)

Read lists the regular files under dir. goos is the target OS: for Windows every file is recorded as 644, otherwise a file with any executable bit set is 755. Read refuses a tree that holds a symlink or any other non-regular file, and one with no files; empty directories do not count.

func (*Tree) Hash

func (t *Tree) Hash() (string, error)

Hash returns the tree hash, "sha256:" and the lowercase hex sha256 of one record per file: "<path>\x00<755|644>\x00<hex sha256 of content>\n".

func (*Tree) Paths

func (t *Tree) Paths() []string

Paths returns the slash-separated relative path of every file, sorted.

func (*Tree) WriteZip

func (t *Tree) WriteZip(w io.Writer) (Packed, error)

WriteZip writes the tree as a deterministic zip to w: one Deflate entry per file in tree order, no directory entries, every entry dated 1980-01-01 00:00:00 UTC with mode 0644 or 0755. The same tree and Go version give the same bytes on every OS.

Jump to

Keyboard shortcuts

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