The Wayback Machine - https://web.archive.org/web/20260409102717/https://pkg.go.dev/github.com/moby/buildkit/client/llb

llb

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 33 Imported by: 669

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const (
	NetModeSandbox = pb.NetMode_UNSET
	NetModeHost    = pb.NetMode_HOST
	NetModeNone    = pb.NetMode_NONE
)
View Source
const (
	SecurityModeInsecure = pb.SecurityMode_INSECURE
	SecurityModeSandbox  = pb.SecurityMode_SANDBOX
)
View Source
const (
	GitAuthHeaderKey = "GIT_AUTH_HEADER"
	GitAuthTokenKey  = "GIT_AUTH_TOKEN"
)

Variables ΒΆ

View Source
var (
	LinuxAmd64   = Platform(ocispecs.Platform{OS: "linux", Architecture: "amd64"})
	LinuxArmhf   = Platform(ocispecs.Platform{OS: "linux", Architecture: "arm", Variant: "v7"})
	LinuxArm     = LinuxArmhf
	LinuxArmel   = Platform(ocispecs.Platform{OS: "linux", Architecture: "arm", Variant: "v6"})
	LinuxArm64   = Platform(ocispecs.Platform{OS: "linux", Architecture: "arm64"})
	LinuxS390x   = Platform(ocispecs.Platform{OS: "linux", Architecture: "s390x"})
	LinuxPpc64   = Platform(ocispecs.Platform{OS: "linux", Architecture: "ppc64"})
	LinuxPpc64le = Platform(ocispecs.Platform{OS: "linux", Architecture: "ppc64le"})
	LinuxRiscv64 = Platform(ocispecs.Platform{OS: "linux", Architecture: "riscv64"})
	Darwin       = Platform(ocispecs.Platform{OS: "darwin", Architecture: "amd64"})
	Windows      = Platform(ocispecs.Platform{OS: "windows", Architecture: "amd64"})
)
View Source
var CDIDeviceOptional = cdiDeviceOptionFunc(func(ci *CDIDeviceInfo) {
	ci.Optional = true
})
View Source
var IgnoreCache = constraintsOptFunc(func(c *Constraints) {
	c.Metadata.IgnoreCache = true
})
View Source
var MarkImageInternal = imageOptionFunc(func(ii *ImageInfo) {
	ii.RecordType = "internal"
})
View Source
var SSHOptional = sshOptionFunc(func(si *SSHInfo) {
	si.Optional = true
})
View Source
var SecretOptional = secretOptionFunc(func(si *SecretInfo) {
	si.Optional = true
})

Functions ΒΆ

func ForceNoOutput ΒΆ added in v0.5.0

func ForceNoOutput(m *mount)

func MarshalConstraints ΒΆ

func MarshalConstraints(base, override *Constraints) (*pb.Op, *pb.OpMetadata)

func Readonly ΒΆ

func Readonly(m *mount)

func WriteTo ΒΆ

func WriteTo(def *Definition, w io.Writer) error

Types ΒΆ

type AuthOption ΒΆ added in v0.21.0

type AuthOption interface {
	GitOption
	HTTPOption
}

AuthOption can be used with either HTTP or Git sources.

func AuthHeaderSecret ΒΆ added in v0.8.0

func AuthHeaderSecret(secretName string) AuthOption

AuthHeaderSecret returns an AuthOption that defines the name of a secret to use for HTTP based authentication.

type CDIDeviceInfo ΒΆ added in v0.20.0

type CDIDeviceInfo struct {
	Name     string
	Optional bool
}

type CDIDeviceOption ΒΆ added in v0.20.0

type CDIDeviceOption interface {
	SetCDIDeviceOption(*CDIDeviceInfo)
}

func CDIDeviceName ΒΆ added in v0.20.0

func CDIDeviceName(name string) CDIDeviceOption

type CacheMountSharingMode ΒΆ

type CacheMountSharingMode int
const (
	CacheMountShared CacheMountSharingMode = iota
	CacheMountPrivate
	CacheMountLocked
)

type ChmodOpt ΒΆ added in v0.17.0

type ChmodOpt struct {
	Mode    os.FileMode
	ModeStr string
}

func (ChmodOpt) SetCopyOption ΒΆ added in v0.17.0

func (co ChmodOpt) SetCopyOption(mi *CopyInfo)

type ChownOpt ΒΆ added in v0.5.0

type ChownOpt struct {
	User  *UserOpt
	Group *UserOpt
}

func (ChownOpt) SetCopyOption ΒΆ added in v0.5.0

func (co ChownOpt) SetCopyOption(mi *CopyInfo)

func (ChownOpt) SetMkdirOption ΒΆ added in v0.5.0

func (co ChownOpt) SetMkdirOption(mi *MkdirInfo)

func (ChownOpt) SetMkfileOption ΒΆ added in v0.5.0

func (co ChownOpt) SetMkfileOption(mi *MkfileInfo)

func (ChownOpt) SetSymlinkOption ΒΆ added in v0.19.0

func (co ChownOpt) SetSymlinkOption(si *SymlinkInfo)

type ChownOption ΒΆ added in v0.5.0

type ChownOption interface {
	MkdirOption
	MkfileOption
	CopyOption
	SymlinkOption
}

func WithUIDGID ΒΆ added in v0.5.0

func WithUIDGID(uid, gid int) ChownOption

func WithUser ΒΆ added in v0.5.0

func WithUser(name string) ChownOption

type Constraints ΒΆ

type Constraints struct {
	Platform          *ocispecs.Platform
	WorkerConstraints []string
	Metadata          OpMetadata
	LocalUniqueID     string
	Caps              *apicaps.CapSet
	SourceLocations   []*SourceLocation
}

func NewConstraints ΒΆ added in v0.10.0

func NewConstraints(co ...ConstraintsOpt) *Constraints

type ConstraintsOpt ΒΆ

type ConstraintsOpt interface {
	SetConstraintsOption(*Constraints)
	RunOption
	LocalOption
	HTTPOption
	ImageBlobOption
	ImageOption
	GitOption
	OCILayoutOption
}

func LocalUniqueID ΒΆ

func LocalUniqueID(v string) ConstraintsOpt

func Platform ΒΆ

func Platform(p ocispecs.Platform) ConstraintsOpt

func ProgressGroup ΒΆ added in v0.10.0

func ProgressGroup(id, name string, weak bool) ConstraintsOpt

func Require ΒΆ

func Require(filters ...string) ConstraintsOpt

func WithCaps ΒΆ

func WithCaps(caps apicaps.CapSet) ConstraintsOpt

WithCaps exposes supported LLB caps to the marshaler

func WithCustomName ΒΆ

func WithCustomName(name string) ConstraintsOpt

func WithCustomNamef ΒΆ added in v0.4.0

func WithCustomNamef(name string, a ...any) ConstraintsOpt

func WithDescription ΒΆ

func WithDescription(m map[string]string) ConstraintsOpt

func WithExportCache ΒΆ

func WithExportCache() ConstraintsOpt

WithExportCache forces results for this vertex to be exported with the cache

func WithoutDefaultExportCache ΒΆ

func WithoutDefaultExportCache() ConstraintsOpt

WithoutDefaultExportCache resets the cache export for the vertex to use the default defined by the build configuration.

func WithoutExportCache ΒΆ

func WithoutExportCache() ConstraintsOpt

WithoutExportCache sets results for this vertex to be not exported with the cache

type CopyInfo ΒΆ added in v0.5.0

type CopyInfo struct {
	Mode                           *ChmodOpt
	FollowSymlinks                 bool
	CopyDirContentsOnly            bool
	IncludePatterns                []string
	ExcludePatterns                []string
	RequiredPaths                  []string
	AttemptUnpack                  bool
	CreateDestPath                 bool
	AllowWildcard                  bool
	AllowEmptyWildcard             bool
	ChownOpt                       *ChownOpt
	CreatedTime                    *time.Time
	AlwaysReplaceExistingDestPaths bool
}

func (*CopyInfo) SetCopyOption ΒΆ added in v0.5.0

func (mi *CopyInfo) SetCopyOption(mi2 *CopyInfo)

type CopyInput ΒΆ added in v0.5.0

type CopyInput interface {
	// contains filtered or unexported methods
}

CopyInput is either llb.State or *FileActionWithState It is used by Copy to to specify the source of the copy operation.

type CopyOption ΒΆ added in v0.5.0

type CopyOption interface {
	SetCopyOption(*CopyInfo)
}

func WithExcludePatterns ΒΆ added in v0.13.0

func WithExcludePatterns(patterns []string) CopyOption

type CreatedTime ΒΆ added in v0.5.0

type CreatedTime time.Time

func WithCreatedTime ΒΆ added in v0.5.0

func WithCreatedTime(t time.Time) CreatedTime

func (CreatedTime) SetCopyOption ΒΆ added in v0.5.0

func (c CreatedTime) SetCopyOption(mi *CopyInfo)

func (CreatedTime) SetMkdirOption ΒΆ added in v0.5.0

func (c CreatedTime) SetMkdirOption(mi *MkdirInfo)

func (CreatedTime) SetMkfileOption ΒΆ added in v0.5.0

func (c CreatedTime) SetMkfileOption(mi *MkfileInfo)

func (CreatedTime) SetSymlinkOption ΒΆ added in v0.19.0

func (c CreatedTime) SetSymlinkOption(si *SymlinkInfo)

type Definition ΒΆ

type Definition struct {
	Def         [][]byte
	Metadata    map[digest.Digest]OpMetadata
	Source      *pb.Source
	Constraints *Constraints
}

Definition is the LLB definition structure with per-vertex metadata entries Corresponds to the Definition structure defined in solver/pb.Definition.

func ReadFrom ΒΆ

func ReadFrom(r io.Reader) (*Definition, error)

func (*Definition) FromPB ΒΆ

func (def *Definition) FromPB(x *pb.Definition)

func (*Definition) Head ΒΆ added in v0.10.0

func (def *Definition) Head() (digest.Digest, error)

func (*Definition) ToPB ΒΆ

func (def *Definition) ToPB() *pb.Definition

type DefinitionOp ΒΆ added in v0.7.0

type DefinitionOp struct {
	// contains filtered or unexported fields
}

DefinitionOp implements llb.Vertex using a marshalled definition.

For example, after marshalling a LLB state and sending over the wire, the LLB state can be reconstructed from the definition.

func NewDefinitionOp ΒΆ added in v0.7.0

func NewDefinitionOp(def *pb.Definition) (*DefinitionOp, error)

NewDefinitionOp returns a new operation from a marshalled definition.

func (*DefinitionOp) Inputs ΒΆ added in v0.7.0

func (d *DefinitionOp) Inputs() []Output

func (*DefinitionOp) Marshal ΒΆ added in v0.7.0

func (*DefinitionOp) Output ΒΆ added in v0.7.0

func (d *DefinitionOp) Output() Output

func (*DefinitionOp) ToInput ΒΆ added in v0.7.0

func (d *DefinitionOp) ToInput(ctx context.Context, c *Constraints) (*pb.Input, error)

func (*DefinitionOp) Validate ΒΆ added in v0.7.0

func (d *DefinitionOp) Validate(context.Context, *Constraints) error

func (*DefinitionOp) Vertex ΒΆ added in v0.7.0

type DiffOp ΒΆ added in v0.10.0

type DiffOp struct {
	// contains filtered or unexported fields
}

func NewDiff ΒΆ added in v0.10.0

func NewDiff(lower, upper State, c Constraints) *DiffOp

func (*DiffOp) Inputs ΒΆ added in v0.10.0

func (m *DiffOp) Inputs() (out []Output)

func (*DiffOp) Marshal ΒΆ added in v0.10.0

func (m *DiffOp) Marshal(ctx context.Context, constraints *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error)

func (*DiffOp) Output ΒΆ added in v0.10.0

func (m *DiffOp) Output() Output

func (*DiffOp) Validate ΒΆ added in v0.10.0

func (m *DiffOp) Validate(ctx context.Context, constraints *Constraints) error

type DiffType ΒΆ added in v0.9.0

type DiffType string
const (
	// DiffNone will do no file comparisons, all files in the Local source will
	// be retransmitted.
	DiffNone DiffType = pb.AttrLocalDifferNone
	// DiffMetadata will compare file metadata (size, modified time, mode, owner,
	// group, device and link name) to determine if the files in the Local source need
	// to be retransmitted.  This is the default behavior.
	DiffMetadata DiffType = pb.AttrLocalDifferMetadata
)

type DifferInfo ΒΆ added in v0.9.0

type DifferInfo struct {
	Type     DiffType
	Required bool
}

type EnvList ΒΆ

type EnvList struct {
	// contains filtered or unexported fields
}

func (*EnvList) AddOrReplace ΒΆ

func (e *EnvList) AddOrReplace(k, v string) *EnvList

func (*EnvList) Delete ΒΆ

func (e *EnvList) Delete(k string) EnvList

func (*EnvList) Get ΒΆ

func (e *EnvList) Get(k string) (string, bool)

func (*EnvList) Keys ΒΆ added in v0.15.0

func (e *EnvList) Keys() []string

func (*EnvList) SetDefault ΒΆ

func (e *EnvList) SetDefault(k, v string) *EnvList

func (*EnvList) ToArray ΒΆ

func (e *EnvList) ToArray() []string

type ExecInfo ΒΆ

type ExecInfo struct {
	State          State
	Mounts         []MountInfo
	ReadonlyRootFS bool
	ProxyEnv       *ProxyEnv
	Secrets        []SecretInfo
	SSH            []SSHInfo
	CDIDevices     []CDIDeviceInfo
	// contains filtered or unexported fields
}

type ExecOp ΒΆ

type ExecOp struct {
	// contains filtered or unexported fields
}

func NewExecOp ΒΆ

func NewExecOp(base State, proxyEnv *ProxyEnv, readOnly bool, c Constraints) *ExecOp

func (*ExecOp) AddMount ΒΆ

func (e *ExecOp) AddMount(target string, source Output, opt ...MountOption) Output

func (*ExecOp) GetMount ΒΆ

func (e *ExecOp) GetMount(target string) Output

func (*ExecOp) Inputs ΒΆ

func (e *ExecOp) Inputs() (inputs []Output)

func (*ExecOp) Marshal ΒΆ

func (*ExecOp) Output ΒΆ

func (e *ExecOp) Output() Output

func (*ExecOp) Validate ΒΆ

func (e *ExecOp) Validate(ctx context.Context, c *Constraints) error

type ExecState ΒΆ

type ExecState struct {
	State
	// contains filtered or unexported fields
}

func (ExecState) AddMount ΒΆ

func (e ExecState) AddMount(target string, source State, opt ...MountOption) State

func (ExecState) GetMount ΒΆ

func (e ExecState) GetMount(target string) State

func (ExecState) Root ΒΆ

func (e ExecState) Root() State

type FileAction ΒΆ added in v0.5.0

type FileAction struct {
	// contains filtered or unexported fields
}

FileAction is used to specify a file operation on a State. It can be used to create a directory, create a file, or remove a file, etc. This is used by State.File Typically a FileAction is created by calling one of the helper functions such as Mkdir, Copy, Rm, Mkfile

func Copy ΒΆ added in v0.5.0

func Copy(input CopyInput, src, dest string, opts ...CopyOption) *FileAction

Copy produces a FileAction which copies a file or directory from the source to the destination. The "input" parameter is the contents to copy from. "src" is the path to copy from within the "input". "dest" is the path to copy to within the destination (the state being operated on). See CopyInput for the valid types of input.

Example:

st := llb.Local(".")
llb.Scratch().File(llb.Copy(st, "/foo", "/bar"))

The example copies the local (client) directory "./foo" to a new empty directory at /bar.

Note: Copying directories can have different behavior based on if the destination exists or not. When the destination already exists, the contents of the source directory is copied underneath the destination, including the directory itself. You may need to supply a copy option to copy the dir contents only. You may also need to pass in a CopyOption which creates parent directories if they do not exist.

See CopyOption for more details on what options are available.

func Mkdir ΒΆ added in v0.5.0

func Mkdir(p string, m os.FileMode, opt ...MkdirOption) *FileAction

Mkdir creates a FileAction which creates a directory at the given path. Example:

llb.Scratch().File(llb.Mkdir("/foo", 0755))

func Mkfile ΒΆ added in v0.5.0

func Mkfile(p string, m os.FileMode, dt []byte, opts ...MkfileOption) *FileAction

Mkfile creates a FileAction which creates a file at the given path with the provided contents. Example:

llb.Scratch().File(llb.Mkfile("/foo", 0644, []byte("hello world!")))

func Rm ΒΆ added in v0.5.0

func Rm(p string, opts ...RmOption) *FileAction

Rm creates a FileAction which removes a file or directory at the given path. Example:

llb.Scratch().File(Mkfile("/foo", 0644, []byte("not around for long..."))).File(llb.Rm("/foo"))
func Symlink(oldpath, newpath string, opts ...SymlinkOption) *FileAction

Symlink creates a symlink at `newpath` that points to `oldpath`

func (*FileAction) Copy ΒΆ added in v0.5.0

func (fa *FileAction) Copy(input CopyInput, src, dest string, opt ...CopyOption) *FileAction

func (*FileAction) Mkdir ΒΆ added in v0.5.0

func (fa *FileAction) Mkdir(p string, m os.FileMode, opt ...MkdirOption) *FileAction

func (*FileAction) Mkfile ΒΆ added in v0.5.0

func (fa *FileAction) Mkfile(p string, m os.FileMode, dt []byte, opt ...MkfileOption) *FileAction

func (*FileAction) Rm ΒΆ added in v0.5.0

func (fa *FileAction) Rm(p string, opt ...RmOption) *FileAction
func (fa *FileAction) Symlink(oldpath, newpath string, opt ...SymlinkOption) *FileAction

Symlink creates a symlink at `newpath` that points to `oldpath`

func (*FileAction) WithState ΒΆ added in v0.5.0

func (fa *FileAction) WithState(s State) CopyInput

type FileInfoOption ΒΆ added in v0.28.0

type FileInfoOption interface {
	HTTPOption
	ImageBlobOption
}

func Chmod ΒΆ

func Chmod(perm os.FileMode) FileInfoOption

func Chown ΒΆ

func Chown(uid, gid int) FileInfoOption

func Filename ΒΆ

func Filename(name string) FileInfoOption

type FileOp ΒΆ added in v0.5.0

type FileOp struct {
	MarshalCache
	// contains filtered or unexported fields
}

func NewFileOp ΒΆ added in v0.5.0

func NewFileOp(s State, action *FileAction, c Constraints) *FileOp

func (*FileOp) Inputs ΒΆ added in v0.5.0

func (f *FileOp) Inputs() []Output

func (*FileOp) Marshal ΒΆ added in v0.5.0

func (*FileOp) Output ΒΆ added in v0.5.0

func (f *FileOp) Output() Output

func (*FileOp) Validate ΒΆ added in v0.5.0

func (f *FileOp) Validate(context.Context, *Constraints) error

type GitInfo ΒΆ

type GitInfo struct {
	KeepGitDir       bool
	AuthTokenSecret  string
	AuthHeaderSecret string

	KnownSSHHosts  string
	MountSSHSock   string
	Checksum       string
	Ref            string
	SubDir         string
	SkipSubmodules bool
	MTime          string
	// contains filtered or unexported fields
}

type GitOption ΒΆ

type GitOption interface {
	SetGitOption(*GitInfo)
}

func AuthTokenSecret ΒΆ added in v0.8.0

func AuthTokenSecret(v string) GitOption

func GitChecksum ΒΆ added in v0.22.0

func GitChecksum(v string) GitOption

func GitMTime ΒΆ added in v0.29.0

func GitMTime(v string) GitOption

GitMTime sets the file modification time policy for git sources. Valid values are "checkout" (default) and "commit".

func GitMTimeCommit ΒΆ added in v0.29.0

func GitMTimeCommit() GitOption

GitMTimeCommit sets file modification times to the commit timestamp of the resolved commit, rather than the checkout time.

func GitRef ΒΆ added in v0.24.0

func GitRef(v string) GitOption

func GitSkipSubmodules ΒΆ added in v0.24.0

func GitSkipSubmodules() GitOption

func GitSubDir ΒΆ added in v0.24.0

func GitSubDir(v string) GitOption

func KeepGitDir ΒΆ

func KeepGitDir() GitOption

func KnownSSHHosts ΒΆ added in v0.8.0

func KnownSSHHosts(key string) GitOption

func MountSSHSock ΒΆ added in v0.8.0

func MountSSHSock(sshID string) GitOption

type HTTPHeader ΒΆ added in v0.21.0

type HTTPHeader struct {
	Accept    string
	UserAgent string
}

type HTTPInfo ΒΆ

type HTTPInfo struct {
	Checksum         digest.Digest
	AuthHeaderSecret string
	Header           *HTTPHeader
	Signature        *HTTPSignatureInfo
	// contains filtered or unexported fields
}

type HTTPOption ΒΆ

type HTTPOption interface {
	SetHTTPOption(*HTTPInfo)
}

func Checksum ΒΆ

func Checksum(dgst digest.Digest) HTTPOption
func Header(header HTTPHeader) HTTPOption

Header returns an HTTPOption that ensures additional request headers will be sent when retrieving the HTTP source.

func VerifyPGPSignature ΒΆ added in v0.28.0

func VerifyPGPSignature(info HTTPSignatureInfo) HTTPOption

VerifyPGPSignature returns an HTTPOption for detached OpenPGP signature verification of the downloaded HTTP payload.

type HTTPSignatureInfo ΒΆ added in v0.28.0

type HTTPSignatureInfo struct {
	PubKey []byte

	// Signature is an inline detached armored OpenPGP signature.
	Signature []byte
}

HTTPSignatureInfo configures detached-signature verification for HTTP sources. The current implementation uses inline armored signatures.

type HostIP ΒΆ

type HostIP struct {
	Host string
	IP   net.IP
}

type ImageBlobInfo ΒΆ added in v0.28.0

type ImageBlobInfo struct {
	// contains filtered or unexported fields
}

type ImageBlobOption ΒΆ added in v0.28.0

type ImageBlobOption interface {
	SetImageBlobOption(*ImageBlobInfo)
}

func ImageBlobOCIStore ΒΆ added in v0.28.0

func ImageBlobOCIStore(sessionID string, storeID string) ImageBlobOption

ImageBlobOCIStore returns an ImageBlobOption that configures the OCI layout session/store used by OCILayoutBlob.

type ImageInfo ΒΆ

type ImageInfo struct {
	RecordType string
	// contains filtered or unexported fields
}

type ImageMetaResolver ΒΆ

type ImageMetaResolver = sourceresolver.ImageMetaResolver

ImageMetaResolver can resolve image config metadata from a reference

type ImageOption ΒΆ

type ImageOption interface {
	SetImageOption(*ImageInfo)
}

func ResolveDigest ΒΆ added in v0.8.0

func ResolveDigest(v bool) ImageOption

ResolveDigest uses the meta resolver to update the ref of image with full digest before marshaling. This makes image ref immutable and is recommended if you want to make sure meta resolver data matches the image used during the build.

func WithImageChecksum ΒΆ added in v0.25.0

func WithImageChecksum(dgst digest.Digest) ImageOption

func WithLayerLimit ΒΆ added in v0.11.0

func WithLayerLimit(l int) ImageOption

func WithMetaResolver ΒΆ

func WithMetaResolver(mr ImageMetaResolver) ImageOption

WithMetaResolver adds a metadata resolver to an image

type LocalInfo ΒΆ

type LocalInfo struct {
	SessionID              string
	IncludePatterns        string
	ExcludePatterns        string
	FollowPaths            string
	SharedKeyHint          string
	Differ                 DifferInfo
	MetadataOnlyCollector  bool
	MetadataOnlyExceptions string
	// contains filtered or unexported fields
}

type LocalOption ΒΆ

type LocalOption interface {
	SetLocalOption(*LocalInfo)
}

func Differ ΒΆ added in v0.9.0

func Differ(t DiffType, required bool) LocalOption

func ExcludePatterns ΒΆ

func ExcludePatterns(p []string) LocalOption

func FollowPaths ΒΆ

func FollowPaths(p []string) LocalOption

func IncludePatterns ΒΆ

func IncludePatterns(p []string) LocalOption

func MetadataOnlyTransfer ΒΆ added in v0.21.0

func MetadataOnlyTransfer(exceptions []string) LocalOption

func SessionID ΒΆ

func SessionID(id string) LocalOption

func SharedKeyHint ΒΆ

func SharedKeyHint(h string) LocalOption

type MarshalCache ΒΆ

type MarshalCache struct {
	// contains filtered or unexported fields
}

func (*MarshalCache) Acquire ΒΆ added in v0.18.2

func (mc *MarshalCache) Acquire() *MarshalCacheInstance

type MarshalCacheInstance ΒΆ added in v0.18.2

type MarshalCacheInstance struct {
	*MarshalCache
}

func (*MarshalCacheInstance) Load ΒΆ added in v0.18.2

func (*MarshalCacheInstance) Release ΒΆ added in v0.18.2

func (mc *MarshalCacheInstance) Release()

func (*MarshalCacheInstance) Store ΒΆ added in v0.18.2

type MergeOp ΒΆ added in v0.10.0

type MergeOp struct {
	// contains filtered or unexported fields
}

func NewMerge ΒΆ added in v0.10.0

func NewMerge(inputs []State, c Constraints) *MergeOp

func (*MergeOp) Inputs ΒΆ added in v0.10.0

func (m *MergeOp) Inputs() []Output

func (*MergeOp) Marshal ΒΆ added in v0.10.0

func (m *MergeOp) Marshal(ctx context.Context, constraints *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error)

func (*MergeOp) Output ΒΆ added in v0.10.0

func (m *MergeOp) Output() Output

func (*MergeOp) Validate ΒΆ added in v0.10.0

func (m *MergeOp) Validate(ctx context.Context, constraints *Constraints) error

type MkdirInfo ΒΆ added in v0.5.0

type MkdirInfo struct {
	MakeParents bool
	ChownOpt    *ChownOpt
	CreatedTime *time.Time
}

func (*MkdirInfo) SetMkdirOption ΒΆ added in v0.5.0

func (mi *MkdirInfo) SetMkdirOption(mi2 *MkdirInfo)

type MkdirOption ΒΆ added in v0.5.0

type MkdirOption interface {
	SetMkdirOption(*MkdirInfo)
}

func WithParents ΒΆ added in v0.5.0

func WithParents(b bool) MkdirOption

WithParents is an option for Mkdir which creates parent directories if they do not exist.

type MkfileInfo ΒΆ added in v0.5.0

type MkfileInfo struct {
	ChownOpt    *ChownOpt
	CreatedTime *time.Time
}

func (*MkfileInfo) SetMkfileOption ΒΆ added in v0.5.0

func (mi *MkfileInfo) SetMkfileOption(mi2 *MkfileInfo)

type MkfileOption ΒΆ added in v0.5.0

type MkfileOption interface {
	SetMkfileOption(*MkfileInfo)
}

type MountContentCache ΒΆ added in v0.13.0

type MountContentCache int
const (
	MountContentCacheDefault MountContentCache = iota
	MountContentCacheOn
	MountContentCacheOff
)

type MountInfo ΒΆ

type MountInfo struct {
	Target string
	Source Output
	Opts   []MountOption
}

type MountOption ΒΆ

type MountOption func(*mount)

func AsPersistentCacheDir ΒΆ

func AsPersistentCacheDir(id string, sharing CacheMountSharingMode) MountOption

func ContentCache ΒΆ added in v0.13.0

func ContentCache(cache MountContentCache) MountOption

func SourcePath ΒΆ

func SourcePath(src string) MountOption

func Tmpfs ΒΆ

func Tmpfs(opts ...TmpfsOption) MountOption

type OCILayoutInfo ΒΆ added in v0.11.0

type OCILayoutInfo struct {
	// contains filtered or unexported fields
}

type OCILayoutOption ΒΆ added in v0.11.0

type OCILayoutOption interface {
	SetOCILayoutOption(*OCILayoutInfo)
}

func OCIChecksum ΒΆ added in v0.25.0

func OCIChecksum(dgst digest.Digest) OCILayoutOption

func OCILayerLimit ΒΆ added in v0.11.0

func OCILayerLimit(limit int) OCILayoutOption

func OCIStore ΒΆ added in v0.11.0

func OCIStore(sessionID string, storeID string) OCILayoutOption

type OpMetadata ΒΆ added in v0.17.0

type OpMetadata struct {
	IgnoreCache   bool                   `json:"ignore_cache,omitempty"`
	Description   map[string]string      `json:"description,omitempty"`
	ExportCache   *pb.ExportCache        `json:"export_cache,omitempty"`
	Caps          map[apicaps.CapID]bool `json:"caps,omitempty"`
	ProgressGroup *pb.ProgressGroup      `json:"progress_group,omitempty"`
}

OpMetadata has a more friendly interface for pb.OpMetadata.

func NewOpMetadata ΒΆ added in v0.17.0

func NewOpMetadata(mpb *pb.OpMetadata) OpMetadata

func (*OpMetadata) FromPB ΒΆ added in v0.17.0

func (m *OpMetadata) FromPB(mpb *pb.OpMetadata)

func (OpMetadata) ToPB ΒΆ added in v0.17.0

func (m OpMetadata) ToPB() *pb.OpMetadata

type Output ΒΆ

type Output interface {
	ToInput(context.Context, *Constraints) (*pb.Input, error)
	Vertex(context.Context, *Constraints) Vertex
}

type ProxyEnv ΒΆ

type ProxyEnv struct {
	HTTPProxy  string
	HTTPSProxy string
	FTPProxy   string
	NoProxy    string
	AllProxy   string
}

type ResolveMode ΒΆ

type ResolveMode int
const (
	ResolveModeDefault ResolveMode = iota
	ResolveModeForcePull
	ResolveModePreferLocal
)

func (ResolveMode) SetImageOption ΒΆ

func (r ResolveMode) SetImageOption(ii *ImageInfo)

func (ResolveMode) String ΒΆ

func (r ResolveMode) String() string

type RmInfo ΒΆ added in v0.5.0

type RmInfo struct {
	AllowNotFound bool
	AllowWildcard bool
}

func (*RmInfo) SetRmOption ΒΆ added in v0.5.0

func (mi *RmInfo) SetRmOption(mi2 *RmInfo)

type RmOption ΒΆ added in v0.5.0

type RmOption interface {
	SetRmOption(*RmInfo)
}

func WithAllowNotFound ΒΆ added in v0.5.0

func WithAllowNotFound(b bool) RmOption

func WithAllowWildcard ΒΆ added in v0.5.0

func WithAllowWildcard(b bool) RmOption

type RunOption ΒΆ

type RunOption interface {
	SetRunOption(es *ExecInfo)
}

func AddCDIDevice ΒΆ added in v0.20.0

func AddCDIDevice(opts ...CDIDeviceOption) RunOption

func AddExtraHost ΒΆ

func AddExtraHost(host string, ip net.IP) RunOption

func AddMount ΒΆ

func AddMount(dest string, mountState State, opts ...MountOption) RunOption

func AddSSHSocket ΒΆ

func AddSSHSocket(opts ...SSHOption) RunOption

func AddSecret ΒΆ

func AddSecret(dest string, opts ...SecretOption) RunOption

AddSecret is a RunOption that adds a secret to the exec.

func AddSecretWithDest ΒΆ added in v0.16.0

func AddSecretWithDest(src string, dest *string, opts ...SecretOption) RunOption

AddSecretWithDest is a RunOption that adds a secret to the exec with an optional destination.

func AddUlimit ΒΆ added in v0.10.0

func AddUlimit(name UlimitName, soft int64, hard int64) RunOption

func Args ΒΆ

func Args(a []string) RunOption

func ReadonlyRootFS ΒΆ

func ReadonlyRootFS() RunOption

ReadonlyRootFS sets the execs's root filesystem to be read-only.

func Shlex ΒΆ

func Shlex(str string) RunOption

func Shlexf ΒΆ

func Shlexf(str string, v ...any) RunOption

func ValidExitCodes ΒΆ added in v0.17.0

func ValidExitCodes(codes ...int) RunOption

func With ΒΆ

func With(so ...StateOption) RunOption

func WithCgroupParent ΒΆ added in v0.10.0

func WithCgroupParent(cp string) RunOption

func WithProxy ΒΆ

func WithProxy(ps ProxyEnv) RunOption

WithProxy is a RunOption that sets the proxy environment variables in the resulting exec. For example `HTTP_PROXY` is a standard environment variable for unix systems that programs may read.

type SSHInfo ΒΆ

type SSHInfo struct {
	ID       string
	Target   string
	Mode     int
	UID      int
	GID      int
	Optional bool
}

type SSHOption ΒΆ

type SSHOption interface {
	SetSSHOption(*SSHInfo)
}

func SSHID ΒΆ

func SSHID(id string) SSHOption

func SSHSocketOpt ΒΆ

func SSHSocketOpt(target string, uid, gid, mode int) SSHOption

func SSHSocketTarget ΒΆ

func SSHSocketTarget(target string) SSHOption

type SecretInfo ΒΆ

type SecretInfo struct {
	ID string
	// Target optionally specifies the target for the secret mount
	Target *string
	// Env optionally names the environment variable for the secret
	Env      *string
	Mode     int
	UID      int
	GID      int
	Optional bool
}

type SecretOption ΒΆ

type SecretOption interface {
	SetSecretOption(*SecretInfo)
}

func SecretAsEnv ΒΆ added in v0.10.0

func SecretAsEnv(v bool) SecretOption

SecretAsEnv defines if the secret should be added as an environment variable

func SecretAsEnvName ΒΆ added in v0.16.0

func SecretAsEnvName(v string) SecretOption

SecretAsEnvName defines if the secret should be added as an environment variable with the specified name

func SecretFileOpt ΒΆ

func SecretFileOpt(uid, gid, mode int) SecretOption

SecretFileOpt sets the secret's target file uid, gid and permissions.

func SecretID ΒΆ

func SecretID(id string) SecretOption

type SourceLocation ΒΆ added in v0.8.0

type SourceLocation struct {
	SourceMap *SourceMap
	Ranges    []*pb.Range
}

type SourceMap ΒΆ added in v0.8.0

type SourceMap struct {
	State      *State
	Definition *Definition
	Filename   string
	// Language should use names defined in https://github.com/github/linguist/blob/v7.24.1/lib/linguist/languages.yml
	Language string
	Data     []byte
}

SourceMap maps a source file/location to an LLB state/definition. SourceMaps are used to provide information for debugging and helpful error messages to the user. As an example, lets say you have a Dockerfile with the following content:

FROM alpine
RUN exit 1

When the "RUN" statement exits with a non-zero exit code buildkit will treat it as an error and is able to provide the user with a helpful error message pointing to exactly the line in the Dockerfile that caused the error.

func NewSourceMap ΒΆ added in v0.8.0

func NewSourceMap(st *State, filename string, lang string, dt []byte) *SourceMap

func (*SourceMap) Location ΒΆ added in v0.8.0

func (s *SourceMap) Location(r []*pb.Range) ConstraintsOpt

type SourceOp ΒΆ

type SourceOp struct {
	// contains filtered or unexported fields
}

func NewSource ΒΆ

func NewSource(id string, attrs map[string]string, c Constraints) *SourceOp

func (*SourceOp) Inputs ΒΆ

func (s *SourceOp) Inputs() []Output

func (*SourceOp) Marshal ΒΆ

func (s *SourceOp) Marshal(ctx context.Context, constraints *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error)

func (*SourceOp) Output ΒΆ

func (s *SourceOp) Output() Output

func (*SourceOp) Validate ΒΆ

func (s *SourceOp) Validate(ctx context.Context, c *Constraints) error

type State ΒΆ

type State struct {
	// contains filtered or unexported fields
}

State represents all operations that must be done to produce a given output. States are immutable, and all operations return a new state linked to the previous one. State is the core type of the LLB API and is used to build a graph of operations. The graph is then marshaled into a definition that can be executed by a backend (such as buildkitd).

Operations performed on a State are executed lazily after the entire state graph is marshalled and sent to the backend.

func Diff ΒΆ added in v0.10.0

func Diff(lower, upper State, opts ...ConstraintsOpt) State

Diff returns a state that represents the diff of the lower and upper states. The returned State is useful for use with Merge where you can merge the lower state with the diff.

func Git ΒΆ

func Git(url, fragment string, opts ...GitOption) State

Git returns a state that represents a git repository. Example:

st := llb.Git("https://github.com/moby/buildkit.git", "v0.11.6")

The example fetches the v0.11.6 tag of the buildkit repository. You can also use a commit hash or a branch name.

Other URL formats are supported such as "git@github.com:moby/buildkit.git", "git://...", "ssh://..." Formats that utilize SSH may need to supply credentials as a GitOption. You may need to check the source code for a full list of supported formats.

Fragment can be used to pass ref:subdir format that can set in (old-style) Docker Git URL format after # . This is provided for backwards compatibility. It is recommended to leave it empty and call GitRef(), GitSubdir() options instead.

By default the git repository is cloned with `--depth=1` to reduce the amount of data downloaded. Additionally the ".git" directory is removed after the clone, you can keep ith with the KeepGitDir GitOption.

func HTTP ΒΆ

func HTTP(url string, opts ...HTTPOption) State

func Image ΒΆ

func Image(ref string, opts ...ImageOption) State

Image returns a state that represents a docker image in a registry. Example:

st := llb.Image("busybox:latest")

func ImageBlob ΒΆ added in v0.28.0

func ImageBlob(ref string, opts ...ImageBlobOption) State

func Local ΒΆ

func Local(name string, opts ...LocalOption) State

Local returns a state that represents a directory local to the client.

func Merge ΒΆ added in v0.10.0

func Merge(inputs []State, opts ...ConstraintsOpt) State

Merge merges multiple states into a single state. This is useful in conjunction with Diff to create set of patches which are independent of each other to a base state without affecting the cache of other merged states. As an example, lets say you have a rootfs with the following directories:

/ /bin /etc /opt /tmp

Now lets say you want to copy a directory /etc/foo from one state and a binary /bin/bar from another state. Copy makes a duplicate of file on top of another directory. Merge creates a directory whose contents is an overlay of 2 states on top of each other.

With "Merge" you can do this:

fooState := Diff(rootfs, fooState)
barState := Diff(rootfs, barState)

Then merge the results with:

Merge(rootfs, fooDiff, barDiff)

The resulting state will have both /etc/foo and /bin/bar, but because Merge was used, changing the contents of "fooDiff" does not require copying "barDiff" again.

func NewState ΒΆ

func NewState(o Output) State

func OCILayout ΒΆ added in v0.11.0

func OCILayout(ref string, opts ...OCILayoutOption) State

func OCILayoutBlob ΒΆ added in v0.28.0

func OCILayoutBlob(ref string, opts ...ImageBlobOption) State

OCILayoutBlob returns a state that represents a single digest-addressed blob from an OCI layout store.

func Scratch ΒΆ

func Scratch() State

Scratch returns a state that represents an empty filesystem.

func (State) AddEnv ΒΆ

func (s State) AddEnv(key, value string) State

AddEnv returns a new State with the provided environment variable set. See AddEnv

func (State) AddEnvf ΒΆ

func (s State) AddEnvf(key, value string, v ...any) State

AddEnvf is the same as State.AddEnv but with a format string.

func (State) AddExtraHost ΒΆ

func (s State) AddExtraHost(host string, ip net.IP) State

AddExtraHost adds a host name to IP mapping to any containers created from this state.

func (State) AddUlimit ΒΆ added in v0.10.0

func (s State) AddUlimit(name UlimitName, soft int64, hard int64) State

AddUlimit sets the hard/soft for the given ulimit. The ulimit is applied to containers created from this state. Ulimits are Linux specific and only applies to containers created from this state such as via `[State.Run]` Ulimits do not apply to image configs.

func (State) Async ΒΆ added in v0.8.0

func (s State) Async(f func(context.Context, State, *Constraints) (State, error)) State

func (State) Dir ΒΆ

func (s State) Dir(str string) State

Dir returns a new State with the provided working directory set. See Dir

func (State) Dirf ΒΆ

func (s State) Dirf(str string, v ...any) State

Dirf is the same as State.Dir but with a format string.

func (State) Env ΒΆ

func (s State) Env(ctx context.Context, co ...ConstraintsOpt) (*EnvList, error)

Env returns the current environment variables for the state.

func (State) File ΒΆ added in v0.5.0

func (s State) File(a *FileAction, opts ...ConstraintsOpt) State

File performs a file operation on the current state. See FileAction for details on the operations that can be performed.

func (State) GetArgs ΒΆ

func (s State) GetArgs(ctx context.Context, co ...ConstraintsOpt) ([]string, error)

func (State) GetDir ΒΆ

func (s State) GetDir(ctx context.Context, co ...ConstraintsOpt) (string, error)

GetDir returns the current working directory for the state.

func (State) GetEnv ΒΆ

func (s State) GetEnv(ctx context.Context, key string, co ...ConstraintsOpt) (string, bool, error)

GetEnv returns the value of the environment variable with the provided key.

func (State) GetHostname ΒΆ added in v0.8.0

func (s State) GetHostname(ctx context.Context, co ...ConstraintsOpt) (string, error)

GetHostname returns the hostname set on the state. See Hostname for more details.

func (State) GetNetwork ΒΆ

func (s State) GetNetwork(ctx context.Context, co ...ConstraintsOpt) (pb.NetMode, error)

GetNetwork returns the network mode for the state.

func (State) GetPlatform ΒΆ

func (s State) GetPlatform(ctx context.Context, co ...ConstraintsOpt) (*ocispecs.Platform, error)

GetPlatform returns the platform for the state.

func (State) GetSecurity ΒΆ added in v0.5.0

func (s State) GetSecurity(ctx context.Context, co ...ConstraintsOpt) (pb.SecurityMode, error)

GetSecurity returns the security mode for the state.

func (State) Hostname ΒΆ added in v0.8.0

func (s State) Hostname(v string) State

Hostname sets the hostname for this state. See Hostname for more details.

func (State) Marshal ΒΆ

func (s State) Marshal(ctx context.Context, co ...ConstraintsOpt) (*Definition, error)

Marshal marshals the state and all its parents into a Definition.

func (State) Network ΒΆ

func (s State) Network(n pb.NetMode) State

Network sets the network mode for the state. Network modes are used by State.Run to determine the network mode used when running the container. Network modes are not applied to image configs.

func (State) Output ΒΆ

func (s State) Output() Output

Output returns the output of the state.

func (State) Platform ΒΆ

func (s State) Platform(p ocispecs.Platform) State

Platform sets the platform for the state. Platforms are used to determine image variants to pull and run as well as the platform metadata to set on the image config.

func (State) Reset ΒΆ

func (s State) Reset(s2 State) State

Reset is used to return a new State with all of the current state and the provided State as the parent. In effect you can think of this as creating a new state with all the output from the current state but reparented to the provided state. See Reset for more details.

func (State) Run ΒΆ

func (s State) Run(ro ...RunOption) ExecState

Run performs the command specified by the arguments within the context of the current State. The command is executed as a container with the State's filesystem as the root filesystem. As such any command you run must be present in the State's filesystem. Constraints such as [State.Ulimit], [State.ParentCgroup], State.Network, etc. are applied to the container.

Run is useful when none of the LLB ops are sufficient for the operation that you want to perform.

func (State) Security ΒΆ added in v0.5.0

func (s State) Security(n pb.SecurityMode) State

Security sets the security mode for the state. Security modes are used by State.Run to the privileges that processes in the container will run with. Security modes are not applied to image configs.

func (State) SetMarshalDefaults ΒΆ

func (s State) SetMarshalDefaults(co ...ConstraintsOpt) State

func (State) User ΒΆ

func (s State) User(v string) State

User sets the user for this state. See User for more details.

func (State) Validate ΒΆ

func (s State) Validate(ctx context.Context, c *Constraints) error

Validate validates the state. This validation, unlike most other operations on State, is not lazily performed.

func (State) Value ΒΆ

func (s State) Value(ctx context.Context, k any, co ...ConstraintsOpt) (any, error)

func (State) With ΒΆ

func (s State) With(so ...StateOption) State

With applies [StateOption]s to the State. Each applied StateOption creates a new State object with the previous as its parent.

func (State) WithCgroupParent ΒΆ added in v0.10.0

func (s State) WithCgroupParent(cp string) State

WithCgroupParent sets the parent cgroup for any containers created from this state. This is useful when you want to apply resource constraints to a group of containers. Cgroups are Linux specific and only applies to containers created from this state such as via `[State.Run]` Cgroups do not apply to image configs.

func (State) WithImageConfig ΒΆ added in v0.3.2

func (s State) WithImageConfig(c []byte) (State, error)

WithImageConfig adds the environment variables, working directory, and platform specified in the image config to the state.

func (State) WithOutput ΒΆ

func (s State) WithOutput(o Output) State

WithOutput creates a new state with the output set to the given output.

func (State) WithValue ΒΆ

func (s State) WithValue(k, v any) State

type StateOption ΒΆ

type StateOption func(State) State

func AddEnv ΒΆ

func AddEnv(key, value string) StateOption

AddEnv returns a StateOption whichs adds an environment variable to the state. Use this with State.With to create a new state with the environment variable set. This is the equivalent of `[State.AddEnv]`

func AddEnvf ΒΆ

func AddEnvf(key, value string, v ...any) StateOption

AddEnvf is the same as AddEnv but allows for a format string. This is the equivalent of `[State.AddEnvf]`

func Dir ΒΆ

func Dir(str string) StateOption

Dir returns a StateOption sets the working directory for the state which will be used to resolve relative paths as well as the working directory for State.Run. See State.With for where to use this.

func Dirf ΒΆ

func Dirf(str string, v ...any) StateOption

Dirf is the same as Dir but allows for a format string.

func Hostname ΒΆ added in v0.8.0

func Hostname(str string) StateOption

Hostname returns a StateOption which sets the hostname used for containers created by State.Run. This is the equivalent of State.Hostname See State.With for where to use this.

func Network ΒΆ

func Network(v pb.NetMode) StateOption

Network returns a StateOption which sets the network mode used for containers created by State.Run. This is the equivalent of State.Network See State.With for where to use this.

func Reset ΒΆ

func Reset(other State) StateOption

Reset returns a StateOption which creates a new State with just the output of the current State and the provided State is set as the parent. This is the equivalent of State.Reset

func Security ΒΆ added in v0.5.0

func Security(v pb.SecurityMode) StateOption

Security returns a StateOption which sets the security mode used for containers created by State.Run. This is the equivalent of State.Security See State.With for where to use this.

func User ΒΆ

func User(str string) StateOption

User returns a StateOption which sets the user for the state which will be used by State.Run. This is the equivalent of State.User See State.With for where to use this.

func (StateOption) SetRunOption ΒΆ added in v0.8.0

func (fn StateOption) SetRunOption(ei *ExecInfo)

type SymlinkInfo ΒΆ added in v0.19.0

type SymlinkInfo struct {
	ChownOpt    *ChownOpt
	CreatedTime *time.Time
}

SymlinkInfo is the modifiable options used to create symlinks

func (*SymlinkInfo) SetSymlinkOption ΒΆ added in v0.19.0

func (si *SymlinkInfo) SetSymlinkOption(si2 *SymlinkInfo)

type SymlinkOption ΒΆ added in v0.19.0

type SymlinkOption interface {
	SetSymlinkOption(*SymlinkInfo)
}

type TmpfsInfo ΒΆ added in v0.10.0

type TmpfsInfo struct {
	Size int64
}

type TmpfsOption ΒΆ added in v0.10.0

type TmpfsOption interface {
	SetTmpfsOption(*TmpfsInfo)
}

func TmpfsSize ΒΆ added in v0.10.0

func TmpfsSize(b int64) TmpfsOption

type UlimitName ΒΆ added in v0.10.0

type UlimitName string
const (
	UlimitCore       UlimitName = "core"
	UlimitCPU        UlimitName = "cpu"
	UlimitData       UlimitName = "data"
	UlimitFsize      UlimitName = "fsize"
	UlimitLocks      UlimitName = "locks"
	UlimitMemlock    UlimitName = "memlock"
	UlimitMsgqueue   UlimitName = "msgqueue"
	UlimitNice       UlimitName = "nice"
	UlimitNofile     UlimitName = "nofile"
	UlimitNproc      UlimitName = "nproc"
	UlimitRss        UlimitName = "rss"
	UlimitRtprio     UlimitName = "rtprio"
	UlimitRttime     UlimitName = "rttime"
	UlimitSigpending UlimitName = "sigpending"
	UlimitStack      UlimitName = "stack"
)

type UserOpt ΒΆ added in v0.5.0

type UserOpt struct {
	UID  int
	Name string
}

type Vertex ΒΆ

type Vertex interface {
	Validate(context.Context, *Constraints) error
	Marshal(context.Context, *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error)
	Output() Output
	Inputs() []Output
}

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

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