dalec

package module
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: MIT Imports: 39 Imported by: 0

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 way to build packages and containers, with a focus on supply chain security.

Features

  • 🐳 No additional tools are needed except for Docker!
  • 🚀 Easy to use declarative configuration
  • 📦 Build packages and/or containers for a number of different targets
    • DEB-based: Debian, and Ubuntu
    • RPM-based: Azure Linux, Rocky Linux, and Alma Linux
    • Windows containers (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.

Badges

OpenSSF Best Practices OpenSSF Scorecard

Documentation

Index

Constants

View Source
const (
	// PreBuiltPkgSuffix is what is expected to be appended to a targetKey when it's
	// meant to be a target distro specific package (e.g. mariner2-pkg, azlinux3-pkg,
	// windowscross-pkg, bookworm-pkg, etc.). When this is provided and used to buildkit
	// and container, it will take precedence over GenericPkg.
	PreBuiltPkgSuffix = "-pkg"
	// If not a target specific package, but we want to indicate the use of a
	// prebuilt package, we use GenericPkg to indicate that it's not target specific.
	GenericPkg = "pkg"
)
View Source
const (
	BazelDefaultSocketID = "bazel-default" // Default ID for bazel socket
)
View Source
const DefaultPatchStrip int = 1
View Source
const (

	// GoModCacheKey is the key used to identify the go module cache in the buildkit cache.
	// It is exported only for testing purposes.
	GomodCacheKey = "dalec-gomod-proxy-cache"
)
View Source
const (
	// KeyDalecTarget is the key used the build arg name which may be used to read
	// the target name.
	KeyDalecTarget = "DALEC_TARGET"
)

Variables

View Source
var (
	ErrNodeNotFound  = errors.New("node not found")
	ErrInvalidExtKey = errors.New("extension keys must start with \"x-\"")
)

Functions

func AllowAnyArg added in v0.11.3

func AllowAnyArg(s string) bool

AllowAnyArg can be used to set [SubstituteConfig.AllowArg] to allow any arg to be substituted regardless of whether it is declared in the spec.

func AsTar added in v0.17.0

func AsTar(worker llb.State, dest string, opts ...llb.ConstraintsOpt) llb.StateOption

AsTar returns an llb.StateOption which converts the input state into a tar with the given "dest" path as the name.

func BuildImageConfig added in v0.4.0

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

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 DisallowAllUndeclared added in v0.11.3

func DisallowAllUndeclared(s string) bool

DisallowAllUndeclared can be used to set [SubstituteConfig.AllowArg] to disallow args unless they are declared in the spec. This is used by default when substituting args.

func DuplicateMap

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

func ErrorState added in v0.17.0

func ErrorState(in llb.State, err error) llb.State

ErrorState returns a state that contains the error in an async state. If the error is nil, it returns the input state unchanged.

func ErrorStateOption added in v0.17.0

func ErrorStateOption(err error) llb.StateOption

ErrorStateOption returns a llb.StateOption that returns a state option that surfaces the error in an async state. If the error is nil, it returns a no-op state option.

func GetRepoKeys added in v0.10.0

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

func HasGolang added in v0.15.0

func HasGolang(spec *Spec, targetKey string) bool

func HasNpm added in v0.16.0

func HasNpm(spec *Spec, targetKey string) bool
func InstallPostSymlinks(post *PostInstall, worker llb.State, opts ...llb.ConstraintsOpt) llb.StateOption

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, opts ...llb.ConstraintsOpt) 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 NoopStateOption added in v0.17.0

func NoopStateOption(in llb.State) llb.State

NoopStateOption is a llb.StateOption that does not change the input state.

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 Platform added in v0.14.0

func Platform(platform *ocispecs.Platform) llb.ConstraintsOpt

Platform returns a llb.ConstraintsOpt that sets the platform to the provided platform If the platform is nil, the llb.ConstraintOpt is a no-op.

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[K cmp.Ordered, V any](m map[K]V) []K

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

func SortedMapIter added in v0.17.0

func SortedMapIter[K cmp.Ordered, V any](m map[K]V) iter.Seq2[K, V]

SortedMap returns an iter that yields the keys and values of the map in sorted order based on the keys.

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, st 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 WithAllowAnyArg added in v0.11.3

func WithAllowAnyArg(cfg *SubstituteConfig)

WithAllowAnyArg is a SubstituteOpt that sets [SubstituteConfig.AllowArg] to AllowAnyArg.

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

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

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 AddGroupConfig added in v0.12.0

type AddGroupConfig struct {
	// Name is the name of the group to add to the system.
	Name string `yaml:"name" json:"name"`
}

AddGroupConfig is the configuration for adding a group to the system.

type AddUserConfig added in v0.12.0

type AddUserConfig struct {
	// Name is the name of the user to add to the system.
	Name string `yaml:"name" json:"name"`
}

AddUserConfig is the configuration for adding a user to the system.

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"`

	// Caches is the list of caches to use for the build.
	// These apply to all steps.
	Caches []CacheConfig `yaml:"caches,omitempty" json:"caches,omitempty"`
}

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"`
	// Permissions is the file permissions to set on the artifact.
	// If not set, the default value will depend on the kind of artifact or the underlying artifact's already set permissions.
	Permissions fs.FileMode `yaml:"permissions,omitempty" json:"permissions,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"`
	// User is the user name that should own the symlink
	User string `yaml:"user,omitempty" json:"user,omitempty"`
	// Group is the group name that should own the symlink
	Group string `yaml:"group,omitempty" json:"group,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:"libs,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"`

	// Users is a list of users to add to the system when the package is installed.
	Users []AddUserConfig `yaml:"users,omitempty" json:"users,omitempty"`
	// Groups is a list of groups to add to the system when the package is installed.
	Groups []AddGroupConfig `yaml:"groups,omitempty" json:"groups,omitempty"`

	// DisableStrip is used to disable stripping of artifacts.
	DisableStrip bool `yaml:"disable_strip,omitempty" json:"disable_strip,omitempty"`

	// DisableAutoRequires is used to disable automatic dependency discovery for
	// the produced package.
	//
	// Some tooling, such as `rpmbuild`, will look at all artifacts and
	// automatically inject missing dependencies into the package metadata.
	// For instance, if you include a `.sh` script, rpmbuild with automatically
	// add `bash` as a dependency for the package.
	// It also does this for libraries being linked against.
	//
	// This is useful if you want to have more control over the dependencies
	// that are included in the package.
	// However, you must be careful to manually include all dependencies that are required.
	DisableAutoRequires bool `yaml:"disable_auto_requires,omitempty" json:"disable_auto_requires,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) HasDocs added in v0.16.2

func (a Artifacts) HasDocs() bool

func (*Artifacts) IsEmpty

func (a *Artifacts) IsEmpty() bool

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

type BaseImage added in v0.12.0

type BaseImage struct {
	// Rootfs represents an image rootfs.
	Rootfs Source `yaml:"rootfs" json:"rootfs"`
}

func (*BaseImage) ResolveImageConfig added in v0.12.0

func (bi *BaseImage) ResolveImageConfig(ctx context.Context, sOpt SourceOpts, opt sourceresolver.Opt) ([]byte, error)

func (*BaseImage) ToState added in v0.12.0

func (bi *BaseImage) ToState(sOpt SourceOpts, opts ...llb.ConstraintsOpt) llb.State

type BazelCache added in v0.15.0

type BazelCache struct {
	// Scope adds extra information to the cache key.
	// This is useful to differentiate between different build contexts if required.
	//
	// This is mainly intended for internal testing purposes.
	Scope string `json:"scope,omitempty" yaml:"scope,omitepty"`
}

BazelCache sets up a cache for bazel builds.

Currently this only supports setting up a *local* bazel cache.

BazelCache relies on the *system* bazelrc file to configure the default cache location. If the project being built includes its own bazelrc it may override the one configured by BazelCache.

An alternative to BazelCache would be a CacheDir and use `--disk_cache` to set the cache location when executing bazel commands.

func (*BazelCache) ToRunOption added in v0.15.0

func (c *BazelCache) ToRunOption(worker llb.State, distroKey string, opts ...BazelCacheOption) llb.RunOption

type BazelCacheInfo added in v0.15.0

type BazelCacheInfo struct {
	Platform *ocispecs.Platform
	// contains filtered or unexported fields
}

type BazelCacheOption added in v0.15.0

type BazelCacheOption interface {
	SetBazelCacheOption(*BazelCacheInfo)
}

type BazelCacheOptionFunc added in v0.15.0

type BazelCacheOptionFunc func(*BazelCacheInfo)

func (BazelCacheOptionFunc) SetBazelCacheOption added in v0.15.0

func (f BazelCacheOptionFunc) SetBazelCacheOption(info *BazelCacheInfo)

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"`

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

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

type CacheConfig added in v0.15.0

type CacheConfig struct {
	// Dir specifies a generic cache directory configuration.
	Dir *CacheDir `json:"dir,omitempty" yaml:"dir,omitempty" jsonschema:"oneof_required=dir"`
	// GoBuild specifies a cache for Go's incremental build artifacts.
	// This should speed up repeated builds of Go projects.
	GoBuild *GoBuildCache `json:"gobuild,omitempty" yaml:"gobuild,omitempty" jsonschema:"oneof_required=gobuild"`
	// Bazel specifies a cache for bazel builds.
	Bazel *BazelCache `json:"bazel,omitempty" yaml:"bazel,omitempty" jsonschema:"oneof_required=bazel-local"`
}

CacheConfig configures a cache to use for a build.

Other, cache types may be added in the future, such as: - rust compiler cache ...

func (*CacheConfig) ToRunOption added in v0.15.0

func (c *CacheConfig) ToRunOption(worker llb.State, distroKey string, opts ...CacheConfigOption) llb.RunOption

type CacheConfigOption added in v0.15.0

type CacheConfigOption interface {
	SetCacheConfigOption(*CacheInfo)
}

func WithBazelCacheConstraints added in v0.15.0

func WithBazelCacheConstraints(opts ...llb.ConstraintsOpt) CacheConfigOption

func WithCacheDirConstraints added in v0.15.0

func WithCacheDirConstraints(opts ...llb.ConstraintsOpt) CacheConfigOption

func WithGoCacheConstraints added in v0.15.0

func WithGoCacheConstraints(opts ...llb.ConstraintsOpt) CacheConfigOption

type CacheConfigOptionFunc added in v0.15.0

type CacheConfigOptionFunc func(*CacheInfo)

func (CacheConfigOptionFunc) SetCacheConfigOption added in v0.15.0

func (f CacheConfigOptionFunc) SetCacheConfigOption(info *CacheInfo)

type CacheDir added in v0.15.0

type CacheDir struct {
	// Key is the cache key to use.
	// If not set then the dest will be used.
	Key string `json:"key" yaml:"key"`
	// Dest is the directory to mount the cache to.
	Dest string `json:"dest" yaml:"dest" jsonschema:"required"`
	// Sharing is the sharing mode of the cache.
	// It can be one of the following:
	// - shared: multiple jobs can use the cache at the same time.
	// - locked: exclusive access to the cache is required.
	// - private: changes to the cache are not shared with other jobs and are discarded
	//   after the job is finished.
	Sharing string `json:"sharing" yaml:"sharing" jsonschema:"enum=shared,enum=locked,enum=private"`

	// NoAutoNamespace disables the automatic prefixing of the cache key with the
	// target specific information such as distro and CPU architecture, which may
	// be auto-injected to prevent common issues that would cause an invalid cache.
	NoAutoNamespace bool `json:"no_auto_namespace" yaml:"no_auto_namespace"`
}

CacheDir is a generic cache directory configuration.

func (*CacheDir) ToRunOption added in v0.15.0

func (c *CacheDir) ToRunOption(distroKey string, opts ...CacheDirOption) llb.RunOption

type CacheDirInfo added in v0.15.0

type CacheDirInfo struct {
	// Platform sets the platform used to generate part of the cache key when
	// CacheDir.NoAutoNamespace is set to false.
	Platform *ocispecs.Platform
}

type CacheDirOption added in v0.15.0

type CacheDirOption interface {
	SetCacheDirOption(*CacheDirInfo)
}

type CacheDirOptionFunc added in v0.15.0

type CacheDirOptionFunc func(*CacheDirInfo)

func (CacheDirOptionFunc) SetCacheDirOption added in v0.15.0

func (f CacheDirOptionFunc) SetCacheDirOption(info *CacheDirInfo)

type CacheInfo added in v0.15.0

type CacheInfo struct {
	DirInfo CacheDirInfo
	GoBuild GoBuildCacheInfo
	Bazel   BazelCacheInfo
}

type ChangelogEntry

type ChangelogEntry struct {
	// Date is the date of the changelog entry.
	// Dates are formatted as YYYY-MM-DD
	Date Date `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 list of regular expressions 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"`

	// 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 ConstraintsOptFunc added in v0.15.0

type ConstraintsOptFunc func(*llb.Constraints)

func (ConstraintsOptFunc) SetConstraintsOption added in v0.15.0

func (f ConstraintsOptFunc) SetConstraintsOption(c *llb.Constraints)

func (ConstraintsOptFunc) SetGitOption added in v0.15.0

func (f ConstraintsOptFunc) SetGitOption(gi *llb.GitInfo)

func (ConstraintsOptFunc) SetHTTPOption added in v0.15.0

func (f ConstraintsOptFunc) SetHTTPOption(hi *llb.HTTPInfo)

func (ConstraintsOptFunc) SetImageOption added in v0.15.0

func (f ConstraintsOptFunc) SetImageOption(ii *llb.ImageInfo)

func (ConstraintsOptFunc) SetLocalOption added in v0.15.0

func (f ConstraintsOptFunc) SetLocalOption(li *llb.LocalInfo)

func (ConstraintsOptFunc) SetOCILayoutOption added in v0.15.0

func (f ConstraintsOptFunc) SetOCILayoutOption(oi *llb.OCILayoutInfo)

func (ConstraintsOptFunc) SetRunOption added in v0.15.0

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

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 Date added in v0.15.0

type Date struct {
	time.Time
}

func (Date) Compare added in v0.15.0

func (d Date) Compare(other Date) int

func (Date) MarshalJSON added in v0.15.0

func (d Date) MarshalJSON() ([]byte, error)

func (Date) MarshalYAML added in v0.15.0

func (d Date) MarshalYAML() ([]byte, error)

func (Date) String added in v0.15.0

func (d Date) String() string

func (*Date) UnmarshalJSON added in v0.15.0

func (d *Date) UnmarshalJSON(dt []byte) error

func (*Date) UnmarshalYAML added in v0.15.0

func (d *Date) UnmarshalYAML(dt []byte) error

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 ExtDecodeConfig added in v0.12.2

type ExtDecodeConfig struct {
	AllowUnknownFields bool
}

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.ConstraintsOpt) (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 GeneratorCargohome added in v0.15.0

type GeneratorCargohome 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"`
}

GeneratorCargohome is used to generate a cargo home from cargo sources

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"`
	// Auth is the git authorization to use for gomods. The keys are the hosts, and the values are the auth to use for that host.
	Auth map[string]GomodGitAuth `yaml:"auth,omitempty" json:"auth,omitempty"`
}

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

type GeneratorNodeMod added in v0.16.0

type GeneratorNodeMod 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"`
}

GeneratorNodeMod is used to generate a node module cache for Yarn or npm.

type GeneratorPip added in v0.16.0

type GeneratorPip 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"`

	// RequirementsFile is the name of the requirements file (default: "requirements.txt")
	RequirementsFile string `yaml:"requirements_file,omitempty" json:"requirements_file,omitempty"`

	// IndexUrl specifies a custom PyPI index URL
	IndexUrl string `yaml:"index_url,omitempty" json:"index_url,omitempty"`

	// ExtraIndexUrls specifies additional PyPI index URLs
	ExtraIndexUrls []string `yaml:"extra_index_urls,omitempty" json:"extra_index_urls,omitempty"`
}

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 info 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) SetGitOption added in v0.17.0

func (a *GitAuth) SetGitOption(gi *llb.GitInfo)

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

type GoBuildCache added in v0.15.0

type GoBuildCache struct {
	// Scope adds extra information to the cache key.
	// This is useful to differentiate between different build contexts if required.
	//
	// This is mainly intended for internal testing purposes.
	Scope string `json:"scope,omitempty" yaml:"scope,omitempty"`

	// The gobuild cache may be automatically injected into a build if
	// go is detected.
	// Disabled explicitly turns this off.
	Disabled bool `json:"disabled,omitempty" yaml:"disabled,omitempty"`
}

GoBuildCache is a cache for Go build artifacts. It is used to speed up Go builds by caching the incremental builds.

func (*GoBuildCache) ToRunOption added in v0.15.0

func (c *GoBuildCache) ToRunOption(distroKey string, opts ...GoBuildCacheOption) llb.RunOption

type GoBuildCacheInfo added in v0.15.0

type GoBuildCacheInfo struct {
	Platform *ocispecs.Platform
}

type GoBuildCacheOption added in v0.15.0

type GoBuildCacheOption interface {
	SetGoBuildCacheOption(*GoBuildCacheInfo)
}

type GoBuildCacheOptionFunc added in v0.15.0

type GoBuildCacheOptionFunc func(*GoBuildCacheInfo)

func (GoBuildCacheOptionFunc) SetGoBuildCacheOption added in v0.15.0

func (f GoBuildCacheOptionFunc) SetGoBuildCacheOption(info *GoBuildCacheInfo)

type GomodGitAuth added in v0.16.0

type GomodGitAuth struct {
	// Header is the name of the secret that 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 a struct container the name of the ssh ID which contains the
	// address of the ssh auth socket, plus the username to use for the git
	// remote.
	// Note: This should not have the *actual* socket address, just the name of
	// the ssh ID which was specified as a build secret.
	SSH *GomodGitAuthSSH `yaml:"ssh,omitempty" json:"ssh,omitempty"`
}

type GomodGitAuthSSH added in v0.16.0

type GomodGitAuthSSH struct {
	// ID is the name of the ssh socket to mount, as provided via the `--ssh`
	// flag to `docker build`.
	ID string `yaml:"id,omitempty" json:"id,omitempty"`
	// Username is the username to use with this particular git remote. If none
	// is provided, `git` will be inserted.
	Username string `yaml:"username,omitempty" json:"username,omitempty"`
}

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"`

	// Deprecated: Use [Bases] instead.
	Base string `yaml:"base,omitempty" json:"base,omitempty"`

	// Bases is used to specify a list of base images to build images for.  The
	// intent of allowing multiple bases is for cases, such as Windows, where you
	// may want to publish multiple versions of a base image in one image.
	//
	// Windows is the example here because of the way Windows works, the image
	// that the base is based off of must match the OS version of the host machine.
	// Therefore it is common to have multiple Windows images in one with a
	// different value for the os version field of the platform.
	//
	// For the most part implementations are not expected to support multiple base
	// images and may error out if multiple are specified.
	//
	// This should not be set if [Base] is also set.
	Bases []BaseImage `yaml:"bases,omitempty" json:"bases,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"`
	// Sysext is the list of packages to include in the generated system
	// extension. No dependency resolution is performed when generating system
	// extensions, so all required dependencies must be explicitly listed here.
	Sysext map[string]PackageConstraints `yaml:"sysext,omitempty" json:"sysext,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 MergeDependencies added in v0.12.5

func MergeDependencies(base, target *PackageDependencies) *PackageDependencies

MergeDependencies merges two sets of package dependencies, a base and a target. If a dependency is set in both, the one from `target` is used, otherwise, the dependency from parent is used. MergeDependencies(nil, child) = child, MergeDependencies(parent, nil) = parent

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 specifies a list of dependency generators to apply to a given 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 cause modifications to the build environment.
	//
	// Currently supported generators are: "gomod", "cargohome", and "pip".
	// The "gomod" generator will generate a go module cache from the source.
	// The "cargohome" generator will generate a cargo home from the source.
	// The "pip" generator will generate a pip cache from the source.
	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) Doc

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

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) IsDir added in v0.17.0

func (s *Source) IsDir() bool

func (*Source) ToMount added in v0.17.0

func (s *Source) ToMount(sOpt SourceOpts, constraints ...llb.ConstraintsOpt) (llb.State, []llb.MountOption)

func (*Source) ToState added in v0.17.0

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

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) IsDir added in v0.17.0

func (src *SourceBuild) IsDir() bool

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) IsDir added in v0.17.0

func (src *SourceContext) IsDir() bool

type SourceDockerImage

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

func (*SourceDockerImage) IsDir added in v0.17.0

func (src *SourceDockerImage) IsDir() bool

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,omitempty" json:"gomod,omitempty" jsonschema:"oneof_required=gomod"`

	// Cargohome is the cargo home generator.
	Cargohome *GeneratorCargohome `yaml:"cargohome,omitempty" json:"cargohome,omitempty" jsonschema:"oneof_required=cargohome"`

	// Pip is the pip generator.
	Pip *GeneratorPip `yaml:"pip,omitempty" json:"pip,omitempty" jsonschema:"oneof_required=pip"`

	// NodeMod is the generic node module generator for npm.
	NodeMod *GeneratorNodeMod `yaml:"nodemod,omitempty" json:"nodemod,omitempty" jsonschema:"oneof_required=nodemod"`
}

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) IsDir added in v0.17.0

func (src *SourceGit) IsDir() bool

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) IsDir added in v0.17.0

func (src *SourceHTTP) IsDir() bool

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) Doc

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

func (*SourceInline) IsDir added in v0.17.0

func (src *SourceInline) IsDir() bool

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)

Doc writes the information about the directory to the writer.

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)

Doc writes the information about the file to the writer.

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.

func (SourceMount) ToRunOption added in v0.17.0

func (s SourceMount) ToRunOption(sOpt SourceOpts, c llb.ConstraintsOpt) llb.RunOption

type SourceOpts

type SourceOpts struct {
	Resolver         llb.ImageMetaResolver
	Forward          ForwarderFunc
	GetContext       func(string, ...llb.LocalOption) (*llb.State, error)
	TargetPlatform   *ocispecs.Platform
	GitCredHelperOpt func() (llb.RunOption, 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"`
	// contains filtered or unexported fields
}

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) CargohomeDeps added in v0.15.0

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

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

func (*Spec) Ext added in v0.12.2

func (s *Spec) Ext(key string, target interface{}, opts ...func(*ExtDecodeConfig)) error

Ext reads the extension field from the spec and unmarshals it into the target value.

func (*Spec) FillDefaults

func (s *Spec) FillDefaults()

func (*Spec) GetArtifacts added in v0.12.0

func (s *Spec) GetArtifacts(targetKey string) Artifacts

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) GetConflicts added in v0.15.0

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

func (*Spec) GetImageBases added in v0.12.0

func (s *Spec) GetImageBases(targetKey string) []BaseImage

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) GetProvides added in v0.15.0

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

func (*Spec) GetReplaces added in v0.15.0

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

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) GetSingleBase added in v0.12.0

func (s *Spec) GetSingleBase(targetKey string) (*BaseImage, error)

GetSingleBase looks up the base images to use for the targetKey and returns only the first entry. If there is more than 1 entry an error is returned. If there are no entries then both return values are nil.

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) HasCargohomes added in v0.15.0

func (s *Spec) HasCargohomes() bool

HasCargohomes returns true if any of the sources in the spec are a Rust Cargo project.

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) HasNodeMods added in v0.16.0

func (s *Spec) HasNodeMods() bool

HasNodeMods returns true if any of the sources in the spec are node modules.

func (*Spec) HasPips added in v0.16.0

func (s *Spec) HasPips() bool

func (Spec) MarshalYAML added in v0.12.2

func (s Spec) MarshalYAML() ([]byte, error)

func (*Spec) NodeModDeps added in v0.16.0

func (s *Spec) NodeModDeps(sOpt SourceOpts, worker llb.State, opts ...llb.ConstraintsOpt) (map[string]llb.State, error)

NodeModDeps returns a map[string]llb.State containing all the node module dependencies for the spec for any sources that have a node module generator specified. If there are no sources with a node module generator, this will return nil. The returned states have node_modules installed for each relevant source, using sources as input.

func (*Spec) PipDeps added in v0.16.0

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

PipDeps returns an llb.State containing all the pip dependencies for the spec for any sources that have a pip generator specified. If there are no sources with a pip generator, this will return nil. The returned state contains a merged cache of all downloaded pip packages.

func (*Spec) SubstituteArgs

func (s *Spec) SubstituteArgs(env map[string]string, opts ...SubstituteOpt) error

func (*Spec) UnmarshalYAML added in v0.12.2

func (s *Spec) UnmarshalYAML(dt []byte) error

func (Spec) Validate

func (s Spec) Validate() error

func (*Spec) WithExtension added in v0.12.3

func (s *Spec) WithExtension(key string, value interface{}) error

WithExtension adds an extension field to the spec. If the value is set to a []byte, it is used as-is and is expected to already be in YAML format.

type SubstituteConfig added in v0.11.3

type SubstituteConfig struct {
	AllowArg func(string) bool
}

type SubstituteOpt added in v0.11.3

type SubstituteOpt func(*SubstituteConfig)

type SymlinkTarget

type SymlinkTarget struct {
	// Path is the path where the symlink should be placed
	//
	// Deprecated: This is here for backward compatibility. Use `Paths` instead.
	Path string `yaml:"path" json:"path" jsonschema:"oneof_required=path"`
	// Path is a list of `newpath`s that will all point to the same `oldpath`.
	Paths []string `yaml:"paths" json:"paths" jsonschema:"oneof_required=paths"`
	// User is the user name to set on the symlink.
	User string `yaml:"user,omitempty" json:"user,omitempty"`
	// Group is the group name to set on the symlink.
	Group string `yaml:"group,omitempty" json:"group,omitempty"`
}

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"`

	// Artifacts describes all of the artifact configurations to include for this specific target.
	Artifacts *Artifacts `yaml:"artifacts,omitempty" json:"artifacts,omitempty"`

	// Provides is the list of packages that this target provides.
	Provides map[string]PackageConstraints `yaml:"provides,omitempty" json:"provides,omitempty"`

	// Replaces is the list of packages that this target replaces/obsoletes.
	Replaces map[string]PackageConstraints `yaml:"replaces,omitempty" json:"replaces,omitempty"`

	// Conflicts is the list of packages that this target conflicts with.
	Conflicts map[string]PackageConstraints `yaml:"conflicts,omitempty" json:"conflicts,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"`

	// 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,omitempty" json:"steps,omitempty"`

	// 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