layout

package
v0.68.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 53 Imported by: 2

Documentation

Overview

Package layout contains functions for interacting with Zarf packages.

Index

Constants

View Source
const (
	ZarfYAML     = "zarf.yaml"
	Signature    = "zarf.yaml.sig"
	Checksums    = "checksums.txt"
	ValuesYAML   = "values.yaml"
	ValuesSchema = "values.schema.json"

	ImagesDir     = "images"
	ComponentsDir = "components"

	SBOMDir = "zarf-sbom"
	SBOMTar = "sboms.tar"

	DocumentationTar = "documentation.tar"

	IndexJSON = "index.json"
	OCILayout = "oci-layout"
)

Constants used in the default package layout.

Variables

View Source
var (
	// IndexPath is the path to the index.json file
	IndexPath = filepath.Join(ImagesDir, IndexJSON)
	// ImagesBlobsDir is the path to the directory containing the image blobs in the OCI package.
	ImagesBlobsDir = filepath.Join(ImagesDir, "blobs", "sha256")
	// OCILayoutPath is the path to the oci-layout file
	OCILayoutPath = filepath.Join(ImagesDir, OCILayout)
)

Functions

func FormatDocumentFileName added in v0.68.0

func FormatDocumentFileName(key, file string) string

FormatDocumentFileName for storing the document in the package or presenting it to the user

func GetDocumentationFileNames added in v0.68.0

func GetDocumentationFileNames(documentation map[string]string) map[string]string

GetDocumentationFileNames returns a map of documentation keys to their final filenames. Filenames are deconflicted: if multiple keys have the same basename, they get prefixed with the key.

func PackageChart added in v0.60.0

func PackageChart(ctx context.Context, chart v1alpha1.ZarfChart, packagePath string, chartPath string, valuesFilePath string) error

PackageChart takes a Zarf Chart definition and packs it into a package layout

func PackageManifest added in v0.60.0

func PackageManifest(ctx context.Context, manifest v1alpha1.ZarfManifest, compBuildPath string, packagePath string) error

PackageManifest takes a Zarf manifest definition and packs it into a package layout

Types

type AssembleOptions

type AssembleOptions struct {
	// Flavor causes the package to only include components with a matching `.components[x].only.flavor` or no flavor `.components[x].only.flavor` specified
	Flavor string
	// RegistryOverrides overrides the basepath of an OCI image with a path to a different registry
	RegistryOverrides  []images.RegistryOverride
	SigningKeyPath     string
	SigningKeyPassword string
	SkipSBOM           bool
	// When DifferentialPackage is set the zarf package created only includes images and repos not in the differential package
	DifferentialPackage v1alpha1.ZarfPackage
	OCIConcurrency      int
	// CachePath is the path to the Zarf cache, used to cache images
	CachePath string
	// WithBuildMachineInfo includes build machine information (hostname and username) in the package metadata
	WithBuildMachineInfo bool
}

AssembleOptions are the options for creating a package from a package object

type AssembleSkeletonOptions

type AssembleSkeletonOptions struct {
	SigningKeyPath       string
	SigningKeyPassword   string
	Flavor               string
	WithBuildMachineInfo bool
}

AssembleSkeletonOptions are the options for creating a skeleton package

type ComponentDir

type ComponentDir string

ComponentDir is the type for the different directories in a component.

const (
	RepoComponentDir      ComponentDir = "repos"
	FilesComponentDir     ComponentDir = "files"
	ChartsComponentDir    ComponentDir = "charts"
	ManifestsComponentDir ComponentDir = "manifests"
	DataComponentDir      ComponentDir = "data"
	ValuesComponentDir    ComponentDir = "values"
)

Different component directory types.

type NoSBOMAvailableError

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

NoSBOMAvailableError is returned when a user tries to access a package SBOM, but it is not available

func (*NoSBOMAvailableError) Error

func (e *NoSBOMAvailableError) Error() string

type PackageLayout

type PackageLayout struct {
	Pkg v1alpha1.ZarfPackage
	// contains filtered or unexported fields
}

PackageLayout manages the layout for a package.

func AssemblePackage

func AssemblePackage(ctx context.Context, pkg v1alpha1.ZarfPackage, packagePath string, opts AssembleOptions) (*PackageLayout, error)

AssemblePackage takes a package definition and returns a package layout with all the resources collected

func AssembleSkeleton

func AssembleSkeleton(ctx context.Context, pkg v1alpha1.ZarfPackage, packagePath string, opts AssembleSkeletonOptions) (*PackageLayout, error)

AssembleSkeleton creates a skeleton package and returns the path to the created package.

func LoadFromDir

func LoadFromDir(ctx context.Context, dirPath string, opts PackageLayoutOptions) (*PackageLayout, error)

LoadFromDir loads and validates a package from the given directory path.

func LoadFromTar

func LoadFromTar(ctx context.Context, tarPath string, opts PackageLayoutOptions) (*PackageLayout, error)

LoadFromTar unpacks the given archive (any compress/format) and loads it.

func (*PackageLayout) Archive

func (p *PackageLayout) Archive(ctx context.Context, dirPath string, maxPackageSize int) (string, error)

Archive creates a tarball from the package layout and returns the path to that tarball

func (*PackageLayout) Cleanup

func (p *PackageLayout) Cleanup() error

Cleanup removes any temporary directories created.

func (*PackageLayout) ContainsSBOM

func (p *PackageLayout) ContainsSBOM() bool

ContainsSBOM checks if a package includes an SBOM

func (*PackageLayout) DirPath

func (p *PackageLayout) DirPath() string

DirPath returns base directory of the package layout

func (*PackageLayout) FileName

func (p *PackageLayout) FileName() (string, error)

FileName returns the name of the Zarf package should have when exported to the file system

func (*PackageLayout) Files

func (p *PackageLayout) Files() (map[string]string, error)

Files returns a map of all the files in the package.

func (*PackageLayout) GetComponentDir

func (p *PackageLayout) GetComponentDir(ctx context.Context, destPath, componentName string, ct ComponentDir) (_ string, err error)

GetComponentDir returns a path to the directory in the given component.

func (*PackageLayout) GetDocumentation added in v0.68.0

func (p *PackageLayout) GetDocumentation(ctx context.Context, destPath string, keys []string) (err error)

GetDocumentation extracts documentation files from the package to the given destination path. If keys is empty, all documentation files are extracted. If keys are provided, only those specific documentation files are extracted.

func (*PackageLayout) GetImageDirPath

func (p *PackageLayout) GetImageDirPath() string

GetImageDirPath returns the path to the images directory

func (*PackageLayout) GetSBOM

func (p *PackageLayout) GetSBOM(ctx context.Context, destPath string) error

GetSBOM outputs the SBOM data from the package to the given destination path.

func (*PackageLayout) IsSigned added in v0.66.0

func (p *PackageLayout) IsSigned() bool

IsSigned returns true if the package is signed. It first checks the package metadata (Build.Signed), then falls back to checking for the presence of a signature file for backward compatibility.

func (*PackageLayout) SignPackage

func (p *PackageLayout) SignPackage(ctx context.Context, opts utils.SignBlobOptions) (err error)

SignPackage signs the zarf package using cosign with the provided options. If the options do not indicate signing should be performed (no key material configured), this is a no-op and returns nil.

func (*PackageLayout) VerifyPackageSignature added in v0.66.0

func (p *PackageLayout) VerifyPackageSignature(ctx context.Context, opts utils.VerifyBlobOptions) error

VerifyPackageSignature verifies the package signature

type PackageLayoutOptions

type PackageLayoutOptions struct {
	PublicKeyPath           string
	SkipSignatureValidation bool
	IsPartial               bool
	Filter                  filters.ComponentFilterStrategy
}

PackageLayoutOptions are the options used when loading a package.

Jump to

Keyboard shortcuts

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