zarfpackage

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package zarfpackage reads a built zarf package (https://github.com/zarf-dev/zarf) as a source of images and files for a package build.

Both halves of a zarf package record where their content came from, which is what makes resolving a distro definition against one a map lookup rather than a heuristic:

  • images/ is a plain OCI image layout whose index entries carry org.opencontainers.image.ref.name, set to the reference zarf pulled the image under before any registry override was applied.
  • zarf.yaml keeps each component file's source exactly as the package author wrote it, and the bytes sit at a path derived from the file's position in the component. zarf rewrites files[].source only when building a skeleton, which is not a package anybody deploys.

Those are the same strings a distro definition writes in imageConfig.images and File.Source.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Package

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

Package is an opened zarf package. Close removes what Open unpacked, so every Package must be closed.

func Open

func Open(ctx context.Context, path string) (*Package, error)

Open reads the zarf package at path, which may be a built package archive or a directory it has already been extracted into. An archive is unpacked into a temporary directory owned by the returned Package.

func OpenDir

func OpenDir(ctx context.Context, dir, source string) (*Package, error)

OpenDir reads an already-unpacked zarf package at dir, naming it in messages and recorded provenance as source. The caller keeps ownership of dir: the returned Package's Close does not remove it.

This is the entry point for a caller that has unpacked a bundle itself in order to work out which format it is -- see openContentStore in pkg/distro.

func (*Package) Close

func (p *Package) Close() error

Close removes anything Open unpacked. A package directory is left untouched.

func (*Package) Describe

func (p *Package) Describe() string

Describe names the package in log lines.

func (*Package) Fetch

func (p *Package) Fetch(ctx context.Context, req contentstore.FileRequest, dst string) (err error)

Fetch writes the component file declared as coming from req.Source to dst, creating it.

func (*Package) File

func (p *Package) File(req contentstore.FileRequest) (string, bool, error)

File reports whether the package holds a component file declared as coming from req.Source -- a URL or a path as it appeared in a distro definition -- and the name it is restored under.

req.Arch is ignored, and the error is always nil. A zarf package's components[].files has no platform dimension: one entry is one file, and a package that carries two architectures of something carries them as two entries. Only a bundle that can hold several platforms under one reference -- a hauler store holding a vendor-published index -- has anything to answer here.

func (*Package) HasImage

func (p *Package) HasImage(ref string) bool

HasImage reports whether the package holds the image ref, spelled as a distro definition spells it.

func (*Package) Source

func (p *Package) Source() string

Source is the path the package was opened from, for messages and provenance.

func (*Package) Target

func (p *Package) Target() oras.ReadOnlyTarget

Target presents the package's images as an oras target that resolves the references a distro definition uses.

The layout's own tag index cannot be relied on: zarf tags each image under the reference it pulled it by, but a package of files alone has no layout at all, and nothing guarantees the tag survived a registry override. This maps the full reference back through the index annotation instead.

Jump to

Keyboard shortcuts

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