v1alpha1

package
v0.38.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 11

Documentation

Overview

Package v1alpha1 holds the definition of the v1alpha1 Zarf Package

Package v1alpha1 holds the definition of the v1alpha1 Zarf Package

Index

Constants

View Source
const (
	ZarfPackageTemplatePrefix = "###ZARF_PKG_TMPL_"
	ZarfPackageVariablePrefix = "###ZARF_PKG_VAR_"
	ZarfPackageArch           = "###ZARF_PKG_ARCH###"
	ZarfComponentName         = "###ZARF_COMPONENT_NAME###"
)

Zarf looks for these strings in zarf.yaml to make dynamic changes

View Source
const (
	// ZarfInitConfig is the kind of Zarf package used during `zarf init`.
	ZarfInitConfig ZarfPackageKind = "ZarfInitConfig"
	// ZarfPackageConfig is the default kind of Zarf package, primarily used during `zarf package`.
	ZarfPackageConfig ZarfPackageKind = "ZarfPackageConfig"
	// APIVersion the api version of this package.
	APIVersion string = "zarf.dev/v1alpha1"
)

Variables

View Source
var (
	// IsUppercaseNumberUnderscore is a regex for uppercase, numbers and underscores.
	// https://regex101.com/r/tfsEuZ/1
	IsUppercaseNumberUnderscore = regexp.MustCompile(`^[A-Z0-9_]+$`).MatchString
)

Functions

This section is empty.

Types

type Constant

type Constant struct {
	// The name to be used for the constant
	Name string `json:"name" jsonschema:"pattern=^[A-Z0-9_]+$"`
	// The value to set for the constant during deploy
	Value string `json:"value"`
	// A description of the constant to explain its purpose on package create or deploy confirmation prompts
	Description string `json:"description,omitempty"`
	// Whether to automatically indent the variable's value (if multiline) when templating. Based on the number of chars before the start of ###ZARF_CONST_.
	AutoIndent bool `json:"autoIndent,omitempty"`
	// An optional regex pattern that a constant value must match before a package can be created.
	Pattern string `json:"pattern,omitempty"`
}

Constant are constants that can be used to dynamically template K8s resources or run in actions.

func (Constant) Validate

func (c Constant) Validate() error

Validate runs all validation checks on a package constant.

type DeprecatedZarfComponentScripts

type DeprecatedZarfComponentScripts struct {
	// Show the output of the script during package deployment.
	ShowOutput bool `json:"showOutput,omitempty"`
	// Timeout in seconds for the script.
	TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
	// Retry the script if it fails.
	Retry bool `json:"retry,omitempty"`
	// Scripts to run before the component is added during package create.
	Prepare []string `json:"prepare,omitempty"`
	// Scripts to run before the component is deployed.
	Before []string `json:"before,omitempty"`
	// Scripts to run after the component successfully deploys.
	After []string `json:"after,omitempty"`
}

DeprecatedZarfComponentScripts are scripts that run before or after a component is deployed.

type InteractiveVariable

type InteractiveVariable struct {
	Variable `json:",inline"`
	// A description of the variable to be used when prompting the user a value
	Description string `json:"description,omitempty"`
	// The default value to use for the variable
	Default string `json:"default,omitempty"`
	// Whether to prompt the user for input for this variable
	Prompt bool `json:"prompt,omitempty"`
}

InteractiveVariable is a variable that can be used to prompt a user for more information

type SetVariable

type SetVariable struct {
	Variable `json:",inline"`
	// The value the variable is currently set with
	Value string `json:"value"`
}

SetVariable tracks internal variables that have been set during this run of Zarf

type Shell

type Shell struct {
	Windows string `` /* 290-byte string literal not displayed */
	Linux   string `` /* 185-byte string literal not displayed */
	Darwin  string `` /* 186-byte string literal not displayed */
}

Shell represents the desired shell to use for a given command

type Variable

type Variable struct {
	// The name to be used for the variable
	Name string `json:"name" jsonschema:"pattern=^[A-Z0-9_]+$"`
	// Whether to mark this variable as sensitive to not print it in the log
	Sensitive bool `json:"sensitive,omitempty"`
	// Whether to automatically indent the variable's value (if multiline) when templating. Based on the number of chars before the start of ###ZARF_VAR_.
	AutoIndent bool `json:"autoIndent,omitempty"`
	// An optional regex pattern that a variable value must match before a package deployment can continue.
	Pattern string `json:"pattern,omitempty"`
	// Changes the handling of a variable to load contents differently (i.e. from a file rather than as a raw variable - templated files should be kept below 1 MiB)
	Type VariableType `json:"type,omitempty" jsonschema:"enum=raw,enum=file"`
}

Variable represents a variable that has a value set programmatically

type VariableType

type VariableType string

VariableType represents a type of a Zarf package variable

const (
	// RawVariableType is the default type for a Zarf package variable
	RawVariableType VariableType = "raw"
	// FileVariableType is a type for a Zarf package variable that loads its contents from a file
	FileVariableType VariableType = "file"
)

type ZarfBuildData

type ZarfBuildData struct {
	// The machine name that created this package.
	Terminal string `json:"terminal"`
	// The username who created this package.
	User string `json:"user"`
	// The architecture this package was created on.
	Architecture string `json:"architecture"`
	// The timestamp when this package was created.
	Timestamp string `json:"timestamp"`
	// The version of Zarf used to build this package.
	Version string `json:"version"`
	// Any migrations that have been run on this package.
	Migrations []string `json:"migrations,omitempty"`
	// Any registry domains that were overridden on package create when pulling images.
	RegistryOverrides map[string]string `json:"registryOverrides,omitempty"`
	// Whether this package was created with differential components.
	Differential bool `json:"differential,omitempty"`
	// Version of a previously built package used as the basis for creating this differential package.
	DifferentialPackageVersion string `json:"differentialPackageVersion,omitempty"`
	// List of components that were not included in this package due to differential packaging.
	DifferentialMissing []string `json:"differentialMissing,omitempty"`
	// The minimum version of Zarf that does not have breaking package structure changes.
	LastNonBreakingVersion string `json:"lastNonBreakingVersion,omitempty"`
	// The flavor of Zarf used to build this package.
	Flavor string `json:"flavor,omitempty"`
}

ZarfBuildData is written during the packager.Create() operation to track details of the created package.

type ZarfChart

type ZarfChart struct {
	// The name of the chart within Zarf; note that this must be unique and does not need to be the same as the name in the chart repo.
	Name string `json:"name"`
	// The version of the chart to deploy; for git-based charts this is also the tag of the git repo by default (when not using the '@' syntax for 'repos').
	Version string `json:"version,omitempty"`
	// The URL of the OCI registry, chart repository, or git repo where the helm chart is stored.
	URL string `` /* 275-byte string literal not displayed */
	// The name of a chart within a Helm repository (defaults to the Zarf name of the chart).
	RepoName string `json:"repoName,omitempty"`
	// (git repo only) The sub directory to the chart within a git repo.
	GitPath string `json:"gitPath,omitempty" jsonschema:"example=charts/your-chart"`
	// The path to a local chart's folder or .tgz archive.
	LocalPath string `json:"localPath,omitempty"`
	// The namespace to deploy the chart to.
	Namespace string `json:"namespace,omitempty"`
	// The name of the Helm release to create (defaults to the Zarf name of the chart).
	ReleaseName string `json:"releaseName,omitempty"`
	// Whether to not wait for chart resources to be ready before continuing.
	NoWait bool `json:"noWait,omitempty"`
	// List of local values file paths or remote URLs to include in the package; these will be merged together when deployed.
	ValuesFiles []string `json:"valuesFiles,omitempty"`
	// [alpha] List of variables to set in the Helm chart.
	Variables []ZarfChartVariable `json:"variables,omitempty"`
}

ZarfChart defines a helm chart to be deployed.

type ZarfChartVariable

type ZarfChartVariable struct {
	// The name of the variable.
	Name string `json:"name" jsonschema:"pattern=^[A-Z0-9_]+$"`
	// A brief description of what the variable controls.
	Description string `json:"description"`
	// The path within the Helm chart values where this variable applies.
	Path string `json:"path"`
}

ZarfChartVariable represents a variable that can be set for a Helm chart overrides.

type ZarfComponent

type ZarfComponent struct {
	// The name of the component.
	Name string `json:"name" jsonschema:"pattern=^[a-z0-9][a-z0-9\\-]*$"`

	// Message to include during package deploy describing the purpose of this component.
	Description string `json:"description,omitempty"`

	// Determines the default Y/N state for installing this component on package deploy.
	Default bool `json:"default,omitempty"`

	// Do not prompt user to install this component.
	Required *bool `json:"required,omitempty"`

	// Filter when this component is included in package creation or deployment.
	Only ZarfComponentOnlyTarget `json:"only,omitempty"`

	// [Deprecated] Create a user selector field based on all components in the same group. This will be removed in Zarf v1.0.0. Consider using 'only.flavor' instead.
	DeprecatedGroup string `json:"group,omitempty" jsonschema:"deprecated=true"`

	// [Deprecated] Specify a path to a public key to validate signed online resources. This will be removed in Zarf v1.0.0.
	DeprecatedCosignKeyPath string `json:"cosignKeyPath,omitempty" jsonschema:"deprecated=true"`

	// Import a component from another Zarf package.
	Import ZarfComponentImport `json:"import,omitempty"`

	// Kubernetes manifests to be included in a generated Helm chart on package deploy.
	Manifests []ZarfManifest `json:"manifests,omitempty"`

	// Helm charts to install during package deploy.
	Charts []ZarfChart `json:"charts,omitempty"`

	// Datasets to inject into a container in the target cluster.
	DataInjections []ZarfDataInjection `json:"dataInjections,omitempty"`

	// Files or folders to place on disk during package deployment.
	Files []ZarfFile `json:"files,omitempty"`

	// List of OCI images to include in the package.
	Images []string `json:"images,omitempty"`

	// List of git repos to include in the package.
	Repos []string `json:"repos,omitempty"`

	// Extend component functionality with additional features.
	Extensions extensions.ZarfComponentExtensions `json:"extensions,omitempty"`

	// [Deprecated] (replaced by actions) Custom commands to run before or after package deployment. This will be removed in Zarf v1.0.0.
	DeprecatedScripts DeprecatedZarfComponentScripts `json:"scripts,omitempty" jsonschema:"deprecated=true"`

	// Custom commands to run at various stages of a package lifecycle.
	Actions ZarfComponentActions `json:"actions,omitempty"`
}

ZarfComponent is the primary functional grouping of assets to deploy by Zarf.

func (ZarfComponent) IsRequired

func (c ZarfComponent) IsRequired() bool

IsRequired returns if the component is required or not.

func (ZarfComponent) RequiresCluster

func (c ZarfComponent) RequiresCluster() bool

RequiresCluster returns if the component requires a cluster connection to deploy.

type ZarfComponentAction

type ZarfComponentAction struct {
	// Hide the output of the command during package deployment (default false).
	Mute *bool `json:"mute,omitempty"`
	// Timeout in seconds for the command (default to 0, no timeout for cmd actions and 300, 5 minutes for wait actions).
	MaxTotalSeconds *int `json:"maxTotalSeconds,omitempty"`
	// Retry the command if it fails up to given number of times (default 0).
	MaxRetries *int `json:"maxRetries,omitempty"`
	// The working directory to run the command in (default is CWD).
	Dir *string `json:"dir,omitempty"`
	// Additional environment variables to set for the command.
	Env []string `json:"env,omitempty"`
	// The command to run. Must specify either cmd or wait for the action to do anything.
	Cmd string `json:"cmd,omitempty"`
	// (cmd only) Indicates a preference for a shell for the provided cmd to be executed in on supported operating systems.
	Shell *Shell `json:"shell,omitempty"`
	// [Deprecated] (replaced by setVariables) (onDeploy/cmd only) The name of a variable to update with the output of the command. This variable will be available to all remaining actions and components in the package. This will be removed in Zarf v1.0.0.
	DeprecatedSetVariable string `json:"setVariable,omitempty" jsonschema:"pattern=^[A-Z0-9_]+$"`
	// (onDeploy/cmd only) An array of variables to update with the output of the command. These variables will be available to all remaining actions and components in the package.
	SetVariables []Variable `json:"setVariables,omitempty"`
	// Description of the action to be displayed during package execution instead of the command.
	Description string `json:"description,omitempty"`
	// Wait for a condition to be met before continuing. Must specify either cmd or wait for the action. See the 'zarf tools wait-for' command for more info.
	Wait *ZarfComponentActionWait `json:"wait,omitempty"`
}

ZarfComponentAction represents a single action to run during a zarf package operation.

type ZarfComponentActionDefaults

type ZarfComponentActionDefaults struct {
	// Hide the output of commands during execution (default false).
	Mute bool `json:"mute,omitempty"`
	// Default timeout in seconds for commands (default to 0, no timeout).
	MaxTotalSeconds int `json:"maxTotalSeconds,omitempty"`
	// Retry commands given number of times if they fail (default 0).
	MaxRetries int `json:"maxRetries,omitempty"`
	// Working directory for commands (default CWD).
	Dir string `json:"dir,omitempty"`
	// Additional environment variables for commands.
	Env []string `json:"env,omitempty"`
	// (cmd only) Indicates a preference for a shell for the provided cmd to be executed in on supported operating systems.
	Shell Shell `json:"shell,omitempty"`
}

ZarfComponentActionDefaults sets the default configs for child actions.

type ZarfComponentActionSet

type ZarfComponentActionSet struct {
	// Default configuration for all actions in this set.
	Defaults ZarfComponentActionDefaults `json:"defaults,omitempty"`
	// Actions to run at the start of an operation.
	Before []ZarfComponentAction `json:"before,omitempty"`
	// Actions to run at the end of an operation.
	After []ZarfComponentAction `json:"after,omitempty"`
	// Actions to run if all operations succeed.
	OnSuccess []ZarfComponentAction `json:"onSuccess,omitempty"`
	// Actions to run if all operations fail.
	OnFailure []ZarfComponentAction `json:"onFailure,omitempty"`
}

ZarfComponentActionSet is a set of actions to run during a zarf package operation.

type ZarfComponentActionWait

type ZarfComponentActionWait struct {
	// Wait for a condition to be met in the cluster before continuing. Only one of cluster or network can be specified.
	Cluster *ZarfComponentActionWaitCluster `json:"cluster,omitempty"`
	// Wait for a condition to be met on the network before continuing. Only one of cluster or network can be specified.
	Network *ZarfComponentActionWaitNetwork `json:"network,omitempty"`
}

ZarfComponentActionWait specifies a condition to wait for before continuing

type ZarfComponentActionWaitCluster

type ZarfComponentActionWaitCluster struct {
	// The kind of resource to wait for.
	Kind string `json:"kind" jsonschema:"example=Pod,example=Deployment"`
	// The name of the resource or selector to wait for.
	Name string `json:"name" jsonschema:"example=podinfo,example=app=podinfo"`
	// The namespace of the resource to wait for.
	Namespace string `json:"namespace,omitempty"`
	// The condition or jsonpath state to wait for; defaults to exist, a special condition that will wait for the resource to exist.
	Condition string `json:"condition,omitempty" jsonschema:"example=Ready,example=Available,'{.status.availableReplicas}'=23"`
}

ZarfComponentActionWaitCluster specifies a condition to wait for before continuing

type ZarfComponentActionWaitNetwork

type ZarfComponentActionWaitNetwork struct {
	// The protocol to wait for.
	Protocol string `json:"protocol" jsonschema:"enum=tcp,enum=http,enum=https"`
	// The address to wait for.
	Address string `json:"address" jsonschema:"example=localhost:8080,example=1.1.1.1"`
	// The HTTP status code to wait for if using http or https.
	Code int `json:"code,omitempty" jsonschema:"example=200,example=404"`
}

ZarfComponentActionWaitNetwork specifies a condition to wait for before continuing

type ZarfComponentActions

type ZarfComponentActions struct {
	// Actions to run during package creation.
	OnCreate ZarfComponentActionSet `json:"onCreate,omitempty"`
	// Actions to run during package deployment.
	OnDeploy ZarfComponentActionSet `json:"onDeploy,omitempty"`
	// Actions to run during package removal.
	OnRemove ZarfComponentActionSet `json:"onRemove,omitempty"`
}

ZarfComponentActions are ActionSets that map to different zarf package operations.

type ZarfComponentImport

type ZarfComponentImport struct {
	// The name of the component to import from the referenced zarf.yaml.
	Name string `json:"name,omitempty"`
	// The path to the directory containing the zarf.yaml to import.
	Path string `json:"path,omitempty"`
	// [beta] The URL to a Zarf package to import via OCI.
	URL string `json:"url,omitempty" jsonschema:"pattern=^oci://.*$"`
}

ZarfComponentImport structure for including imported Zarf components.

func (ZarfComponentImport) JSONSchemaExtend

func (ZarfComponentImport) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend extends the generated json schema during `zarf internal gen-config-schema`

type ZarfComponentOnlyCluster

type ZarfComponentOnlyCluster struct {
	// Only create and deploy to clusters of the given architecture.
	Architecture string `json:"architecture,omitempty" jsonschema:"enum=amd64,enum=arm64"`
	// A list of kubernetes distros this package works with (Reserved for future use).
	Distros []string `json:"distros,omitempty" jsonschema:"example=k3s,example=eks"`
}

ZarfComponentOnlyCluster represents the architecture and K8s cluster distribution to filter on.

type ZarfComponentOnlyTarget

type ZarfComponentOnlyTarget struct {
	// Only deploy component to specified OS.
	LocalOS string `json:"localOS,omitempty" jsonschema:"enum=linux,enum=darwin,enum=windows"`
	// Only deploy component to specified clusters.
	Cluster ZarfComponentOnlyCluster `json:"cluster,omitempty"`
	// Only include this component when a matching '--flavor' is specified on 'zarf package create'.
	Flavor string `json:"flavor,omitempty"`
}

ZarfComponentOnlyTarget filters a component to only show it for a given local OS and cluster.

type ZarfContainerTarget

type ZarfContainerTarget struct {
	// The namespace to target for data injection.
	Namespace string `json:"namespace"`
	// The K8s selector to target for data injection.
	Selector string `json:"selector" jsonschema:"example=app=data-injection"`
	// The container name to target for data injection.
	Container string `json:"container"`
	// The path within the container to copy the data into.
	Path string `json:"path"`
}

ZarfContainerTarget defines the destination info for a ZarfData target

type ZarfDataInjection

type ZarfDataInjection struct {
	// Either a path to a local folder/file or a remote URL of a file to inject into the given target pod + container.
	Source string `json:"source"`
	// The target pod + container to inject the data into.
	Target ZarfContainerTarget `json:"target"`
	// Compress the data before transmitting using gzip. Note: this requires support for tar/gzip locally and in the target image.
	Compress bool `json:"compress,omitempty"`
}

ZarfDataInjection is a data-injection definition.

type ZarfFile

type ZarfFile struct {
	// Local folder or file path or remote URL to pull into the package.
	Source string `json:"source"`
	// (files only) Optional SHA256 checksum of the file.
	Shasum string `json:"shasum,omitempty"`
	// The absolute or relative path where the file or folder should be copied to during package deploy.
	Target string `json:"target"`
	// (files only) Determines if the file should be made executable during package deploy.
	Executable bool `json:"executable,omitempty"`
	// List of symlinks to create during package deploy.
	Symlinks []string `json:"symlinks,omitempty"`
	// Local folder or file to be extracted from a 'source' archive.
	ExtractPath string `json:"extractPath,omitempty"`
}

ZarfFile defines a file to deploy.

type ZarfManifest

type ZarfManifest struct {
	// A name to give this collection of manifests; this will become the name of the dynamically-created helm chart.
	Name string `json:"name"`
	// The namespace to deploy the manifests to.
	Namespace string `json:"namespace,omitempty"`
	// List of local K8s YAML files or remote URLs to deploy (in order).
	Files []string `json:"files,omitempty"`
	// Allow traversing directory above the current directory if needed for kustomization.
	KustomizeAllowAnyDirectory bool `json:"kustomizeAllowAnyDirectory,omitempty"`
	// List of local kustomization paths or remote URLs to include in the package.
	Kustomizations []string `json:"kustomizations,omitempty"`
	// Whether to not wait for manifest resources to be ready before continuing.
	NoWait bool `json:"noWait,omitempty"`
}

ZarfManifest defines raw manifests Zarf will deploy as a helm chart.

type ZarfMetadata

type ZarfMetadata struct {
	// Name to identify this Zarf package.
	Name string `json:"name" jsonschema:"pattern=^[a-z0-9][a-z0-9\\-]*$"`
	// Additional information about this package.
	Description string `json:"description,omitempty"`
	// Generic string set by a package author to track the package version (Note: ZarfInitConfigs will always be versioned to the CLIVersion they were created with).
	Version string `json:"version,omitempty"`
	// Link to package information when online.
	URL string `json:"url,omitempty"`
	// An image URL to embed in this package (Reserved for future use in Zarf UI).
	Image string `json:"image,omitempty"`
	// Disable compression of this package.
	Uncompressed bool `json:"uncompressed,omitempty"`
	// The target cluster architecture for this package.
	Architecture string `json:"architecture,omitempty" jsonschema:"example=arm64,example=amd64"`
	// Yaml OnLy Online (YOLO): True enables deploying a Zarf package without first running zarf init against the cluster. This is ideal for connected environments where you want to use existing VCS and container registries.
	YOLO bool `json:"yolo,omitempty"`
	// Comma-separated list of package authors (including contact info).
	Authors string `` /* 132-byte string literal not displayed */
	// Link to package documentation when online.
	Documentation string `json:"documentation,omitempty"`
	// Link to package source code when online.
	Source string `json:"source,omitempty"`
	// Name of the distributing entity, organization or individual.
	Vendor string `json:"vendor,omitempty"`
	// Checksum of a checksums.txt file that contains checksums all the layers within the package.
	AggregateChecksum string `json:"aggregateChecksum,omitempty"`
}

ZarfMetadata lists information about the current ZarfPackage.

type ZarfPackage

type ZarfPackage struct {
	// The API version of the Zarf package.
	APIVersion string `json:"apiVersion,omitempty," jsonschema:"enum=zarf.dev/v1alpha1"`
	// The kind of Zarf package.
	Kind ZarfPackageKind `json:"kind" jsonschema:"enum=ZarfInitConfig,enum=ZarfPackageConfig,default=ZarfPackageConfig"`
	// Package metadata.
	Metadata ZarfMetadata `json:"metadata,omitempty"`
	// Zarf-generated package build data.
	Build ZarfBuildData `json:"build,omitempty"`
	// List of components to deploy in this package.
	Components []ZarfComponent `json:"components" jsonschema:"minItems=1"`
	// Constant template values applied on deploy for K8s resources.
	Constants []Constant `json:"constants,omitempty"`
	// Variable template values applied on deploy for K8s resources.
	Variables []InteractiveVariable `json:"variables,omitempty"`
}

ZarfPackage the top-level structure of a Zarf config file.

func (ZarfPackage) HasImages

func (pkg ZarfPackage) HasImages() bool

HasImages returns true if one of the components contains an image.

func (ZarfPackage) IsInitConfig

func (pkg ZarfPackage) IsInitConfig() bool

IsInitConfig returns whether a Zarf package is an init config.

func (ZarfPackage) IsSBOMAble

func (pkg ZarfPackage) IsSBOMAble() bool

IsSBOMAble checks if a package has contents that an SBOM can be created on (i.e. images, files, or data injections).

type ZarfPackageKind

type ZarfPackageKind string

ZarfPackageKind is an enum of the different kinds of Zarf packages.

Directories

Path Synopsis
Package extensions contains the types for all official extensions.
Package extensions contains the types for all official extensions.

Jump to

Keyboard shortcuts

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