manifest

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: AGPL-3.0, AGPL-3.0-only Imports: 11 Imported by: 0

Documentation

Overview

Package manifest defines the StageFreight manifest schema and deterministic JSON serialization. The manifest is the normalized data bus between raw evidence (Dockerfile, SBOM, scans) and rendering consumers (narrator, inspect, diff).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractSection

func ExtractSection(m *Manifest, dotPath string) (interface{}, error)

ExtractSection extracts a nested value from a manifest using a dot-path. e.g., "inventories.pip" → manifest.Inventories.Pip

func FindDefaultBuildID

func FindDefaultBuildID(cfg *config.Config) string

FindDefaultBuildID returns the first build ID from config, or empty string.

func Inspect

func Inspect(m *Manifest, opts InspectOptions) (string, error)

Inspect pretty-prints a manifest or a specific section.

func MarshalDeterministic

func MarshalDeterministic(m *Manifest) ([]byte, error)

MarshalDeterministic produces canonical JSON output: sorted map keys, two-space indentation, trailing newline. Identical inputs → byte-identical output.

func PopulateBaseImage

func PopulateBaseImage(m *Manifest, rootDir string)

PopulateBaseImage fills in the base_image field from Dockerfile parsing.

func RenderBadges

func RenderBadges(data interface{}) (string, error)

RenderBadges renders an array of inventory items as inline shields.io badge images. Items with version+pinned get green badges, version+unpinned get blue, no version gets grey.

func RenderKV

func RenderKV(data interface{}) (string, error)

RenderKV renders a single object as a key-value markdown table.

func RenderList

func RenderList(data interface{}) (string, error)

RenderList renders an array as a bullet list. Items with "name" and "version" fields are rendered as "name: version". Otherwise just the "name" or string value.

func RenderSection

func RenderSection(m *Manifest, section, renderer string, columns []string) (string, error)

RenderSection renders a manifest section using the specified renderer.

func RenderTable

func RenderTable(data interface{}, columns []string) (string, error)

RenderTable renders an array of objects as a markdown table. columns selects which fields to include. If empty, uses all keys from the first item.

func ResolveManifestPath

func ResolveManifestPath(rootDir string, cfg *config.Config, buildID string) string

ResolveManifestPath returns the path to a manifest JSON for a given build ID and mode.

Types

type Build

type Build struct {
	ConfigPath string            `json:"config_path"`
	BuildID    string            `json:"build_id"`
	Dockerfile string            `json:"dockerfile"`
	Context    string            `json:"context"`
	Target     *string           `json:"target"`
	BaseImage  string            `json:"base_image"`
	Args       map[string]string `json:"args"`
}

Build holds build configuration.

type Complete

type Complete struct {
	ImageMeta    bool `json:"image_metadata"`
	SecurityMeta bool `json:"security_metadata"`
	SBOMImported bool `json:"sbom_imported"`
}

Complete tracks which data categories are populated.

type GenerateOptions

type GenerateOptions struct {
	RootDir   string
	BuildID   string // filter to a specific build ID
	Platform  string // filter to a specific platform (os/arch)
	Mode      string // ephemeral, workspace, commit, publish
	OutputDir string // output directory for manifest files
	DryRun    bool
	Version   string // app version for generator field
}

GenerateOptions controls manifest generation behavior.

type Image

type Image struct {
	Refs         []string `json:"refs"`
	Digest       *string  `json:"digest"`
	ConfigDigest *string  `json:"config_digest"`
}

Image holds built image metadata.

type InspectOptions

type InspectOptions struct {
	Section string // dot-path to extract (empty = whole manifest)
	Format  string // "json", "table", "human" (default: "human")
}

InspectOptions controls manifest inspection behavior.

type InvItem

type InvItem struct {
	Name       string `json:"name"`
	Version    string `json:"version"`
	Pinned     bool   `json:"pinned"`
	Source     string `json:"source"`
	SourceRef  string `json:"source_ref"`
	Manager    string `json:"manager"`
	Confidence string `json:"confidence,omitempty"`
	URL        string `json:"url,omitempty"`
	Stage      string `json:"stage,omitempty"`
	Final      bool   `json:"final,omitempty"`
}

InvItem represents a single inventory entry.

type Invs

type Invs struct {
	Versions []InvItem `json:"versions"`
	Lineage  []InvItem `json:"lineage,omitempty"`
	Apk      []InvItem `json:"apk"`
	Apt      []InvItem `json:"apt"`
	Pip      []InvItem `json:"pip"`
	Galaxy   []InvItem `json:"galaxy"`
	Npm      []InvItem `json:"npm"`
	Go       []InvItem `json:"go"`
	Binaries []InvItem `json:"binaries"`
}

Invs groups inventory items by manager.

type Manifest

type Manifest struct {
	SchemaVersion int      `json:"schema_version"`
	Kind          string   `json:"kind"`
	Metadata      Metadata `json:"metadata"`
	Repo          Repo     `json:"repo"`
	Scope         Scope    `json:"scope"`
	Release       *Release `json:"release,omitempty"`
	Build         Build    `json:"build"`
	Targets       []Target `json:"targets"`
	Image         Image    `json:"image"`
	Completeness  Complete `json:"completeness"`
	Inventories   Invs     `json:"inventories"`
	Security      Security `json:"security"`
}

Manifest is the top-level StageFreight manifest (schema_version: 1).

func Generate

func Generate(cfg *config.Config, opts GenerateOptions) ([]*Manifest, error)

Generate creates manifests for all matching builds.

func LoadManifest

func LoadManifest(path string) (*Manifest, error)

LoadManifest reads and parses a manifest JSON file.

type Metadata

type Metadata struct {
	GeneratedAt string `json:"generated_at,omitempty"` // omitted in commit/workspace modes
	Generator   string `json:"generator"`
	State       string `json:"state"` // "prebuild" or "postbuild"
	Mode        string `json:"mode"`
}

Metadata holds generation metadata.

type Platform

type Platform struct {
	OS      string  `json:"os"`
	Arch    string  `json:"arch"`
	Variant *string `json:"variant"`
}

Platform describes the target platform.

type Release

type Release struct {
	Version string `json:"version"`
	Tag     string `json:"tag"`
}

Release holds version/tag metadata.

type Repo

type Repo struct {
	URL           string `json:"url"`
	DefaultBranch string `json:"default_branch"`
	Commit        string `json:"commit"`
	Dirty         bool   `json:"dirty"`
}

Repo holds git repository metadata.

type SBOMInfo

type SBOMInfo struct {
	Present bool    `json:"present"`
	Format  *string `json:"format"`
	Path    *string `json:"path"`
	Digest  *string `json:"digest"`
}

SBOMInfo describes SBOM availability.

type ScanInfo

type ScanInfo struct {
	Tool string `json:"tool"`
	Path string `json:"path"`
}

ScanInfo describes a security scan result.

type Scope

type Scope struct {
	Name     string    `json:"name"`
	BuildID  string    `json:"build_id"`
	Platform *Platform `json:"platform,omitempty"`
}

Scope identifies the manifest scope.

type Security

type Security struct {
	SBOM       SBOMInfo   `json:"sbom"`
	Signatures []SigInfo  `json:"signatures"`
	Scans      []ScanInfo `json:"scans"`
}

Security holds security-related metadata.

type SigInfo

type SigInfo struct {
	Tool   string `json:"tool"`
	KeyRef string `json:"key_ref,omitempty"`
}

SigInfo describes an image signature.

type Target

type Target struct {
	ID            string   `json:"id"`
	Kind          string   `json:"kind"`
	Provider      string   `json:"provider,omitempty"`
	URL           string   `json:"url"`
	Path          string   `json:"path"`
	Tags          []string `json:"tags,omitempty"`
	CredentialRef string   `json:"credential_ref,omitempty"`
}

Target holds distribution target metadata.

Jump to

Keyboard shortcuts

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