dalec

package module
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 33 Imported by: 1

README

Dalec

Dalec is a project aimed at providing a declarative format for building system packages and containers from those packages.

Our goal is to provide a secure and reproducible way to build packages and containers, with a focus on supply chain security.

[!NOTE] Dalec is still under heavy development and the spec format is not currently considered stable. Feedback is welcome! ❤️

Features

  • 🐳 No additional tools are needed except for Docker!
  • 🚀 Easy to use declarative configuration that provides reproducible builds
  • 📦 Build packages and/or containers for a number of different targets such as Ubuntu, Azure Linux and Windows (cross compilation only)
  • 🔌 Pluggable support for other operating systems
  • 🤏 Minimal image size, resulting in less vulnerabilities and smaller attack surface
  • 🪟 Support for Windows containers
  • ✍️ Support for signed packages
  • 🔐 Ensure supply chain security with build time SBOMs, and Provenance attestations

👉 To get started, please see Dalec documentation!

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Documentation

Index

Constants

View Source
const DefaultPatchStrip int = 1

Variables

This section is empty.

Functions

func BuildImageConfig added in v0.4.0

func BuildImageConfig(spec *Spec, targetKey string, img *DockerImageSpec) error

func CacheDirsToRunOpt

func CacheDirsToRunOpt(mounts map[string]CacheDirConfig, distroKey, archKey string) llb.RunOption

CacheDirsToRunOpt converts the given cache directories into a RunOption.

func DefaultTarWorker added in v0.6.1

func DefaultTarWorker(resolver llb.ImageMetaResolver, opts ...llb.ConstraintsOpt) llb.State

func DisableDiffMerge

func DisableDiffMerge(v bool)

DisableDiffMerge allows disabling the use of llb.Diff and llb.Merge in favor of llb.Copy. This is needed when the buildkit version does not support llb.Diff and llb.Merge.

Mainly this would be to allow dockerd with the (current) standard setup of dockerd which uses "graphdrivers" to work as these ops are not supported by the graphdriver backend. When this is false and the graphdriver backend is used, the build will fail when buildkit checks the capabilities of the backend.

func DuplicateMap

func DuplicateMap[K comparable, V any](m map[K]V) map[K]V

func GetBaseOutputImage added in v0.4.0

func GetBaseOutputImage(spec *Spec, target string) string

func GetRepoKeys added in v0.10.0

func GetRepoKeys(configs []PackageRepositoryConfig, cfg *RepoPlatformConfig, sOpt SourceOpts, opts ...llb.ConstraintsOpt) (llb.RunOption, []string, error)
func InstallPostSymlinks(post *PostInstall, rootfsPath string) llb.RunOption

InstallPostSymlinks returns a RunOption that adds symlinks defined in the PostInstall underneath the provided rootfs path.

func MergeAtPath

func MergeAtPath(input llb.State, states []llb.State, dest string) llb.State

MergeAtPath merges the given states into the given destination path in the given input state.

func MergeImageConfig added in v0.2.0

func MergeImageConfig(dst *DockerImageConfig, src *ImageConfig) error

MergeImageConfig copies the fields from the source ImageConfig into the destination image.Image. If a field is not set in the source, it is not modified in the destination. Envs from ImageConfig are merged into the destination image.Image and take precedence.

func PatchSources

func PatchSources(worker llb.State, spec *Spec, sourceToState map[string]llb.State, opts ...llb.ConstraintsOpt) map[string]llb.State

PatchSources returns a new map containing the patched LLB state for each source in the source map. Sources that are not patched are also included in the result for convenience. `sourceToState` must be a complete map from source name -> llb state for each source in the dalec spec. `worker` must be an LLB state with a `patch` binary present.

func ProgressGroup

func ProgressGroup(name string) llb.ConstraintsOpt

ProgressGroup creates a progress group with the given name. If a progress group is already set in the constraints the id is reused. If no progress group is set a new id is generated.

func SetBuildNetworkMode added in v0.10.0

func SetBuildNetworkMode(spec *Spec) llb.StateOption

SetBuildNetworkMode returns an llb.StateOption that determines which

func ShArgs added in v0.6.1

func ShArgs(args string) llb.RunOption

ShArgs returns a RunOption that runs the given command in a shell.

func ShArgsf added in v0.9.0

func ShArgsf(format string, args ...interface{}) llb.RunOption

ShArgsf is the same as ShArgs but tkes a format string

func SortMapKeys

func SortMapKeys[T any](m map[string]T) []string

SortMapKeys is a convenience generic function to sort the keys of a map[string]T

func SortedMapValues added in v0.6.1

func SortedMapValues[T any](m map[string]T) []T

SortMapValues is like maps.Values, but the list is sorted based on the map key

func SourceIsDir

func SourceIsDir(src Source) bool

func Sources added in v0.6.1

func Sources(spec *Spec, sOpt SourceOpts, opts ...llb.ConstraintsOpt) (map[string]llb.State, error)

Sources gets all the source LLB states from the spec.

func Tar added in v0.6.1

func Tar(work llb.State, src llb.State, dest string, opts ...llb.ConstraintsOpt) llb.State

Tar creates a tar+gz from the provided state and puts it in the provided dest. The provided work state is used to perform the necessary operations to produce the tarball and requires the tar and gzip binaries.

func WithConstraint added in v0.10.0

func WithConstraint(in *llb.Constraints) llb.ConstraintsOpt

func WithConstraints

func WithConstraints(ls ...llb.ConstraintsOpt) llb.ConstraintsOpt

func WithCreateDestPath

func WithCreateDestPath() llb.CopyOption

func WithDirContentsOnly

func WithDirContentsOnly() llb.CopyOption

func WithExcludes

func WithExcludes(patterns []string) llb.CopyOption

func WithIncludes

func WithIncludes(patterns []string) llb.CopyOption

func WithMountedAptCache added in v0.2.0

func WithMountedAptCache(namePrefix string) llb.RunOption

WithMountedAptCache gives an llb.RunOption that mounts the apt cache directories. It uses the given namePrefix as the prefix for the cache keys. namePrefix should be distinct per distro version.

func WithRepoConfigs added in v0.10.0

func WithRepoConfigs(repos []PackageRepositoryConfig, cfg *RepoPlatformConfig, sOpt SourceOpts, opts ...llb.ConstraintsOpt) (llb.RunOption, error)

Returns a run option for importing the config files for all repos

func WithRepoData added in v0.10.0

func WithRepoData(repos []PackageRepositoryConfig, sOpts SourceOpts, opts ...llb.ConstraintsOpt) (llb.RunOption, error)

Returns a run option which mounts the data dirs for all specified repos

func WithRunOptions added in v0.2.0

func WithRunOptions(opts ...llb.RunOption) llb.RunOption

Types

type ArtifactBuild

type ArtifactBuild struct {
	// Steps is the list of commands to run to build the artifact(s).
	// Each step is run sequentially and will be cached accordingly depending on the frontend implementation.
	Steps []BuildStep `yaml:"steps" json:"steps" jsonschema:"required"`
	// Env is the list of environment variables to set for all commands in this step group.
	Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`

	// NetworkMode sets the network mode to use during the build phase.
	// Accepted values: none, sandbox
	// Default: none
	NetworkMode string `yaml:"network_mode,omitempty" json:"network_mode,omitempty" jsonschema:"enum=none,enum=sandbox"`
}

ArtifactBuild configures a group of steps that are run sequentially along with their outputs to build the artifact(s).

type ArtifactConfig

type ArtifactConfig struct {
	// Subpath is the subpath to use in the package for the artifact type.
	//
	// As an example, binaries are typically placed in /usr/bin when installed.
	// If you want to nest them in a subdirectory, you can specify it here.
	SubPath string `yaml:"subpath,omitempty" json:"subpath,omitempty"`
	// Name is file or dir name to use for the artifact in the package.
	// If empty, the file or dir name from the produced artifact will be used.
	Name string `yaml:"name,omitempty" json:"name,omitempty"`
}

ArtifactConfig is the configuration for a given artifact type. This is used to customize where an artifact will be placed when installed.

func (*ArtifactConfig) ResolveName added in v0.4.0

func (a *ArtifactConfig) ResolveName(path string) string

type ArtifactDirConfig added in v0.4.0

type ArtifactDirConfig struct {
	// Mode is used to set the file permission bits of the final created directory to the specified mode.
	// Mode is the octal permissions to set on the dir.
	Mode fs.FileMode `yaml:"mode,omitempty" json:"mode,omitempty"`
}

ArtifactDirConfig contains information about the directory to be created

type ArtifactSymlinkConfig added in v0.9.0

type ArtifactSymlinkConfig struct {
	// Source is the path that is being linked to
	// Example:
	//   If you want a symlink in /usr/bin/foo that is linking to /usr/bin/foo/foo
	//   then the `Source` is `/usr/bin/foo/foo`
	Source string `yaml:"source,omitempty" json:"source,omitempty"`
	// Dest is the path where the symlink will be installed
	Dest string `yaml:"dest,omitempty" json:"dest,omitempty"`
}

type Artifacts

type Artifacts struct {
	// Binaries is the list of binaries to include in the package.
	Binaries map[string]ArtifactConfig `yaml:"binaries,omitempty" json:"binaries,omitempty"`
	// Libexec is the list of additional binaries that may be invoked by the main package binary.
	Libexec map[string]ArtifactConfig `yaml:"libexec,omitempty" json:"libexec,omitempty"`
	// Manpages is the list of manpages to include in the package.
	Manpages map[string]ArtifactConfig `yaml:"manpages,omitempty" json:"manpages,omitempty"`
	// DataDirs is a list of read-only architecture-independent data files, to be placed in /usr/share/
	DataDirs map[string]ArtifactConfig `yaml:"data_dirs,omitempty" json:"data_dirs,omitempty"`
	// Directories is a list of various directories that should be created by the package.
	Directories *CreateArtifactDirectories `yaml:"createDirectories,omitempty" json:"createDirectories,omitempty"`
	// ConfigFiles is a list of files that should be marked as config files in the package.
	ConfigFiles map[string]ArtifactConfig `yaml:"configFiles,omitempty" json:"configFiles,omitempty"`
	// Docs is a list of doc files included in the package
	Docs map[string]ArtifactConfig `yaml:"docs,omitempty" json:"docs,omitempty"`
	// Licenses is a list of doc files included in the package
	Licenses map[string]ArtifactConfig `yaml:"licenses,omitempty" json:"licenses,omitempty"`
	// Systemd is the list of systemd units and dropin files for the package
	Systemd *SystemdConfiguration `yaml:"systemd,omitempty" json:"systemd,omitempty"`

	// Libs is the list of library files to be installed.
	// On linux this would typically be installed to /usr/lib/<package name>
	Libs map[string]ArtifactConfig `yaml:"libs,omitempty" json:"libraries,omitempty"`

	// Links is the list of symlinks to be installed with the package
	// Links should only be used if the *package* should contain the link.
	// For making a container compatible with another image, use [PostInstall] in
	// the [ImageConfig].
	Links []ArtifactSymlinkConfig `yaml:"links,omitempty" json:"links,omitempty"`

	// Headers is a list of header files and/or folders to be installed.
	// On linux this would typically be installed to /usr/include/.
	Headers map[string]ArtifactConfig `yaml:"headers,omitempty" json:"headers,omitempty"`
}

Artifacts describes all the artifacts to include in the package. Artifacts are broken down into types, e.g. binaries, manpages, etc. This differentiation is used to determine where to place the artifact on install.

func (*Artifacts) IsEmpty

func (a *Artifacts) IsEmpty() bool

IsEmpty is used to determine if there are any artifacts to include in the package.

type BuildStep

type BuildStep struct {
	// Command is the command to run to build the artifact(s).
	// This will always be wrapped as /bin/sh -c "<command>", or whatever the equivalent is for the target distro.
	Command string `yaml:"command" json:"command" jsonschema:"required"`
	// Env is the list of environment variables to set for the command.
	Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
}

BuildStep is used to execute a command to build the artifact(s).

type CacheDirConfig

type CacheDirConfig struct {
	// Mode is the locking mode to set on the cache directory
	// values: shared, private, locked
	// default: shared
	Mode string `yaml:"mode,omitempty" json:"mode,omitempty" jsonschema:"enum=shared,enum=private,enum=locked"`
	// Key is the cache key to use to cache the directory
	// default: Value of `Path`
	Key string `yaml:"key,omitempty" json:"key,omitempty"`
	// IncludeDistroKey is used to include the distro key as part of the cache key
	// What this key is depends on the frontend implementation
	// Example for Debian Buster may be "buster"
	//
	// An example use for this is with a Go(lang) build cache when CGO is included.
	// Go is unable to invalidate cgo and re-using the same cache across different distros may cause issues.
	IncludeDistroKey bool `yaml:"include_distro_key,omitempty" json:"include_distro_key,omitempty"`
	// IncludeArchKey is used to include the architecture key as part of the cache key
	// What this key is depends on the frontend implementation
	// Frontends SHOULD use the buildkit platform arch
	//
	// As with [IncludeDistroKey], this is useful for Go(lang) builds with CGO.
	IncludeArchKey bool `yaml:"include_arch_key,omitempty" json:"include_arch_key,omitempty"`
}

CacheDirConfig configures a persistent cache to be used across builds.

type ChangelogEntry

type ChangelogEntry struct {
	// Date is the date of the changelog entry.
	Date time.Time `yaml:"date" json:"date" jsonschema:"oneof_required=date"`
	// Author is the author of the changelog entry. e.g. `John Smith <john.smith@example.com>`
	Author string `yaml:"author" json:"author"`
	// Changes is the list of changes in the changelog entry.
	Changes []string `yaml:"changes" json:"changes"`
}

ChangelogEntry is an entry in the changelog. This is used to generate the changelog for the package.

type CheckOutput

type CheckOutput struct {
	// Equals is the exact string to compare the output to.
	Equals string `yaml:"equals,omitempty" json:"equals,omitempty"`
	// Contains is the list of strings to check if they are contained in the output.
	Contains []string `yaml:"contains,omitempty" json:"contains,omitempty"`
	// Matches is the regular expression to match the output against.
	Matches string `yaml:"matches,omitempty" json:"matches,omitempty"`
	// StartsWith is the string to check if the output starts with.
	StartsWith string `yaml:"starts_with,omitempty" json:"starts_with,omitempty"`
	// EndsWith is the string to check if the output ends with.
	EndsWith string `yaml:"ends_with,omitempty" json:"ends_with,omitempty"`
	// Empty is used to check if the output is empty.
	Empty bool `yaml:"empty,omitempty" json:"empty,omitempty"`
}

CheckOutput is used to specify the expected output of a check, such as stdout/stderr or a file. All non-empty fields will be checked.

func (CheckOutput) Check

func (c CheckOutput) Check(dt string, p string) (retErr error)

Check is used to check the output stream.

func (CheckOutput) IsEmpty

func (c CheckOutput) IsEmpty() bool

IsEmpty is used to determine if there are any checks to perform.

type CheckOutputError

type CheckOutputError struct {
	Kind     string
	Expected string
	Actual   string
	Path     string
}

CheckOutputError is used to build an error message for a failed output check for a test case.

func (*CheckOutputError) Error

func (c *CheckOutputError) Error() string

type Command

type Command struct {
	// Dir is the working directory to run the command in.
	Dir string `yaml:"dir,omitempty" json:"dir,omitempty"`

	// Mounts is the list of sources to mount into the build steps.
	Mounts []SourceMount `yaml:"mounts,omitempty" json:"mounts,omitempty"`

	// List of CacheDirs which will be used across all Steps
	CacheDirs map[string]CacheDirConfig `yaml:"cache_dirs,omitempty" json:"cache_dirs,omitempty"`

	// Env is the list of environment variables to set for all commands in this step group.
	Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`

	// Steps is the list of commands to run to generate the source.
	// Steps are run sequentially and results of each step should be cached.
	Steps []*BuildStep `yaml:"steps" json:"steps" jsonschema:"required"`
}

Command is used to execute a command to generate a source from a docker image.

type CreateArtifactDirectories added in v0.4.0

type CreateArtifactDirectories struct {
	// Config is a list of directories the RPM should place under the system config directory (i.e. /etc)
	Config map[string]ArtifactDirConfig `yaml:"config,omitempty" json:"config,omitempty"`
	// State is a list of directories the RPM should place under the common directory for shared state and libs (i.e. /var/lib).
	State map[string]ArtifactDirConfig `yaml:"state,omitempty" json:"state,omitempty"`
}

CreateArtifactDirectories describes various directories that should be created on install. CreateArtifactDirectories represents different directory paths that are common to RPM systems.

func (*CreateArtifactDirectories) GetConfig added in v0.9.0

func (*CreateArtifactDirectories) GetState added in v0.9.0

type DockerImageConfig added in v0.2.0

type DockerImageConfig = dockerspec.DockerOCIImageConfig

type DockerImageSpec added in v0.2.0

type DockerImageSpec = dockerspec.DockerOCIImage

func BaseImageConfig added in v0.11.0

func BaseImageConfig(platform *ocispecs.Platform) *DockerImageSpec

BaseImageConfig provides a default image config that can be used for producing images.

This is taken from https://github.com/moby/buildkit/blob/0655923d7e2884a0d514313fd688178a6da57b43/frontend/dockerfile/dockerfile2llb/image.go#L26-L39

type FileCheckOutput

type FileCheckOutput struct {
	CheckOutput `yaml:",inline"`
	// Permissions is the expected permissions of the file.
	Permissions fs.FileMode `yaml:"permissions,omitempty" json:"permissions,omitempty"`
	// IsDir is used to set the expected file mode to a directory.
	IsDir bool `yaml:"is_dir,omitempty" json:"is_dir,omitempty"`
	// NotExist is used to check that the file does not exist.
	NotExist bool `yaml:"not_exist,omitempty" json:"not_exist,omitempty"`
}

FileCheckOutput is used to specify the expected output of a file.

func (FileCheckOutput) Check

func (c FileCheckOutput) Check(dt string, mode fs.FileMode, isDir bool, p string) error

Check is used to check the output file.

type FilterFunc added in v0.2.0

type FilterFunc = func(string, []string, []string, ...llb.ConstraintsOpt) llb.StateOption

type ForwarderFunc

type ForwarderFunc func(llb.State, *SourceBuild) (llb.State, error)

type Frontend

type Frontend struct {
	// Image specifies the frontend image to forward the build to.
	// This can be left unspecified *if* the original frontend has builtin support for the distro.
	//
	// If the original frontend does not have builtin support for the distro, this must be specified or the build will fail.
	// If this is specified then it MUST be used.
	Image string `yaml:"image,omitempty" json:"image,omitempty" jsonschema:"required,example=docker.io/my/frontend:latest"`
	// CmdLine is the command line to use to forward the build to the frontend.
	// By default the frontend image's entrypoint/cmd is used.
	CmdLine string `yaml:"cmdline,omitempty" json:"cmdline,omitempty"`
}

Frontend encapsulates the configuration for a frontend to forward a build target to.

type GeneratorGomod added in v0.3.0

type GeneratorGomod struct {
	// Paths is the list of paths to run the generator on. Used to generate multi-module in a single source.
	Paths []string `yaml:"paths,omitempty" json:"paths,omitempty"`
}

GeneratorGomod is used to generate a go module cache from go module sources

type GitAuth added in v0.9.0

type GitAuth struct {
	// Header is the name of the secret which contains the git auth header.
	// when using git auth header based authentication.
	// Note: This should not have the *actual* secret value, just the name of
	// the secret which was specified as a build secret.
	Header string `yaml:"header,omitempty" json:"header,omitempty"`
	// Token is the name of the secret which contains a git auth token when using
	// token based authentication.
	// Note: This should not have the *actual* secret value, just the name of
	// the secret which was specified as a build secret.
	Token string `yaml:"token,omitempty" json:"token,omitempty"`
	// SSH is the name of the secret which contains the ssh auth into when using
	// ssh based auth.
	// Note: This should not have the *actual* secret value, just the name of
	// the secret which was specified as a build secret.
	SSH string `yaml:"ssh,omitempty" json:"ssh,omitempty"`
}

func (*GitAuth) LLBOpt added in v0.9.0

func (a *GitAuth) LLBOpt() llb.GitOption

LLBOpt returns an llb.GitOption which sets the auth header and token secret values in LLB if they are set.

type ImageConfig

type ImageConfig struct {
	// Entrypoint sets the image's "entrypoint" field.
	// This is used to control the default command to run when the image is run.
	Entrypoint string `yaml:"entrypoint,omitempty" json:"entrypoint,omitempty"`
	// Cmd sets the image's "cmd" field.
	// When entrypoint is set, this is used as the default arguments to the entrypoint.
	// When entrypoint is not set, this is used as the default command to run.
	Cmd string `yaml:"cmd,omitempty" json:"cmd,omitempty"`
	// Env is the list of environment variables to set in the image.
	Env []string `yaml:"env,omitempty" json:"env,omitempty"`
	// Labels is the list of labels to set in the image metadata.
	Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
	// Volumes is the list of volumes for the image.
	// Volumes instruct the runtime to bypass the any copy-on-write filesystems and mount the volume directly to the container.
	Volumes map[string]struct{} `yaml:"volumes,omitempty" json:"volumes,omitempty"`
	// WorkingDir is the working directory to set in the image.
	// This sets the directory the container will start in.
	WorkingDir string `yaml:"working_dir,omitempty" json:"working_dir,omitempty"`
	// StopSignal is the signal to send to the container to stop it.
	// This is used to stop the container gracefully.
	StopSignal string `yaml:"stop_signal,omitempty" json:"stop_signal,omitempty" jsonschema:"example=SIGTERM"`
	// Base is the base image to use for the output image.
	// This only affects the output image, not the intermediate build image.
	Base string `yaml:"base,omitempty" json:"base,omitempty"`

	// Post is the post install configuration for the image.
	// This allows making additional modifications to the container rootfs after the package(s) are installed.
	//
	// Use this to perform actions that would otherwise require additional tooling inside the container that is not relevant to
	// the resulting container and makes a post-install script as part of the package unnecessary.
	Post *PostInstall `yaml:"post,omitempty" json:"post,omitempty"`

	// User is the that the image should run as.
	User string `yaml:"user,omitempty" json:"user,omitempty"`
}

ImageConfig is the configuration for the output image. When the target output is a container image, this is used to configure the image.

func MergeSpecImage added in v0.4.0

func MergeSpecImage(spec *Spec, targetKey string) *ImageConfig

type InvalidPatchError added in v0.7.0

type InvalidPatchError struct {
	Source    string
	PatchSpec *PatchSpec
	Err       error
}

func (*InvalidPatchError) Error added in v0.7.0

func (s *InvalidPatchError) Error() string

func (*InvalidPatchError) Unwrap added in v0.7.0

func (s *InvalidPatchError) Unwrap() error

type InvalidSourceError

type InvalidSourceError struct {
	Name string
	Err  error
}

InvalidSourceError is an error type returned when a source is invalid.

func (*InvalidSourceError) Error

func (s *InvalidSourceError) Error() string

func (*InvalidSourceError) Unwrap

func (s *InvalidSourceError) Unwrap() error

type LLBGetter

type LLBGetter func(sOpts SourceOpts, opts ...llb.ConstraintsOpt) (llb.State, error)

type PackageConfig added in v0.3.0

type PackageConfig struct {
	// Signer is the configuration to use for signing packages
	Signer *PackageSigner `yaml:"signer,omitempty" json:"signer,omitempty"`
}

PackageConfig encapsulates the configuration for artifact targets

type PackageConstraints added in v0.7.0

type PackageConstraints struct {
	// Version is a list of version constraints for the package.
	// The format of these strings is dependent on the package manager of the target system.
	// Examples:
	//   [">=1.0.0", "<2.0.0"]
	Version []string `yaml:"version,omitempty" json:"version,omitempty"`
	// Arch is a list of architecture constraints for the package.
	// Use this to specify that a package constraint only applies to certain architectures.
	Arch []string `yaml:"arch,omitempty" json:"arch,omitempty"`
}

PackageConstraints is used to specify complex constraints for a package dependency.

type PackageDependencies

type PackageDependencies struct {
	// Build is the list of packagese required to build the package.
	Build map[string]PackageConstraints `yaml:"build,omitempty" json:"build,omitempty"`
	// Runtime is the list of packages required to install/run the package.
	Runtime map[string]PackageConstraints `yaml:"runtime,omitempty" json:"runtime,omitempty"`
	// Recommends is the list of packages recommended to install with the generated package.
	// Note: Not all package managers support this (e.g. rpm)
	Recommends map[string]PackageConstraints `yaml:"recommends,omitempty" json:"recommends,omitempty"`

	// Test lists any extra packages required for running tests
	// These packages are only installed for tests which have steps that require
	// running a command in the built container.
	// See [TestSpec] for more information.
	Test []string `yaml:"test,omitempty" json:"test,omitempty"`

	// ExtraRepos is used to inject extra package repositories that may be used to
	// satisfy package dependencies in various stages.
	ExtraRepos []PackageRepositoryConfig `yaml:"extra_repos,omitempty" json:"extra_repos,omitempty"`
}

PackageDependencies is a list of dependencies for a package. This will be included in the package metadata so that the package manager can install the dependencies. It also includes build-time dedendencies, which we'll install before running any build steps.

func (*PackageDependencies) GetExtraRepos added in v0.10.0

func (p *PackageDependencies) GetExtraRepos(env string) []PackageRepositoryConfig

type PackageRepositoryConfig added in v0.10.0

type PackageRepositoryConfig struct {
	// Keys are the list of keys that need to be imported to use the configured
	// repositories
	Keys map[string]Source `yaml:"keys,omitempty" json:"keys,omitempty"`

	// Config list of repo configs to to add to the environment.  The format of
	// these configs are distro specific (e.g. apt/yum configs).
	Config map[string]Source `yaml:"config" json:"config"`

	// Data lists all the extra data that needs to be made available for the
	// provided repository config to work.
	// As an example, if the provided config is referencing a file backed repository
	// then data would include the file data, assuming its not already available
	// in the environment.
	Data []SourceMount `yaml:"data,omitempty" json:"data,omitempty"`
	// Envs specifies the list of environments to make the repositories available
	// during.
	// Acceptable values are:
	//  - "build"   - Repositories are added prior to installing build dependencies
	//  - "test"    - Repositories are added prior to installing test dependencies
	//  - "install" - Repositories are added prior to installing the output
	//                package in a container build target.
	Envs []string `yaml:"envs" json:"envs" jsonschema:"enum=build,enum=test,enum=install"`
}

PackageRepositoryConfig

func GetExtraRepos added in v0.11.0

func GetExtraRepos(repos []PackageRepositoryConfig, env string) []PackageRepositoryConfig

type PackageSigner added in v0.6.0

type PackageSigner struct {
	*Frontend `yaml:",inline" json:",inline"`
	// Args are passed along to the signer frontend as build args
	Args map[string]string `yaml:"args,omitempty" json:"args,omitempty"`
}

PackageSigner is the configuration for defining how to sign a package

type PatchSpec

type PatchSpec struct {
	// Source is the name of the source that contains the patch to apply.
	Source string `yaml:"source" json:"source" jsonschema:"required"`
	// Strip is the number of leading path components to strip from the patch.
	// The default is 1 which is typical of a git diff.
	Strip *int `yaml:"strip,omitempty" json:"strip,omitempty"`
	// Optional subpath to the patch file inside the source
	// This is only useful for directory-backed sources.
	Path string `yaml:"path,omitempty" json:"path,omitempty"`
}

PatchSpec is used to apply a patch to a source with a given set of options. This is used in [Spec.Patches]

type PostInstall

type PostInstall struct {
	// Symlinks is the list of symlinks to create in the container rootfs after the package(s) are installed.
	// The key is the path the symlink should point to.
	Symlinks map[string]SymlinkTarget `yaml:"symlinks,omitempty" json:"symlinks,omitempty"`
}

PostInstall is the post install configuration for the image.

type RepoPlatformConfig added in v0.10.0

type RepoPlatformConfig struct {
	ConfigRoot string
	GPGKeyRoot string
	ConfigExt  string
}

type RunOptFunc added in v0.3.0

type RunOptFunc func(*llb.ExecInfo)

func (RunOptFunc) SetRunOption added in v0.3.0

func (f RunOptFunc) SetRunOption(ei *llb.ExecInfo)

type Source

type Source struct {
	// This is an embedded union representing all of the possible source types.
	// Exactly one must be non-nil, with all other cases being errors.
	//
	// === Begin Source Variants ===
	DockerImage *SourceDockerImage `yaml:"image,omitempty" json:"image,omitempty"`
	Git         *SourceGit         `yaml:"git,omitempty" json:"git,omitempty"`
	HTTP        *SourceHTTP        `yaml:"http,omitempty" json:"http,omitempty"`
	Context     *SourceContext     `yaml:"context,omitempty" json:"context,omitempty"`
	Build       *SourceBuild       `yaml:"build,omitempty" json:"build,omitempty"`
	Inline      *SourceInline      `yaml:"inline,omitempty" json:"inline,omitempty"`

	// Path is the path to the source after fetching it based on the identifier.
	Path string `yaml:"path,omitempty" json:"path,omitempty"`

	// Includes is a list of paths underneath `Path` to include, everything else is execluded
	// If empty, everything is included (minus the excludes)
	Includes []string `yaml:"includes,omitempty" json:"includes,omitempty"`
	// Excludes is a list of paths underneath `Path` to exclude, everything else is included
	Excludes []string `yaml:"excludes,omitempty" json:"excludes,omitempty"`

	// Generate is the list generators to run on the source.
	//
	// Generators are used to generate additional sources from this source.
	// As an example the `gomod` generator can be used to generate a go module cache from a go source.
	// How a generator operates is dependent on the actual generator.
	// Generators may also cauuse modifications to the build environment.
	//
	// Currently only one generator is supported: "gomod"
	Generate []*SourceGenerator `yaml:"generate,omitempty" json:"generate,omitempty"`
}

Source defines a source to be used in the build. A source can be a local directory, a git repositoryt, http(s) URL, etc.

func (*Source) AsMount added in v0.2.0

func (s *Source) AsMount(name string, sOpt SourceOpts, opts ...llb.ConstraintsOpt) (llb.State, error)

func (*Source) AsState added in v0.2.0

func (s *Source) AsState(name string, sOpt SourceOpts, opts ...llb.ConstraintsOpt) (llb.State, error)

func (Source) Doc

func (s Source) Doc(name string) (io.Reader, error)

Doc returns the details of how the source was created. This should be included, where applicable, in build in build specs (such as RPM spec files) so that others can reproduce the build.

func (*Source) GetDisplayRef added in v0.2.0

func (src *Source) GetDisplayRef() (string, error)

type SourceBuild

type SourceBuild struct {
	// A source specification to use as the context for the Dockerfile build
	Source Source `yaml:"source,omitempty" json:"source,omitempty"`

	// DockerfilePath is the path to the build file in the build context
	// If not set the default is assumed by buildkit to be `Dockerfile` at the root of the context.
	DockerfilePath string `yaml:"dockerfile_path,omitempty" json:"dockerfile_path,omitempty"`

	// Target specifies the build target to use.
	// If unset, the default target is determined by the frontend implementation
	// (e.g. the dockerfile frontend uses the last build stage as the default).
	Target string `yaml:"target,omitempty" json:"target,omitempty"`
	// Args are the build args to pass to the build.
	Args map[string]string `yaml:"args,omitempty" json:"args,omitempty"`
}

SourceBuild is used to generate source from a DockerFile build.

func (*SourceBuild) AsState added in v0.2.0

func (src *SourceBuild) AsState(name string, sOpt SourceOpts, opts ...llb.ConstraintsOpt) (llb.State, error)

type SourceContext

type SourceContext struct {
	// Name is the name of the build context. By default, it is the magic name
	// `context`, recognized by Docker as the default context.
	Name string `yaml:"name,omitempty" json:"name,omitempty"`
}

SourceContext is used to generate a source from a build context. The path to the build context is provided to the `Path` field of the owning `Source`.

func (*SourceContext) AsState added in v0.2.0

func (src *SourceContext) AsState(path string, includes []string, excludes []string, sOpt SourceOpts, opts ...llb.ConstraintsOpt) (llb.State, error)

type SourceDockerImage

type SourceDockerImage struct {
	Ref string   `yaml:"ref" json:"ref"`
	Cmd *Command `yaml:"cmd,omitempty" json:"cmd,omitempty"`
}

func (*SourceDockerImage) AsState added in v0.2.0

func (src *SourceDockerImage) AsState(name string, path string, sOpt SourceOpts, opts ...llb.ConstraintsOpt) (llb.State, error)

type SourceGenerator added in v0.3.0

type SourceGenerator struct {
	// Subpath is the path inside a source to run the generator from.
	Subpath string `yaml:"subpath,omitempty" json:"subpath,omitempty"`

	// Gomod is the go module generator.
	Gomod *GeneratorGomod `yaml:"gomod" json:"gomod"`
}

SourceGenerator holds the configuration for a source generator. This can be used inside of a Source to generate additional sources from the given source.

func (*SourceGenerator) Validate added in v0.3.0

func (g *SourceGenerator) Validate() error

type SourceGit

type SourceGit struct {
	URL        string  `yaml:"url" json:"url"`
	Commit     string  `yaml:"commit" json:"commit"`
	KeepGitDir bool    `yaml:"keepGitDir,omitempty" json:"keepGitDir,omitempty"`
	Auth       GitAuth `yaml:"auth,omitempty" json:"auth,omitempty"`
}

func (*SourceGit) AsState added in v0.2.0

func (src *SourceGit) AsState(opts ...llb.ConstraintsOpt) (llb.State, error)

type SourceHTTP

type SourceHTTP struct {
	// URL is the URL to download the file from.
	URL string `yaml:"url" json:"url"`
	// Digest is the digest of the file to download.
	// This is used to verify the integrity of the file.
	// Form: <algorithm>:<digest>
	Digest digest.Digest `yaml:"digest,omitempty" json:"digest,omitempty"`
	// Permissions is the octal file permissions to set on the file.
	Permissions fs.FileMode `yaml:"permissions,omitempty" json:"permissions,omitempty"`
}

SourceHTTP is used to download a file from an HTTP(s) URL.

func (*SourceHTTP) AsState added in v0.2.0

func (src *SourceHTTP) AsState(name string, opts ...llb.ConstraintsOpt) (llb.State, error)

type SourceInline

type SourceInline struct {
	// File is the inline file to generate.
	// File is treated as a literal single file.
	// [SourceIsDir] will return false when this is set.
	// This is mutually exclusive with [Dir]
	File *SourceInlineFile `yaml:"file,omitempty" json:"file,omitempty"`
	// Dir creates a directory with the given files and directories.
	// [SourceIsDir] will return true when this is set.
	// This is mutually exclusive with [File]
	Dir *SourceInlineDir `yaml:"dir,omitempty" json:"dir,omitempty"`
}

SourceInline is used to generate a source from inline content.

func (*SourceInline) AsState added in v0.2.0

func (src *SourceInline) AsState(name string) (llb.State, error)

func (*SourceInline) Doc

func (s *SourceInline) Doc(w io.Writer, name string)

type SourceInlineDir

type SourceInlineDir struct {
	// Files is the list of files to include in the directory.
	// The map key is the name of the file.
	//
	// Files with path separators in the key will be rejected.
	Files map[string]*SourceInlineFile `yaml:"files,omitempty" json:"files,omitempty"`
	// Permissions is the octal permissions to set on the directory.
	Permissions fs.FileMode `yaml:"permissions,omitempty" json:"permissions,omitempty"`

	// UID is the user ID to set on the directory and all files and directories within it.
	// UID must be greater than or equal to 0
	UID int `yaml:"uid,omitempty" json:"uid,omitempty"`
	// GID is the group ID to set on the directory and all files and directories within it.
	// UID must be greater than or equal to 0
	GID int `yaml:"gid,omitempty" json:"gid,omitempty"`
}

SourceInlineDir is used by by SourceInline to represent a filesystem directory.

func (*SourceInlineDir) Doc

func (s *SourceInlineDir) Doc(w io.Writer, name string)

func (*SourceInlineDir) PopulateAt

func (d *SourceInlineDir) PopulateAt(p string) llb.StateOption

type SourceInlineFile

type SourceInlineFile struct {
	// Contents is the content.
	Contents string `yaml:"contents,omitempty" json:"contents,omitempty"`
	// Permissions is the octal file permissions to set on the file.
	Permissions fs.FileMode `yaml:"permissions,omitempty" json:"permissions,omitempty"`
	// UID is the user ID to set on the directory and all files and directories within it.
	// UID must be greater than or equal to 0
	UID int `yaml:"uid,omitempty" json:"uid,omitempty"`
	// GID is the group ID to set on the directory and all files and directories within it.
	// UID must be greater than or equal to 0
	GID int `yaml:"gid,omitempty" json:"gid,omitempty"`
}

SourceInlineFile is used to specify the content of an inline source.

func (*SourceInlineFile) Doc

func (s *SourceInlineFile) Doc(w io.Writer, name string)

func (*SourceInlineFile) PopulateAt

func (f *SourceInlineFile) PopulateAt(p string) llb.StateOption

type SourceMount

type SourceMount struct {
	// Dest is the destination directory to mount to
	Dest string `yaml:"dest" json:"dest" jsonschema:"required"`
	// Spec specifies the source to mount
	Spec Source `yaml:"spec" json:"spec" jsonschema:"required"`
}

SourceMount wraps a Source with a target mount point.

type SourceOpts

type SourceOpts struct {
	Resolver   llb.ImageMetaResolver
	Forward    ForwarderFunc
	GetContext func(string, ...llb.LocalOption) (*llb.State, error)
}

type Spec

type Spec struct {
	// Name is the name of the package.
	Name string `yaml:"name" json:"name" jsonschema:"required"`
	// Description is a short description of the package.
	Description string `yaml:"description" json:"description" jsonschema:"required"`
	// Website is the URL to store in the metadata of the package.
	Website string `yaml:"website" json:"website"`

	// Version sets the version of the package.
	Version string `yaml:"version" json:"version" jsonschema:"required"`
	// Revision sets the package revision.
	// This will generally get merged into the package version when generating the package.
	Revision string `yaml:"revision" json:"revision" jsonschema:"required,oneof_type=string;integer"`

	// Marks the package as architecture independent.
	// It is up to the package author to ensure that the package is actually architecture independent.
	// This is metadata only.
	NoArch bool `yaml:"noarch,omitempty" json:"noarch,omitempty"`

	// Conflicts is the list of packages that conflict with the generated package.
	// This will prevent the package from being installed if any of these packages are already installed or vice versa.
	Conflicts map[string]PackageConstraints `yaml:"conflicts,omitempty" json:"conflicts,omitempty"`
	// Replaces is the list of packages that are replaced by the generated package.
	Replaces map[string]PackageConstraints `yaml:"replaces,omitempty" json:"replaces,omitempty"`
	// Provides is the list of things that the generated package provides.
	// This can be used to satisfy dependencies of other packages.
	// As an example, the moby-runc package provides "runc", other packages could depend on "runc" and be satisfied by moby-runc.
	// This is an advanced use case and consideration should be taken to ensure that the package actually provides the thing it claims to provide.
	Provides map[string]PackageConstraints `yaml:"provides,omitempty" json:"provides,omitempty"`

	// Sources is the list of sources to use to build the artifact(s).
	// The map key is the name of the source and the value is the source configuration.
	// The source configuration is used to fetch the source and filter the files to include/exclude.
	// This can be mounted into the build using the "Mounts" field in the StepGroup.
	//
	// Sources can be embedded in the main spec as here or overridden in a build request.
	Sources map[string]Source `yaml:"sources,omitempty" json:"sources,omitempty"`

	// Patches is the list of patches to apply to the sources.
	// The map key is the name of the source to apply the patches to.
	// The value is the list of patches to apply to the source.
	// The patch must be present in the `Sources` map.
	// Each patch is applied in order and the result is used as the source for the build.
	Patches map[string][]PatchSpec `yaml:"patches,omitempty" json:"patches,omitempty"`

	// Build is the configuration for building the artifacts in the package.
	Build ArtifactBuild `yaml:"build,omitempty" json:"build,omitempty"`

	// Args is the list of arguments that can be used for shell-style expansion in (certain fields of) the spec.
	// Any arg supplied in the build request which does not appear in this list will cause an error.
	// Attempts to use an arg in the spec which is not specified here will assume to be a literal string.
	// The map value is the default value to use if the arg is not supplied in the build request.
	Args map[string]string `yaml:"args,omitempty" json:"args,omitempty"`

	// License is the license of the package.
	License string `yaml:"license" json:"license"`
	// Vendor is the vendor of the package.
	Vendor string `yaml:"vendor,omitempty" json:"vendor,omitempty"`
	// Packager is the name of the person,team,company that packaged the package.
	Packager string `yaml:"packager,omitempty" json:"packager,omitempty"`

	// Artifacts is the list of artifacts to include in the package.
	Artifacts Artifacts `yaml:"artifacts,omitempty" json:"artifacts,omitempty"`

	// The list of distro targets to build the package for.
	Targets map[string]Target `yaml:"targets,omitempty" json:"targets,omitempty"`

	// Dependencies are the different dependencies that need to be specified in the package.
	// Dependencies are overwritten if specified in the target map for the requested distro.
	Dependencies *PackageDependencies `yaml:"dependencies,omitempty" json:"dependencies,omitempty"`
	// PackageConfig is the configuration to use for artifact targets, such as
	// rpms, debs, or zip files containing Windows binaries
	PackageConfig *PackageConfig `yaml:"package_config,omitempty" json:"package_config,omitempty"`
	// Image is the image configuration when the target output is a container image.
	// This is overwritten if specified in the target map for the requested distro.
	Image *ImageConfig `yaml:"image,omitempty" json:"image,omitempty"`

	// Changelog is the list of changes to the package.
	Changelog []ChangelogEntry `yaml:"changelog,omitempty" json:"changelog,omitempty"`

	// Tests are the list of tests to run for the package that should work regardless of target OS
	// Each item in this list is run with a separate rootfs and cannot interact with other tests.
	// Each [TestSpec] is run with a separate rootfs, asynchronously from other [TestSpec].
	Tests []*TestSpec `yaml:"tests,omitempty" json:"tests,omitempty"`
}

Spec is the specification for a package build.

func LoadSpec

func LoadSpec(dt []byte) (*Spec, error)

LoadSpec loads a spec from the given data.

func (*Spec) FillDefaults

func (s *Spec) FillDefaults()

func (*Spec) GetBuildDeps added in v0.2.0

func (s *Spec) GetBuildDeps(targetKey string) map[string]PackageConstraints

func (*Spec) GetBuildRepos added in v0.10.0

func (s *Spec) GetBuildRepos(targetKey string) []PackageRepositoryConfig

func (*Spec) GetImagePost added in v0.6.1

func (s *Spec) GetImagePost(target string) *PostInstall

func (*Spec) GetInstallRepos added in v0.10.0

func (s *Spec) GetInstallRepos(targetKey string) []PackageRepositoryConfig

func (*Spec) GetPackageDeps added in v0.9.0

func (s *Spec) GetPackageDeps(target string) *PackageDependencies

GetPackageDeps returns the package dependencies for the given target. If the target does not have dependencies, the global dependencies are returned.

func (*Spec) GetRuntimeDeps added in v0.2.0

func (s *Spec) GetRuntimeDeps(targetKey string) []string

func (*Spec) GetSigner added in v0.3.0

func (s *Spec) GetSigner(targetKey string) (*PackageSigner, bool)

func (*Spec) GetTestDeps added in v0.4.0

func (s *Spec) GetTestDeps(targetKey string) []string

func (*Spec) GetTestRepos added in v0.10.0

func (s *Spec) GetTestRepos(targetKey string) []PackageRepositoryConfig

func (*Spec) GomodDeps added in v0.3.0

func (s *Spec) GomodDeps(sOpt SourceOpts, worker llb.State, opts ...llb.ConstraintsOpt) (*llb.State, error)

GomodDeps returns an llb.State containing all the go module dependencies for the spec for any sources that have a gomod generator specified. If there are no sources with a gomod generator, this will return a nil state.

func (*Spec) HasGomods added in v0.3.0

func (s *Spec) HasGomods() bool

HasGomods returns true if any of the sources in the spec are a go module.

func (*Spec) SubstituteArgs

func (s *Spec) SubstituteArgs(env map[string]string) error

func (Spec) Validate

func (s Spec) Validate() error

type SymlinkTarget

type SymlinkTarget struct {
	// Path is the path where the symlink should be placed
	Path string `yaml:"path" json:"path" jsonschema:"required"`
}

SymlinkTarget specifies the properties of a symlink

type SystemdConfiguration added in v0.5.0

type SystemdConfiguration struct {
	// Units is a list of systemd units to include in the package.
	Units map[string]SystemdUnitConfig `yaml:"units,omitempty" json:"units,omitempty"`
	// Dropins is a list of systemd drop in files that should be included in the package
	Dropins map[string]SystemdDropinConfig `yaml:"dropins,omitempty" json:"dropins,omitempty"`
}

func (*SystemdConfiguration) EnabledUnits added in v0.7.0

func (s *SystemdConfiguration) EnabledUnits() map[string]SystemdUnitConfig

func (*SystemdConfiguration) GetDropins added in v0.9.0

func (s *SystemdConfiguration) GetDropins() map[string]SystemdDropinConfig

func (*SystemdConfiguration) GetUnits added in v0.9.0

func (s *SystemdConfiguration) GetUnits() map[string]SystemdUnitConfig

func (*SystemdConfiguration) IsEmpty added in v0.6.0

func (s *SystemdConfiguration) IsEmpty() bool

type SystemdDropinConfig added in v0.5.0

type SystemdDropinConfig struct {
	// Name is file or dir name to use for the artifact in the package.
	// If empty, the file or dir name from the produced artifact will be used.
	Name string `yaml:"name,omitempty" json:"name,omitempty"`
	// Unit is the name of the systemd unit that the dropin files should be copied under.
	Unit string `yaml:"unit" json:"unit"` // the unit named foo.service maps to the directory foo.service.d
}

func (SystemdDropinConfig) Artifact added in v0.5.0

func (s SystemdDropinConfig) Artifact() *ArtifactConfig

type SystemdUnitConfig added in v0.4.0

type SystemdUnitConfig struct {
	// Name is the name systemd unit should be copied under.
	// Nested paths are not supported. It is the user's responsibility
	// to name the service with the appropriate extension, i.e. .service, .timer, etc.
	Name string `yaml:"name,omitempty" json:"name"`

	// Enable is used to enable the systemd unit on install
	// This determines what will be written to a systemd preset file
	Enable bool `yaml:"enable,omitempty" json:"enable"`
}

func (SystemdUnitConfig) Artifact added in v0.4.0

func (s SystemdUnitConfig) Artifact() *ArtifactConfig

func (SystemdUnitConfig) ResolveName added in v0.9.0

func (s SystemdUnitConfig) ResolveName(name string) string

func (SystemdUnitConfig) SplitName added in v0.9.0

func (s SystemdUnitConfig) SplitName(name string) (string, string)

Splitname resolves a unit name and then gives its unit base name. E.g. for `foo.socket` this would be `foo` and `socket`.

type Target

type Target struct {
	// Dependencies are the different dependencies that need to be specified in the package.
	Dependencies *PackageDependencies `yaml:"dependencies,omitempty" json:"dependencies,omitempty"`

	// Image is the image configuration when the target output is a container image.
	Image *ImageConfig `yaml:"image,omitempty" json:"image,omitempty"`

	// Frontend is the frontend configuration to use for the target.
	// This is used to forward the build to a different, dalec-compatible frontend.
	// This can be useful when testing out new distros or using a different version of the frontend for a given distro.
	Frontend *Frontend `yaml:"frontend,omitempty" json:"frontend,omitempty"`

	// Tests are the list of tests to run which are specific to the target.
	// Tests are appended to the list of tests in the main [Spec]
	Tests []*TestSpec `yaml:"tests,omitempty" json:"tests,omitempty"`

	// PackageConfig is the configuration to use for artifact targets, such as
	// rpms, debs, or zip files containing Windows binaries
	PackageConfig *PackageConfig `yaml:"package_config,omitempty" json:"package_config,omitempty"`
}

Target defines a distro-specific build target. This is used in Spec to specify the build target for a distro.

type TestSpec

type TestSpec struct {
	// Name is the name of the test
	// This will be used to output the test results
	Name string `yaml:"name" json:"name" jsonschema:"required"`

	// Dir is the working directory to run the command in.
	Dir string `yaml:"dir,omitempty" json:"dir,omitempty"`

	// Mounts is the list of sources to mount into the build steps.
	Mounts []SourceMount `yaml:"mounts,omitempty" json:"mounts,omitempty"`

	// List of CacheDirs which will be used across all Steps
	CacheDirs map[string]CacheDirConfig `yaml:"cache_dirs,omitempty" json:"cache_dirs,omitempty"`

	// Env is the list of environment variables to set for all commands in this step group.
	Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`

	// Steps is the list of commands to run to test the package.
	Steps []TestStep `yaml:"steps" json:"steps" jsonschema:"required"`

	// Files is the list of files to check after running the steps.
	Files map[string]FileCheckOutput `yaml:"files,omitempty" json:"files,omitempty"`
}

TestSpec is used to execute tests against a container with the package installed in it.

type TestStep

type TestStep struct {
	// Command is the command to run to build the artifact(s).
	// This will always be wrapped as /bin/sh -c "<command>", or whatever the equivalent is for the target distro.
	Command string `yaml:"command" json:"command" jsonschema:"required"`
	// Env is the list of environment variables to set for the command.
	Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
	// Stdout is the expected output on stdout
	Stdout CheckOutput `yaml:"stdout,omitempty" json:"stdout,omitempty"`
	// Stderr is the expected output on stderr
	Stderr CheckOutput `yaml:"stderr,omitempty" json:"stderr,omitempty"`
	// Stdin is the input to pass to stdin for the command
	Stdin string `yaml:"stdin,omitempty" json:"stdin,omitempty"`
}

TestStep is a wrapper for BuildStep to include checks on stdio streams

Jump to

Keyboard shortcuts

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