packager

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: 68 Imported by: 2

Documentation

Overview

Package packager contains high level operations for Zarf packages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create added in v0.56.0

func Create(ctx context.Context, packagePath string, output string, opts CreateOptions) (_ string, err error)

Create takes a path to a directory containing a ZarfPackageConfig and returns the path to the created package

func DevDeploy added in v0.56.0

func DevDeploy(ctx context.Context, packagePath string, opts DevDeployOptions) (err error)

DevDeploy creates + deploys a package in one shot

func Generate added in v0.56.0

func Generate(ctx context.Context, packageName, url, version string, opts GenerateOptions) (pkg v1alpha1.ZarfPackage, err error)

Generate a Zarf package definition using information about a Helm chart.

func GetPackageFromSourceOrCluster added in v0.56.0

func GetPackageFromSourceOrCluster(ctx context.Context, cluster *cluster.Cluster, src string, namespaceOverride string, opts LoadOptions) (_ v1alpha1.ZarfPackage, err error)

GetPackageFromSourceOrCluster retrieves a Zarf package from a source or cluster.

func Lint added in v0.56.0

func Lint(ctx context.Context, packagePath string, opts LintOptions) error

Lint lints the given Zarf package

func LoadPackage added in v0.56.0

func LoadPackage(ctx context.Context, source string, opts LoadOptions) (_ *layout.PackageLayout, err error)

LoadPackage fetches, verifies, and loads a Zarf package from the specified source.

func OverridePackageNamespace added in v0.57.0

func OverridePackageNamespace(pkg v1alpha1.ZarfPackage, namespace string) error

OverridePackageNamespace overrides the package namespace if the package contains only one unique namespace

func PublishFromOCI added in v0.56.0

func PublishFromOCI(ctx context.Context, src registry.Reference, dst registry.Reference, opts PublishFromOCIOptions) (err error)

PublishFromOCI takes a source and destination registry reference and a PublishFromOCIOpts and copies the package from the source to the destination. src and dst are references to the full package ref, e.g. my-registry.com/my-namespace/my-package:0.0.1

func PublishPackage added in v0.56.0

func PublishPackage(ctx context.Context, pkgLayout *layout.PackageLayout, dst registry.Reference, opts PublishPackageOptions) (registry.Reference, error)

PublishPackage takes a package layout and pushes the package to the given registry. dst is the path to the registry namespace, e.g. my-registry.com/my-namespace. The full package ref is created using the package name and returned

func PublishSkeleton added in v0.56.0

func PublishSkeleton(ctx context.Context, path string, ref registry.Reference, opts PublishSkeletonOptions) (registry.Reference, error)

PublishSkeleton takes a Path to the package definition and uploads a skeleton package to the given a registry. dst is the path to the registry namespace, e.g. my-registry.com/my-namespace. The full package ref is created using the package name and returned

func Pull added in v0.55.0

func Pull(ctx context.Context, source, destination string, opts PullOptions) (_ string, err error)

Pull takes a source URL and destination directory, fetches the Zarf package from the given sources, and returns the path to the fetched package.

func PushImagesToRegistry added in v0.56.0

func PushImagesToRegistry(ctx context.Context, pkgLayout *layout.PackageLayout, registryInfo state.RegistryInfo, opts ImagePushOptions) error

PushImagesToRegistry pushes images in the package layout to the specified registry

func PushReposToRepository added in v0.56.0

func PushReposToRepository(ctx context.Context, pkgLayout *layout.PackageLayout, gitInfo state.GitServerInfo, opts RepoPushOptions) error

PushReposToRepository pushes Git repositories in the package layout to the Git server

func Remove added in v0.56.0

func Remove(ctx context.Context, pkg v1alpha1.ZarfPackage, opts RemoveOptions) error

Remove removes a package that was already deployed onto a cluster, uninstalling all installed helm charts.

func UpdateImages added in v0.66.0

func UpdateImages(ctx context.Context, baseDir string, imagesScans []ComponentImageScan) error

UpdateImages updates the images field for components in a zarf.yaml

Types

type ComponentImageScan added in v0.56.0

type ComponentImageScan struct {
	// ComponentName is the name of the component where the images were found
	ComponentName string
	// Matches contains definitively identified container images, such as those in an image: field
	Matches []string
	// PotentialMatches contains potential container images found by a regex
	PotentialMatches []string
	// CosignArtifacts contains found cosign artifacts for images
	CosignArtifacts []string
	// WhyResources contains the resources where specific images were found (when Why option is used)
	WhyResources []Resource
}

ComponentImageScan contains the results of FindImages for a component

func FindImages added in v0.56.0

func FindImages(ctx context.Context, packagePath string, opts FindImagesOptions) (_ []ComponentImageScan, err error)

FindImages iterates over the manifests and charts within each component to find any container images It returns a FindImageResults which contains a scan result for each component

type CreateOptions added in v0.56.0

type CreateOptions struct {
	Flavor                  string
	RegistryOverrides       []images.RegistryOverride
	SigningKeyPath          string
	SigningKeyPassword      string
	SetVariables            map[string]string
	MaxPackageSizeMB        int
	SBOMOut                 string
	SkipSBOM                bool
	DifferentialPackagePath string
	OCIConcurrency          int
	CachePath               string
	WithBuildMachineInfo    bool
	// applicable when output is an OCI registry
	RemoteOptions
	// IsInteractive decides if Zarf can interactively prompt users through the CLI
	IsInteractive bool
	// SkipVersionCheck skips version requirement validation
	SkipVersionCheck bool
}

CreateOptions are the optional parameters to create

type DeployOptions added in v0.56.0

type DeployOptions struct {
	// Deploy time set variables
	SetVariables map[string]string
	// Values are values passed in at deploy time. They can come from the CLI, user configuration, or set directly by
	// API callers.
	value.Values
	// Whether to adopt any pre-existing K8s resources into the Helm charts managed by Zarf
	AdoptExistingResources bool
	// Timeout for Helm operations
	Timeout time.Duration
	// Retries to preform for operations like git and image pushes
	Retries int
	// Number of layers to push concurrently per image
	OCIConcurrency int
	// Namespace is an optional namespace override for package deployment
	NamespaceOverride string
	// Remote Options for image pushes
	RemoteOptions
	// How to configure Zarf state if it's not already been configured
	GitServer      state.GitServerInfo
	RegistryInfo   state.RegistryInfo
	ArtifactServer state.ArtifactServerInfo
	StorageClass   string
	InjectorPort   int

	// [Library Only] A map of component names to chart names containing Helm Chart values to override values on deploy
	ValuesOverridesMap ValuesOverrides
	// IsInteractive decides if Zarf can interactively prompt users through the CLI
	IsInteractive bool
	// SkipVersionCheck skips version requirement validation
	SkipVersionCheck bool
}

DeployOptions are optional parameters to packager.Deploy

type DeployResult added in v0.58.0

type DeployResult struct {
	DeployedComponents []state.DeployedComponent
	VariableConfig     *variables.VariableConfig
	Values             value.Values
}

DeployResult is the result of a successful deploy

func Deploy added in v0.56.0

func Deploy(ctx context.Context, pkgLayout *layout.PackageLayout, opts DeployOptions) (DeployResult, error)

Deploy takes a reference to a `layout.PackageLayout` and deploys the package. If successful, returns a list of components that were successfully deployed and the associated variable config.

type DevDeployOptions added in v0.56.0

type DevDeployOptions struct {
	// When true packs images and repos into the package and uses the cluster Zarf state
	// When false deploys package without repos or images and uses the default Zarf state
	AirgapMode bool
	// 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
	// RegistryURL allows for an override to the Zarf state registry URL when not in airgap mode. Important for setting the ###ZARF_REGISTRY### template
	RegistryURL string
	// RegistryOverrides overrides the basepath of an OCI image with a path to a different registry during package assembly
	RegistryOverrides []images.RegistryOverride
	// CreateSetVariables are for package templates
	CreateSetVariables map[string]string
	// DeploySetVariables are for package variables
	DeploySetVariables map[string]string
	// OptionalComponents to be deployed
	OptionalComponents string
	// Timeout for Helm operations
	Timeout time.Duration
	// Retries to preform for operations like git and image pushes
	Retries int
	// These fields are only used if in airgap mode as they are relevant to requests from the git-server / registry
	OCIConcurrency int
	CachePath      string
	// SkipVersionCheck skips version requirement validation
	SkipVersionCheck bool
	RemoteOptions
}

DevDeployOptions are the optionalParameters to DevDeploy

type FindImagesOptions added in v0.56.0

type FindImagesOptions struct {
	// RepoHelmChartPath specifies the path to helm charts in git repos defined in the zarf.yaml
	RepoHelmChartPath string
	// RegistryURL specifies the value of the ###ZARF_REGISTRY### variable during templating
	RegistryURL string
	// KubeVersionOverride specifies the kubernetes version to provide the Helm chart
	KubeVersionOverride string
	// CreateSetVariables specifies the package create templates
	CreateSetVariables map[string]string
	// DeploySetVariables specifies the package deploy variables
	DeploySetVariables map[string]string
	// Flavor specifies the flavor to use
	Flavor string
	// Why specifies the image to look for so we can print the containing manifest
	Why string
	// SkipCosign specifies whether to skip cosign artifact lookups
	SkipCosign bool
	// CachePath is used to cache layers from skeleton package pulls
	CachePath string
	// IsInteractive decides if Zarf can interactively prompt users through the CLI
	IsInteractive bool
}

FindImagesOptions declares the parameters to find images.

type GenerateOptions added in v0.56.0

type GenerateOptions struct {
	// Path to the Helm chart in the git repository
	GitPath string
	// Kube version to provide to the Helm chart
	KubeVersion string
}

GenerateOptions are the options for generating a Zarf package.

type ImagePushOptions added in v0.56.0

type ImagePushOptions struct {
	Cluster         *cluster.Cluster
	NoImageChecksum bool
	Retries         int
	OCIConcurrency  int
	RemoteOptions
}

ImagePushOptions are optional parameters to push images in a zarf package to a registry

type InspectDefinitionResourcesOptions added in v0.56.0

type InspectDefinitionResourcesOptions struct {
	CreateSetVariables map[string]string
	DeploySetVariables map[string]string
	// Values are values passed in at inspect time. They can come from the CLI, user configuration, or set directly by
	// API callers.
	value.Values
	Flavor      string
	KubeVersion string
	// CachePath is used to cache layers from skeleton package pulls
	CachePath string
	// IsInteractive decides if Zarf can interactively prompt users through the CLI
	IsInteractive bool
}

InspectDefinitionResourcesOptions are the optional parameters to InspectDefinitionResources

type InspectPackageResourcesOptions added in v0.56.0

type InspectPackageResourcesOptions struct {
	SetVariables map[string]string
	KubeVersion  string
	// IsInteractive decides if Zarf can interactively prompt users through the CLI
	IsInteractive bool
}

InspectPackageResourcesOptions are the optional parameters to InspectPackageResources

type LintOptions added in v0.56.0

type LintOptions struct {
	SetVariables map[string]string
	Flavor       string
	CachePath    string
}

LintOptions are the optional parameters to Lint

type LoadOptions added in v0.56.0

type LoadOptions struct {
	Shasum                  string
	Architecture            string
	PublicKeyPath           string
	SkipSignatureValidation bool
	Filter                  filters.ComponentFilterStrategy
	Output                  string
	// number of layers to pull in parallel
	OCIConcurrency int
	// Layers to pull during OCI pull
	LayersSelector zoci.LayersSelector
	// CachePath is used to cache layers from OCI package pulls
	CachePath string
	// Only applicable to OCI + HTTP
	RemoteOptions
}

LoadOptions are the options for LoadPackage.

type PublishFromOCIOptions added in v0.56.0

type PublishFromOCIOptions struct {
	// OCIConcurrency configures the amount of layers to push in parallel
	OCIConcurrency int
	// Architecture is the architecture we are publishing to
	Architecture string
	// Retries is the number of times to retry a failed push
	Retries int
	RemoteOptions
}

PublishFromOCIOptions declares the parameters to publish a package.

type PublishPackageOptions added in v0.56.0

type PublishPackageOptions struct {
	// OCIConcurrency configures the amount of layers to push in parallel
	OCIConcurrency int
	// SigningKeyPath points to a signing key on the local disk.
	SigningKeyPath string
	// SigningKeyPassword holds a password to use the key at SigningKeyPath.
	SigningKeyPassword string
	// Retries specifies the number of retries to use
	Retries int
	RemoteOptions
}

PublishPackageOptions declares the parameters to publish a package.

type PublishSkeletonOptions added in v0.56.0

type PublishSkeletonOptions struct {
	// OCIConcurrency configures the amount of layers to push in parallel
	OCIConcurrency int
	// SigningKeyPath points to a signing key on the local disk.
	SigningKeyPath string
	// SigningKeyPassword holds a password to use the key at SigningKeyPath.
	SigningKeyPassword string
	// CachePath is used to cache layers from skeleton package pulls
	CachePath string
	// Flavor specifies the flavor to use
	Flavor string
	// Retries specifies the number of retries to use
	Retries int
	// SkipVersionCheck skips version requirement validation
	SkipVersionCheck bool
	// WithBuildMachineInfo controls whether to include build machine information (hostname and username) in the package metadata
	WithBuildMachineInfo bool
	RemoteOptions
}

PublishSkeletonOptions declares the parameters to publish a skeleton package.

type PullOptions added in v0.55.0

type PullOptions struct {
	// SHASum uniquely identifies a package based on its contents.
	SHASum string
	// SkipSignatureValidation flags whether Pull should skip validating the signature.
	SkipSignatureValidation bool
	// Architecture is the package architecture.
	Architecture string
	// PublicKeyPath validates the create-time signage of a package.
	PublicKeyPath string
	// OCIConcurrency is the number of layers pulled in parallel
	OCIConcurrency int
	// CachePath is used to cache layers from OCI package pulls
	CachePath string
	RemoteOptions
}

PullOptions declares optional configuration for a Pull operation.

type RemoteOptions added in v0.56.0

type RemoteOptions struct {
	PlainHTTP             bool
	InsecureSkipTLSVerify bool
}

RemoteOptions are common options when calling a remote

type RemoveOptions added in v0.56.0

type RemoveOptions struct {
	Cluster           *cluster.Cluster
	Timeout           time.Duration
	NamespaceOverride string
	SkipVersionCheck  bool
	// Values passed in at remove time. They can come from the CLI or set directly by API callers.
	value.Values
}

RemoveOptions are the options for Remove.

type RepoPushOptions added in v0.56.0

type RepoPushOptions struct {
	Cluster *cluster.Cluster
	Retries int
}

RepoPushOptions are optional parameters to push repos in a zarf package to a Git server

type Resource added in v0.56.0

type Resource struct {
	Content      string
	Name         string
	ResourceType ResourceType
}

Resource contains a Kubernetes Manifest or Chart

func InspectDefinitionResources added in v0.56.0

func InspectDefinitionResources(ctx context.Context, packagePath string, opts InspectDefinitionResourcesOptions) (_ []Resource, err error)

InspectDefinitionResources templates and returns the manifests and Helm chart manifests found in the zarf.yaml at the given path

func InspectPackageResources added in v0.56.0

func InspectPackageResources(ctx context.Context, pkgLayout *layout.PackageLayout, opts InspectPackageResourcesOptions) (_ []Resource, err error)

InspectPackageResources templates and returns the manifests, charts, and values files in the package as they would be on deploy

type ResourceType added in v0.56.0

type ResourceType string

ResourceType represents the different types of Zarf resources that can be inspected

const (
	ManifestResource   ResourceType = "manifest"
	ChartResource      ResourceType = "chart"
	ValuesFileResource ResourceType = "valuesfile"
)

The different types of resources that can be inspected

type ValuesOverrides added in v0.64.0

type ValuesOverrides map[string]map[string]map[string]any

ValuesOverrides is a map of component names to chart names containing Helm Chart values to override values on deploy.

Directories

Path Synopsis
Package actions contains functions for running component actions within Zarf packages.
Package actions contains functions for running component actions within Zarf packages.
Package filters contains core implementations of the ComponentFilterStrategy interface.
Package filters contains core implementations of the ComponentFilterStrategy interface.
Package layout contains functions for interacting with Zarf packages.
Package layout contains functions for interacting with Zarf packages.
Package load takes a ZarfPackageConfig, composes imports, and validates the con
Package load takes a ZarfPackageConfig, composes imports, and validates the con

Jump to

Keyboard shortcuts

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