Documentation
¶
Overview ¶
Package pack reads and checks a tool pack: the unit in which tools are versioned, built, signed and delivered to sensors.
A pack is a directory with a pack.yaml (apiVersion openctem.io/pack/v1) and the tools it carries, each a tool.yaml plus its program (the tool contract, package tool). The same pack.yaml describes a first-party pack built into a sensor profile image and a third-party pack shipped as its own OCI image: built-in tools and outside tools use one format.
pack.yaml states only what no tool.yaml can: which tools travel together, the third-party engines they bundle (with a sha256 per platform), the platforms, the SDK and protocol the pack needs, the base image of a pack image, and the pack's tier. Capabilities, inputs, outputs, credentials, network and resources stay in each tool.yaml; Describe derives the pack view from them. The tier is a claim the loader checks: it must equal the highest minimum tier of the pack's tools, so a reader of pack.yaml sees the truth and a pack cannot hide an active tool behind a passive label.
The specification is docs/tool-packs.md; the machine-readable form is schema/pack.v1.schema.json in package tool.
Stability: Beta (docs/STABILITY.md).
Index ¶
Constants ¶
const ( LabelName = "io.openctem.pack.name" LabelVersion = "io.openctem.pack.version" LabelPublisher = "io.openctem.pack.publisher" LabelTier = "io.openctem.pack.tier" // LabelDigest is the pack manifest digest (Pack.Digest): a sensor // checks the pack.yaml it finds against it. LabelDigest = "io.openctem.pack.digest" )
Labels a pack image carries in its config (and its index annotations).
const ( MaxLayerFiles = 10000 MaxLayerBytes = 512 << 20 )
Limits of a pack layer.
const ( MaxTools = 32 MaxEngines = 32 )
Limits of a pack.
const APIVersion = "openctem.io/pack/v1"
APIVersion is the pack manifest version this package reads.
const BuildDir = ".build"
BuildDir is the directory of per-platform files in a pack: the content of BuildDir/<os>-<arch>/ replaces or adds files at the same paths in that platform's image (a compiled program per architecture). BuildDir itself never enters an image.
const FileName = "pack.yaml"
FileName is the pack manifest's file name in a pack directory.
const ImageRoot = "/opt/openctem/pack"
ImageRoot is where a pack image holds the pack directory: pack.yaml at ImageRoot/pack.yaml and each tool under it. A sensor reads the pack from there, never from the image's entrypoint or command.
const MaxManifestBytes = 64 << 10
MaxManifestBytes bounds pack.yaml.
Variables ¶
var Platforms = []string{"linux/amd64", "linux/arm64"}
Platforms a pack may name.
Functions ¶
This section is empty.
Types ¶
type Description ¶
type Description struct {
Name string `json:"name"`
Version string `json:"version"`
Publisher string `json:"publisher"`
Tier tool.Tier `json:"tier"`
Digest string `json:"digest"`
Platforms []string `json:"platforms"`
Requires Requires `json:"requires"`
Capabilities []string `json:"capabilities"`
Credentials []string `json:"credentials,omitempty"`
Network []string `json:"network"`
VendorHosts []string `json:"vendor_hosts,omitempty"`
Engines []Engine `json:"engines,omitempty"`
Tools []ToolEntry `json:"tools"`
}
Description is the pack as the platform and a catalog show it: pack.yaml plus what its tools declare.
type Dir ¶
type Dir struct {
// Root is the pack directory.
Root string
// Pack is its pack.yaml.
Pack Pack
// Tools are its tools, in pack.yaml order.
Tools []tool.Manifest
// ToolDirs are the tools' directories, in the same order.
ToolDirs []string
}
Dir is a pack read from a directory.
func LoadDir ¶
LoadDir reads a pack directory: pack.yaml and the tool.yaml of every tool it lists, then checks them together. A tool directory reached through a symbolic link is refused: the pack is what its directory holds.
func (*Dir) Describe ¶
func (d *Dir) Describe() Description
Describe derives the pack view from pack.yaml and its tools.
func (*Dir) Layer ¶
Layer returns the pack's layer for one platform ("linux/amd64"): an uncompressed tar of the pack directory under ImageRoot, with the platform's BuildDir overlay applied. The tar is deterministic: entries sorted, owned by root, no timestamps, file modes reduced to 0644 or 0755 (directories 0755). Only regular files and directories are taken; a symbolic link, device or other special file anywhere in the pack is an error, as is a pack over MaxLayerFiles files or MaxLayerBytes bytes.
type Engine ¶
type Engine struct {
Name string `json:"name"`
Version string `json:"version"`
// License is the engine's SPDX license expression.
License string `json:"license"`
// URL is where the engine is downloaded from at build time (https).
URL string `json:"url,omitempty"`
// SHA256 is the hex sha256 of the downloaded file per platform; when
// set it covers every platform of the pack.
SHA256 map[string]string `json:"sha256,omitempty"`
}
Engine is one third-party program a pack bundles.
type Error ¶
Error is one problem in a pack. Path is a JSON pointer into pack.yaml, or a tool's file for a problem found in a tool.
type Image ¶
type Image struct {
// Base is the base image, pinned by digest (ref@sha256:<hex>).
Base string `json:"base"`
}
Image is how `openctem tool build` builds a pack image.
type Pack ¶
type Pack struct {
// APIVersion is APIVersion.
APIVersion string `json:"apiVersion"`
// Name is the pack's name: ^[a-z][a-z0-9-]{1,62}$.
Name string `json:"name"`
// Version is the pack's semantic version (no leading v). Any change
// to the pack's files needs a new version.
Version string `json:"version"`
Description string `json:"description,omitempty"`
// Publisher is who publishes the pack, as a namespace
// (^[a-z][a-z0-9-]{1,62}$). A catalog binds it to the signing
// identity; the loader treats it as text.
Publisher string `json:"publisher"`
// License is the SPDX license expression of the pack's own files.
// Each engine carries its own.
License string `json:"license"`
// Tier is the pack's tier: T0 passive, T1 active, T2 intrusive. It
// must equal the highest minimum tier of the pack's tools.
Tier tool.Tier `json:"tier"`
// Tools are the tools the pack carries.
Tools []ToolRef `json:"tools"`
// Engines are the third-party programs the pack bundles. Every
// engine a tool names (tool.yaml engine.name) is listed here.
Engines []Engine `json:"engines,omitempty"`
// Platforms are the platforms the pack is built for.
Platforms []string `json:"platforms"`
// Requires is what a sensor needs to run the pack.
Requires Requires `json:"requires"`
// Image is how a pack image is built; absent for a pack that is only
// built into a sensor profile image.
Image *Image `json:"image,omitempty"`
}
Pack is pack.yaml.
func Load ¶
Load reads pack.yaml (YAML or JSON) strictly: unknown keys, duplicate keys and more than one document are errors. The result is validated on its own (Validate); Check validates it against its tools.
func (Pack) Check ¶
Check validates the pack against its tools, given in any order:
- the tools are exactly the ones pack.yaml lists;
- the pack's tier equals the highest minimum tier of its tools (tool.Manifest.MinimumTier: declared tier, capability floors, side effects);
- every tool speaks the pack's protocol and needs no newer SDK than the pack requires;
- every engine a tool names is listed in engines.
type Requires ¶
type Requires struct {
// SDK is the oldest sensor SDK (semantic version, no leading v) that
// understands every key the pack and its tools use.
SDK string `json:"sdk"`
// Protocol is the adapter protocol major the pack's tools speak.
Protocol int `json:"protocol"`
}
Requires is what a sensor needs to run a pack.
type ToolEntry ¶
type ToolEntry struct {
Name string `json:"name"`
Version string `json:"version"`
Digest string `json:"digest"`
MinimumTier tool.Tier `json:"minimum_tier"`
Capabilities []string `json:"capabilities,omitempty"`
}
ToolEntry is one tool in a Description.