pack

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 21 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 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

View Source
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).

View Source
const (
	MaxLayerFiles = 10000
	MaxLayerBytes = 512 << 20
)

Limits of a pack layer.

View Source
const (
	MaxTools   = 32
	MaxEngines = 32
)

Limits of a pack.

View Source
const APIVersion = "openctem.io/pack/v1"

APIVersion is the pack manifest version this package reads.

View Source
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.

View Source
const FileName = "pack.yaml"

FileName is the pack manifest's file name in a pack directory.

View Source
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.

View Source
const MaxManifestBytes = 64 << 10

MaxManifestBytes bounds pack.yaml.

Variables

View Source
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

func LoadDir(root string) (*Dir, error)

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) Labels

func (d *Dir) Labels() map[string]string

Labels returns the labels of the pack's image.

func (*Dir) Layer

func (d *Dir) Layer(platform string) ([]byte, error)

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

type Error struct {
	Path    string
	Message string
}

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.

func (Error) Error

func (e Error) Error() string

type Errors

type Errors []Error

Errors are every problem found in a pack.

func (Errors) Error

func (e Errors) Error() string

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

func Load(data []byte) (Pack, error)

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) Canonical

func (p Pack) Canonical() ([]byte, error)

Canonical is the pack manifest's canonical JSON.

func (Pack) Check

func (p Pack) Check(tools []tool.Manifest) error

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.

func (Pack) Digest

func (p Pack) Digest() string

Digest is "sha256:" + the hex sha256 of the canonical JSON.

func (Pack) Validate

func (p Pack) Validate() error

Validate checks the rules of pack.yaml that need no tool.

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.

type ToolRef

type ToolRef struct {
	// Name is the tool's name (tool.yaml name).
	Name string `json:"name"`
	// Path is the tool's directory relative to pack.yaml; default: Name.
	// It stays inside the pack directory.
	Path string `json:"path,omitempty"`
}

ToolRef names one tool of the pack.

func (ToolRef) ToolPath

func (r ToolRef) ToolPath() string

ToolPath is the directory of a tool relative to pack.yaml.

Jump to

Keyboard shortcuts

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