bundle

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package bundle implements UDS bundle deployment functionality.

Package bundle provides functionality for managing UDS bundles.

Index

Constants

View Source
const (
	// BundleSignatureStatusVerified means the bundle signature matched the configured policy.
	BundleSignatureStatusVerified = "verified"
	// BundleSignatureStatusUnverified is retained as an alias for an unchecked bundle.
	BundleSignatureStatusUnverified = "not_checked"
	// BundleSignatureStatusNotChecked means inspection did not authenticate the bundle.
	BundleSignatureStatusNotChecked = "not_checked"
	// BundleSignatureStatusSkipped means the caller explicitly bypassed verification.
	BundleSignatureStatusSkipped = "skipped"
)
View Source
const (
	// PackageSigningStatusSigned means package signing metadata records a signature.
	PackageSigningStatusSigned = "signed"
	// PackageSigningStatusUnsigned means package signing metadata records no signature.
	PackageSigningStatusUnsigned = "unsigned"
	// PackageSigningStatusUnknown means package signing metadata was unavailable or unrecognized.
	PackageSigningStatusUnknown = "unknown"

	// PackageVerificationStatusVerified means package verification metadata records a successful verification.
	PackageVerificationStatusVerified = "verified"
	// PackageVerificationStatusSkipped means package verification was explicitly disabled during bundle creation.
	PackageVerificationStatusSkipped = "skipped"
	// PackageVerificationStatusUnknown means package verification metadata was unavailable or unrecognized.
	PackageVerificationStatusUnknown = "unknown"
)

Variables

View Source
var (
	// ErrInvalidConfig occurs when bundle configuration fails validation.
	ErrInvalidConfig = errors.New("invalid bundle configuration")
	// ErrValidateDependencies occurs when bundle dependency relationships cannot be evaluated.
	ErrValidateDependencies = errors.New("validating bundle dependencies")
	// ErrBundleInputRequired occurs when neither a bundle path nor an in-memory bundle is provided.
	ErrBundleInputRequired = errors.New("bundle path or bundle is required")
	// ErrBundleDirRequired occurs when a bundle operation has no bundle directory.
	ErrBundleDirRequired = errors.New("bundle directory is required")
	// ErrTargetDirRequired occurs when a pull operation has no destination directory.
	ErrTargetDirRequired = errors.New("target directory is required")
	// ErrBundleFileRequired occurs when bundle creation has no definition file.
	ErrBundleFileRequired = errors.New("bundle file is required")
	// ErrSourceRequired occurs when an operation has no bundle source.
	ErrSourceRequired = errors.New("bundle source is required")
	// ErrInvalidOCIReference occurs when an OCI reference cannot be parsed.
	ErrInvalidOCIReference = errors.New("invalid OCI reference")
	// ErrDefaultsFileRequired occurs when reconfiguration has no defaults file.
	ErrDefaultsFileRequired = errors.New("defaults file is required")
	// ErrInvalidSuffix occurs when a reconfiguration suffix is unsafe for tags, paths, or HCL.
	ErrInvalidSuffix = errors.New("invalid reconfiguration suffix")
	// ErrInvalidSigningOptions occurs when a signing mode or its required inputs are invalid.
	ErrInvalidSigningOptions = errors.New("invalid bundle signing options")
	// ErrInvalidVerificationPolicy occurs when a signature verification policy is invalid.
	ErrInvalidVerificationPolicy = errors.New("invalid bundle verification policy")
	// ErrCreateBundle occurs when bundle creation fails after option validation.
	ErrCreateBundle = errors.New("creating bundle")
	// ErrDeployBundle occurs when bundle parsing or deployment fails.
	ErrDeployBundle = errors.New("deploying bundle")
	// ErrInspectBundle occurs when reading or verifying bundle metadata fails.
	ErrInspectBundle = errors.New("inspecting bundle")
	// ErrPrepareDeploySource occurs when an artifact cannot be prepared for deployment.
	ErrPrepareDeploySource = errors.New("preparing deploy source")
	// ErrRemoveBundle occurs when bundle parsing or removal fails.
	ErrRemoveBundle = errors.New("removing bundle")
	// ErrPullBundle occurs when a bundle cannot be pulled from OCI storage.
	ErrPullBundle = errors.New("pulling bundle")
	// ErrPushBundle occurs when bundle extraction or registry upload fails.
	ErrPushBundle = errors.New("pushing bundle")
	// ErrReconfigureBundle occurs when local or remote bundle reconfiguration fails.
	ErrReconfigureBundle = errors.New("reconfiguring bundle")
	// ErrSignBundle occurs when a validated bundle signing operation fails.
	ErrSignBundle = errors.New("signing bundle")
	// ErrVerifyBundle occurs when a validated bundle verification operation fails.
	ErrVerifyBundle = errors.New("verifying bundle")
)
View Source
var ErrBundleNotSigned = errors.New("bundle is not signed")

ErrBundleNotSigned indicates that a bundle has no signature evidence.

Functions

func Sign

func Sign(ctx context.Context, opts SignOptions) error

Sign adds Sigstore bundle evidence to a local bundle archive.

func Verify

func Verify(ctx context.Context, opts VerifyOptions) error

Verify verifies local bundle signature evidence and the complete OCI graph.

Types

type BundleDeployHooks

type BundleDeployHooks struct {
	// PreDeploy runs once before package deployment. Only mutations to
	// PackageDeployHooks are honored: package selection, source preparation, and
	// bundle hooks have already been consumed. A returned error prevents package
	// deployment and skips PostDeploy.
	PreDeploy func(ctx context.Context, b *spec.UDSBundle, opts *DeployOptions) error
	// PostDeploy runs once after every selected package deploys successfully.
	PostDeploy func(ctx context.Context, b *spec.UDSBundle) error
}

BundleDeployHooks provides deployment process extensibility at the bundle scope.

type BundleSignatureSummary

type BundleSignatureSummary struct {
	Status string `json:"status" yaml:"status" text:"Status"`
}

BundleSignatureSummary reports bundle signature status. Package metadata is not proof of bundle integrity.

type ConfigOptions

type ConfigOptions struct {
	LogLevel      string
	Architecture  string
	PlainHTTP     bool
	SkipTLSVerify bool
	TmpDir        string
	Concurrency   int
}

ConfigOptions holds bundle operation settings.

type CreateOptions

type CreateOptions struct {
	Config  *UDSBundleConfig
	Streams iostreams.IOStreams
	Signing SigningOptions
}

CreateOptions holds configuration for the top-level bundle create operation.

func (CreateOptions) Validate

func (o CreateOptions) Validate() error

Validate checks that CreateOptions is valid.

type CreateResult

type CreateResult struct {
	BundleName string `json:"bundleName" yaml:"bundleName" text:"Bundle Name"`
	OutputPath string `json:"outputPath" yaml:"outputPath" text:"Output Path"`
}

CreateResult represents the output of a bundle create operation.

func Create

func Create(ctx context.Context, bundleFile string, opts CreateOptions) (*CreateResult, error)

Create creates a UDS bundle tar.zst from the given bundle definition file. It parses and validates the bundle, ingests all packages, and writes the resulting archive next to the bundle file.

type DependencyViolationError

type DependencyViolationError struct {
	// Violations maps a package name to its related package names (sorted).
	Violations map[string][]string
	// contains filtered or unexported fields
}

func (*DependencyViolationError) Error

func (e *DependencyViolationError) Error() string

Error formats the dependency violations for command-line display.

type DeployOptions

type DeployOptions struct {
	Config   *UDSBundleConfig
	Packages []string
	// Force bypasses ValidateDeploySafety, allowing selected packages to deploy
	// even when required dependencies are absent.
	Force              bool
	BundleDeployHooks  BundleDeployHooks
	PackageDeployHooks PackageDeployHooks
	Streams            iostreams.IOStreams
}

DeployOptions contains options for deploying an entire bundle.

func (DeployOptions) Validate

func (o DeployOptions) Validate() error

Validate checks that DeployOptions is valid. Config must be non-nil and valid.

type DeployPackageOptions

type DeployPackageOptions struct {
	// Config supplies variables, temporary-directory settings, and logging
	// configuration. Deploy populates it from DeployOptions.Config.
	Config             *UDSBundleConfig
	BundleDir          string
	PackageDeployHooks PackageDeployHooks
	// IsPartial reports whether the loaded layout omits checksum-referenced layers.
	IsPartial bool
	Streams   iostreams.IOStreams
}

DeployPackageOptions contains package deployment context passed to hooks.

func (DeployPackageOptions) Validate

func (o DeployPackageOptions) Validate() error

Validate checks that DeployPackageOptions is valid.

type DeployPackageResult

type DeployPackageResult struct {
	Name string `json:"name" yaml:"name" text:"Name"`
}

DeployPackageResult represents a package successfully deployed as part of a bundle.

type DeployResult

type DeployResult struct {
	BundleName string                `json:"bundleName" yaml:"bundleName" text:"Bundle Name"`
	Packages   []DeployPackageResult `json:"packages" yaml:"packages" text:"Packages"`
}

DeployResult represents the output of a bundle deploy operation.

func Deploy

func Deploy(ctx context.Context, source *DeploySource, opts DeployOptions) (*DeployResult, error)

Deploy deploys a UDS bundle to a Kubernetes cluster. It delegates bundle-level deployment (DAG traversal, ordering, parallelism, and concurrency limits) to the deployment adapter.

type DeploySource

type DeploySource struct {
	// BundlePath is the absolute path to the bundle definition file (bundle.uds.hcl).
	BundlePath string
	// DefaultsPath is an optional defaults.uds.hcl path associated with the source.
	DefaultsPath string
	// Bundle is an optional parsed bundle. Prepared artifact sources populate it
	// with deploy-ready values file paths; nil means Deploy parses BundlePath.
	Bundle *spec.UDSBundle
	// Loader overrides how package layouts are obtained; nil means use the default source loader.
	Loader ZarfPackageLayoutLoader
	// contains filtered or unexported fields
}

DeploySource abstracts the bundle definition, optional parsed bundle, and source-specific package loading behavior. It owns temporary resources created while preparing an artifact source.

func PrepareDeploySource

func PrepareDeploySource(ctx context.Context, streams iostreams.IOStreams, path, tmpDir, architecture string) (*DeploySource, error)

PrepareDeploySource prepares a bundle directory or verified tar.zst artifact.

func (*DeploySource) Close

func (s *DeploySource) Close() error

Close releases any temporary resources allocated during source preparation.

type GlobalOptions

type GlobalOptions struct {
	LogLevel string
	Prompt   bool
}

GlobalOptions holds process-wide settings retained for compatibility with bundle configuration consumers. Command behavior is resolved into ConfigOptions.

type InspectOptions

type InspectOptions struct {
	Source                    string
	Config                    *UDSBundleConfig
	Verification              VerificationPolicy
	SkipSignatureVerification bool
	Streams                   iostreams.IOStreams
}

InspectOptions configures inspection of a built bundle.

func (InspectOptions) Validate

func (o InspectOptions) Validate() error

Validate validates inspection options without performing I/O.

type InspectResult

type InspectResult struct {
	Name             string                  `json:"name" yaml:"name" text:"Name"`
	Description      string                  `json:"description,omitempty" yaml:"description,omitempty" text:"Description,omitempty"`
	Version          string                  `json:"version,omitempty" yaml:"version,omitempty" text:"Version,omitempty"`
	ArtifactDigest   string                  `json:"artifactDigest,omitempty" yaml:"artifactDigest,omitempty" text:"Artifact Digest,omitempty"`
	ReconfiguredFrom string                  `json:"reconfiguredFrom,omitempty" yaml:"reconfiguredFrom,omitempty" text:"Reconfigured From,omitempty"`
	BundleSignature  *BundleSignatureSummary `json:"bundleSignature,omitempty" yaml:"bundleSignature,omitempty" text:"Bundle Signature,omitempty"`
	Packages         []PackageSummary        `json:"packages" yaml:"packages" text:"Packages"`
	Bundle           *spec.UDSBundle         `json:"-" yaml:"-" text:"-"`
}

InspectResult represents the output of a bundle inspect operation.

func Inspect

func Inspect(ctx context.Context, opts InspectOptions) (*InspectResult, error)

Inspect reads metadata from a built local or OCI bundle. When a verification policy is provided, it verifies the bundle before parsing its metadata.

type KeylessVerification

type KeylessVerification struct {
	CertificateIdentity         string
	CertificateIdentityRegexp   string
	CertificateOIDCIssuer       string
	CertificateOIDCIssuerRegexp string
	TrustedRoot                 string
}

KeylessVerification constrains the certificate identity trusted for a keyless signature.

type PackageDeployHooks

type PackageDeployHooks struct {
	// PreDeploy enables customization just before a package deploys. It runs after
	// layout loading and before the cluster deploy. Mutations to pkgLayout.PackageDefinition and
	// packageOpts take effect immediately. A non-nil error aborts the deploy; the
	// cluster deploy is not called and PostDeploy is skipped.
	//
	// PreDeploy and PostDeploy are captured before PreDeploy runs, so changing
	// packageOpts.PackageDeployHooks here has no effect. Use
	// BundleDeployHooks.PreDeploy to install per-package hooks dynamically.
	//
	// PreDeploy may run concurrently with PreDeploy for other packages in the
	// same DAG level; implementations must be concurrency-safe.
	PreDeploy func(ctx context.Context, pkg *spec.Package, pkgLayout *ZarfPackageLayout, packageOpts *DeployPackageOptions) error

	// PostDeploy enables tracking successfully deployed packages. It runs after a
	// successful cluster deploy and is not called when PreDeploy or deployment
	// returns an error. It may run concurrently with PostDeploy for other
	// packages in the same DAG level; implementations must be concurrency-safe.
	PostDeploy func(ctx context.Context, pkg *spec.Package) error
}

PackageDeployHooks provides deployment process extensibility on a per-package basis.

type PackageSignatureSummary

type PackageSignatureSummary struct {
	Signed       string `json:"signed" yaml:"signed" text:"Signed"`
	Verification string `json:"verification" yaml:"verification" text:"Verification Posture"`
}

PackageSignatureSummary reports package metadata and the verification result recorded during bundle creation. Inspect does not perform package signature verification.

type PackageStagingRootProvider

type PackageStagingRootProvider interface {
	PackageStagingRoot(context.Context) string
}

PackageStagingRootProvider optionally identifies a directory where package staging can be colocated with loader-owned immutable content. An empty return value uses the configured temporary directory.

type PackageSummary

type PackageSummary struct {
	Name        string                   `json:"name" yaml:"name" text:"Name"`
	Source      string                   `json:"source" yaml:"source" text:"Source"`
	Namespace   string                   `json:"namespace,omitempty" yaml:"namespace,omitempty" text:"Namespace,omitempty"`
	DependsOn   []string                 `json:"dependsOn,omitempty" yaml:"dependsOn,omitempty" text:"DependsOn,omitempty"`
	ValuesFiles []string                 `json:"valuesFiles,omitempty" yaml:"valuesFiles,omitempty" text:"Value Files,omitempty"`
	Signature   *PackageSignatureSummary `json:"signature,omitempty" yaml:"signature,omitempty" text:"Signature,omitempty"`
}

PackageSummary is a serializable summary of a package within a bundle. Packages are listed in deployment order.

type PullOptions

type PullOptions struct {
	Config                    *UDSBundleConfig
	Verification              VerificationPolicy
	SkipSignatureVerification bool
	Streams                   iostreams.IOStreams
}

PullOptions holds configuration for pulling a bundle from an OCI registry.

func (PullOptions) Validate

func (o PullOptions) Validate() error

Validate checks that PullOptions is valid.

type PullResult

type PullResult struct {
	OCIReference string `json:"ociReference" yaml:"ociReference" text:"OCI Reference"`
	OutputPath   string `json:"outputPath" yaml:"outputPath" text:"Output Path"`
}

PullResult represents the output of a bundle pull operation.

func Pull

func Pull(ctx context.Context, ref, targetDir string, opts PullOptions) (*PullResult, error)

Pull pulls a bundle artifact from an OCI registry into targetDir.

type PushOptions

type PushOptions struct {
	Config  *UDSBundleConfig
	Streams iostreams.IOStreams
}

PushOptions holds configuration for pushing a bundle to an OCI registry.

func (PushOptions) Validate

func (o PushOptions) Validate() error

Validate checks that PushOptions is valid.

type PushResult

type PushResult struct {
	OCIReference string `json:"ociReference" yaml:"ociReference" text:"OCI Reference"`
}

PushResult represents the output of a bundle push operation.

func Push

func Push(ctx context.Context, bundleTarball, ref string, opts PushOptions) (*PushResult, error)

Push pushes a local bundle tarball to an OCI registry.

type ReconfigureOptions

type ReconfigureOptions struct {
	// Suffix is appended to the output artifact name.
	Suffix string
	// OutputDir is used for local tarball output and must be empty for OCI sources.
	OutputDir string
	// Config provides shared configuration for the operation.
	Config *UDSBundleConfig
	// Signing controls the signature of the reconfigured output artifact.
	Signing SigningOptions
	// Verification controls verification of the source artifact.
	Verification VerificationPolicy
	// SkipSignatureVerification disables source signature verification.
	SkipSignatureVerification bool
	// Streams carries In, Out, and ErrOut for the operation.
	Streams iostreams.IOStreams
}

ReconfigureOptions holds configuration for the bundle reconfigure operation.

func (ReconfigureOptions) Validate

func (o ReconfigureOptions) Validate() error

Validate checks that ReconfigureOptions is valid.

type ReconfigureResult

type ReconfigureResult struct {
	OutputPath   string `json:"outputPath,omitempty" yaml:"outputPath,omitempty" text:"Output Path,omitempty"`
	OCIReference string `json:"ociReference,omitempty" yaml:"ociReference,omitempty" text:"OCI Reference,omitempty"`
}

ReconfigureResult represents the output of a bundle reconfigure operation.

func Reconfigure

func Reconfigure(ctx context.Context, source, defaultsFile string, opts ReconfigureOptions) (*ReconfigureResult, error)

Reconfigure validates the defaults file and dispatches to the appropriate implementation based on whether the source is a local tarball or OCI reference.

type RemoveOptions

type RemoveOptions struct {
	Config                    *UDSBundleConfig
	Packages                  []string
	Verification              VerificationPolicy
	SkipSignatureVerification bool
	// Force bypasses the removal-safety check for a selected package subset. It
	// can remove packages still required by remaining bundle packages, leaving
	// deployed dependents broken.
	Force   bool
	Streams iostreams.IOStreams
}

RemoveOptions contains options for removing an entire bundle.

func (RemoveOptions) Validate

func (o RemoveOptions) Validate() error

Validate checks that RemoveOptions is valid. Config must be non-nil and valid.

type RemovePackageResult

type RemovePackageResult struct {
	Name   string              `json:"name" yaml:"name" text:"Name"`
	Status RemovePackageStatus `json:"status" yaml:"status" text:"Status"`
}

RemovePackageResult represents the outcome for one package in a bundle removal.

type RemovePackageStatus

type RemovePackageStatus string

RemovePackageStatus describes whether a package was removed or was already absent.

const (
	RemovePackageStatusRemoved RemovePackageStatus = "removed"
	RemovePackageStatusSkipped RemovePackageStatus = "skipped"
)

type RemoveResult

type RemoveResult struct {
	BundleName string                `json:"bundleName" yaml:"bundleName" text:"Bundle Name"`
	Packages   []RemovePackageResult `json:"packages" yaml:"packages" text:"Packages"`
}

RemoveResult represents the output of a bundle remove operation.

func Remove

func Remove(ctx context.Context, source *DeploySource, opts RemoveOptions) (*RemoveResult, error)

Remove validates and removes a UDS bundle from a Kubernetes cluster. When opts.Packages is non-empty, only the specified packages are removed.

type SignOptions

type SignOptions struct {
	Source  string
	Signing SigningOptions
	Config  *UDSBundleConfig
	TmpDir  string
	Streams iostreams.IOStreams
}

SignOptions configures signing an existing bundle artifact.

func (SignOptions) Validate

func (o SignOptions) Validate() error

Validate validates SignOptions.

type SigningMode

type SigningMode string

SigningMode identifies the credentials used to sign a bundle.

const (
	// SigningModeKey signs with a configured private key.
	SigningModeKey SigningMode = "key"
	// SigningModeKeyless signs with a keyless Sigstore identity.
	SigningModeKeyless SigningMode = "keyless"
	// SigningModeUnsigned leaves the bundle unsigned.
	SigningModeUnsigned SigningMode = "unsigned"
)

type SigningOptions

type SigningOptions struct {
	Mode           SigningMode
	Key            string
	KeyPassword    string
	IdentityToken  string
	FulcioURL      string
	FulcioAuthFlow string
	OIDCIssuer     string
	OIDCClientID   string
	RekorURL       string
	TSAServerURL   string
	Overwrite      bool
}

SigningOptions configures a bundle signature operation.

func (SigningOptions) Validate

func (o SigningOptions) Validate() error

Validate validates signing options.

type UDSBundleConfig

type UDSBundleConfig struct {
	Global                *GlobalOptions
	Options               *ConfigOptions
	SignatureVerification *VerificationPolicy
	Variables             Variables
}

UDSBundleConfig is the resolved public bundle configuration.

type Variables

type Variables map[string]any

Variables contains user-defined bundle configuration variables.

type VerificationPolicy

type VerificationPolicy struct {
	PublicKey string
	Keyless   *KeylessVerification
}

VerificationPolicy is consumer-controlled trust material for a bundle signature.

func (VerificationPolicy) Validate

func (p VerificationPolicy) Validate() error

Validate validates verification policy.

type VerifyOptions

type VerifyOptions struct {
	Source  string
	Policy  VerificationPolicy
	Config  *UDSBundleConfig
	TmpDir  string
	Streams iostreams.IOStreams
}

VerifyOptions configures verification of a bundle artifact.

func (VerifyOptions) Validate

func (o VerifyOptions) Validate() error

Validate validates VerifyOptions.

type ZarfPackageLayout

type ZarfPackageLayout struct {
	PackageDefinition api.PackageDefinition
	// contains filtered or unexported fields
}

ZarfPackageLayout exposes the native Zarf package definition during bundle deploy. Keeping the schema-aware definition intact lets hooks mutate fields specific to the package API version in use.

func (*ZarfPackageLayout) Digest

func (p *ZarfPackageLayout) Digest() string

func (*ZarfPackageLayout) DirPath

func (p *ZarfPackageLayout) DirPath() string

func (*ZarfPackageLayout) SetDeployedDigest

func (p *ZarfPackageLayout) SetDeployedDigest(digest string)

SetDeployedDigest records the registry-resolved manifest digest that Zarf should store as the deployed package identity.

type ZarfPackageLayoutLoadOptions

type ZarfPackageLayoutLoadOptions struct {
	Streams   iostreams.IOStreams
	IsPartial bool
}

ZarfPackageLayoutLoadOptions carries options for loading a Zarf package layout.

type ZarfPackageLayoutLoadResult

type ZarfPackageLayoutLoadResult struct {
	Layout    ZarfPackageLayout
	IsPartial bool
}

ZarfPackageLayoutLoadResult contains a loaded layout and metadata discovered while loading it.

type ZarfPackageLayoutLoader

type ZarfPackageLayoutLoader interface {
	LoadPackageLayout(ctx context.Context, pkg *spec.Package, dstDir string, opts ZarfPackageLayoutLoadOptions) (*ZarfPackageLayoutLoadResult, error)
}

ZarfPackageLayoutLoader prepares a Zarf package layout for a bundle package. Implementations must stage a complete Zarf package in dstDir. They may pull from pkg.Source, copy from an extracted bundle artifact, or populate dstDir from another source. The adapter loads the staged package to preserve Zarf's private deployment state before applying supported public layout mutations.

Directories

Path Synopsis
Package spec defines the public semantic model for UDS bundles.
Package spec defines the public semantic model for UDS bundles.

Jump to

Keyboard shortcuts

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