buildkit

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 107 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FocusPrefix    = "[focus] "
	InternalPrefix = "[internal] "

	DaggerWorkerJobKey = "dagger.worker"
)
View Source
const (
	// Exec errors will only include the last this number of bytes of output.
	MaxExecErrorOutputBytes = 100 * 1024

	// TruncationMessage is the message that will be prepended to truncated output.
	TruncationMessage = "[omitting %d bytes]..."

	// MaxFileContentsChunkSize sets the maximum chunk size for ReadFile calls
	// Equals around 95% of the max message size (4MB) in
	// order to keep space for any Protocol Buffers overhead:
	MaxFileContentsChunkSize = 3984588

	// MaxFileContentsSize sets the limit of the maximum file size
	// that can be retrieved using File.Contents, currently set to 128MB:
	MaxFileContentsSize = 128 << 20

	// MetaMountDestPath is the special path that the shim writes metadata to.
	MetaMountDestPath = "/.dagger_meta_mount"

	// MetaSourcePath is a world-writable directory created and mounted to /dagger.
	MetaSourcePath = "meta"
)
View Source
const (
	// OCIStoreName is the name of the OCI content store used for OCI tarball
	// imports.
	OCIStoreName = "dagger-oci"

	// BuiltinContentOCIStoreName is the name of the OCI content store used for
	// builtins like SDKs that we package with the engine container but still use
	// in LLB.
	BuiltinContentOCIStoreName = "dagger-builtin-content"
)

Variables

View Source
var SkipInputs = fmt.Errorf("skip inputs") //nolint:stylecheck // Err prefix isn't convention for Walk control errors

Functions

func ConvertToWorkerCacheResult

func ConvertToWorkerCacheResult(ctx context.Context, res *solverresult.Result[*ref]) (*solverresult.Result[bkcache.ImmutableRef], error)

Types

type BlobOp added in v0.8.8

type BlobOp struct {
	*OpDAG
	*pb.SourceOp
}

func (*BlobOp) OCIDescriptor added in v0.8.8

func (op *BlobOp) OCIDescriptor() (ocispecs.Descriptor, error)

type Client

type Client struct {
	*Opts
	// contains filtered or unexported fields
}

Client is dagger's internal interface to buildkit APIs

func NewClient

func NewClient(ctx context.Context, opts *Opts) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) CombinedResult

func (c *Client) CombinedResult(ctx context.Context) (*Result, error)

CombinedResult returns a buildkit result with all the refs solved by this client so far. This is useful for constructing a result for upstream remote caching.

func (*Client) ContainerImageToTarball added in v0.9.0

func (c *Client) ContainerImageToTarball(
	ctx context.Context,
	engineHostPlatform specs.Platform,
	fileName string,
	inputByPlatform map[string]ContainerExport,
	opts map[string]string,
) (*bksolverpb.Definition, error)

func (*Client) DefToBlob added in v0.9.8

func (c *Client) DefToBlob(
	ctx context.Context,
	pbDef *bksolverpb.Definition,
) (_ *bksolverpb.Definition, desc specs.Descriptor, _ error)

DefToBlob converts the given llb definition to a content addressed blob valid for the duration of the current session. It's useful for converting unstable sources like local dir imports into stable, content-defined sources. NOTE: it's currently assumed that the provided definition is a single layer. Definitions can be squashed into a single layer by copying from them to scratch.

func (*Client) EngineContainerLocalImport added in v0.9.0

func (c *Client) EngineContainerLocalImport(
	ctx context.Context,
	platform specs.Platform,
	srcPath string,
	excludePatterns []string,
	includePatterns []string,
) (*bksolverpb.Definition, specs.Descriptor, error)

Import a directory from the engine container, as opposed to from a client

func (*Client) ExportContainerImage

func (c *Client) ExportContainerImage(
	ctx context.Context,
	inputByPlatform map[string]ContainerExport,
	destPath string,
	opts map[string]string,
) (map[string]string, error)

func (*Client) GetSessionCaller

func (c *Client) GetSessionCaller(ctx context.Context, wait bool) (bksession.Caller, error)

func (*Client) ID

func (c *Client) ID() string

func (*Client) IOReaderExport added in v0.8.8

func (c *Client) IOReaderExport(ctx context.Context, r io.Reader, destPath string, destMode os.FileMode) (rerr error)

IOReaderExport exports the contents of an io.Reader to the caller's local fs as a file TODO: de-dupe this with the above method to extent possible

func (*Client) ListenHostToContainer added in v0.9.0

func (c *Client) ListenHostToContainer(
	ctx context.Context,
	hostListenAddr, proto, upstream string,
) (*session.ListenResponse, func() error, error)

func (*Client) LocalDirExport

func (c *Client) LocalDirExport(
	ctx context.Context,
	def *bksolverpb.Definition,
	destPath string,
	merge bool,
) (rerr error)

func (*Client) LocalFileExport

func (c *Client) LocalFileExport(
	ctx context.Context,
	def *bksolverpb.Definition,
	destPath string,
	filePath string,
	allowParentDirPath bool,
) (rerr error)

func (*Client) LocalImport added in v0.8.8

func (c *Client) LocalImport(
	ctx context.Context,
	platform specs.Platform,
	srcPath string,
	excludePatterns []string,
	includePatterns []string,
) (*bksolverpb.Definition, specs.Descriptor, error)

func (*Client) NewContainer

func (c *Client) NewContainer(ctx context.Context, req bkgw.NewContainerRequest) (bkgw.Container, error)

func (*Client) PublishContainerImage

func (c *Client) PublishContainerImage(
	ctx context.Context,
	inputByPlatform map[string]ContainerExport,
	opts map[string]string,
) (map[string]string, error)

func (*Client) ReadCallerHostFile

func (c *Client) ReadCallerHostFile(ctx context.Context, path string) ([]byte, error)

func (*Client) ResolveImageConfig

func (c *Client) ResolveImageConfig(ctx context.Context, ref string, opt sourceresolver.Opt) (string, digest.Digest, []byte, error)

func (*Client) ResolveSourceMetadata added in v0.11.1

func (c *Client) ResolveSourceMetadata(ctx context.Context, op *bksolverpb.SourceOp, opt sourceresolver.Opt) (*sourceresolver.MetaResponse, error)

func (*Client) Solve

func (c *Client) Solve(ctx context.Context, req bkgw.SolveRequest) (_ *Result, rerr error)

func (*Client) StatCallerHostPath added in v0.9.9

func (c *Client) StatCallerHostPath(ctx context.Context, path string, returnAbsPath bool) (*fsutiltypes.Stat, error)

func (*Client) UpstreamCacheExport

func (c *Client) UpstreamCacheExport(ctx context.Context, cacheExportFuncs []ResolveCacheExporterFunc) error

func (*Client) WriteStatusesTo

func (c *Client) WriteStatusesTo(ctx context.Context, dest io.Writer)

type ContainerExport

type ContainerExport struct {
	Definition *bksolverpb.Definition
	Config     specs.ImageConfig
}

type DiffOp added in v0.8.8

type DiffOp struct {
	*OpDAG
	*pb.DiffOp
}

type ExecError

type ExecError struct {
	Cmd      []string
	ExitCode int
	Stdout   string
	Stderr   string
	// contains filtered or unexported fields
}

ExecError is an error that occurred while executing an `Op_Exec`.

func (*ExecError) Error

func (e *ExecError) Error() string

func (*ExecError) Extensions

func (e *ExecError) Extensions() map[string]interface{}

func (*ExecError) Unwrap

func (e *ExecError) Unwrap() error

type ExecOp added in v0.8.8

type ExecOp struct {
	*OpDAG
	*pb.ExecOp
}

func (*ExecOp) Input added in v0.8.8

func (exec *ExecOp) Input(i pb.InputIndex) *OpDAG

func (*ExecOp) OutputMount added in v0.8.8

func (exec *ExecOp) OutputMount() *pb.Mount

func (*ExecOp) OutputMountBase added in v0.8.8

func (exec *ExecOp) OutputMountBase() *OpDAG

type ExecutionMetadata added in v0.11.3

type ExecutionMetadata struct {
	SystemEnvNames []string
	ClientID       string
	OTELEnvs       []string
}

func (ExecutionMetadata) AsConstraintsOpt added in v0.11.3

func (md ExecutionMetadata) AsConstraintsOpt() (llb.ConstraintsOpt, error)

type FileOp added in v0.8.8

type FileOp struct {
	*OpDAG
	*pb.FileOp
}

type GitOp added in v0.8.8

type GitOp struct {
	*OpDAG
	*pb.SourceOp
}

type HTTPOp added in v0.8.8

type HTTPOp struct {
	*OpDAG
	*pb.SourceOp
}

type ImageOp added in v0.8.8

type ImageOp struct {
	*OpDAG
	*pb.SourceOp
}

type LocalOp added in v0.8.8

type LocalOp struct {
	*OpDAG
	*pb.SourceOp
}

type MergeOp added in v0.8.8

type MergeOp struct {
	*OpDAG
	*pb.MergeOp
}

type NewWorkerOpts added in v0.11.3

type NewWorkerOpts struct {
	Root                 string
	SnapshotterFactory   workerrunc.SnapshotterFactory
	ProcessMode          oci.ProcessMode
	Labels               map[string]string
	IDMapping            *idtools.IdentityMapping
	NetworkProvidersOpts netproviders.Opt
	DNSConfig            *oci.DNSConfig
	ApparmorProfile      string
	SELinux              bool
	ParallelismSem       *semaphore.Weighted
	TraceSocket          string
	DefaultCgroupParent  string
	Entitlements         []string
	GCPolicy             []client.PruneInfo
	BuildkitVersion      client.BuildkitVersion
	RegistryHosts        docker.RegistryHosts
	Platforms            []ocispecs.Platform
}

type OCIOp added in v0.8.8

type OCIOp struct {
	*OpDAG
	*pb.SourceOp
}

type OpDAG added in v0.8.8

type OpDAG struct {
	*pb.Op                  // the root of the DAG
	OpDigest *digest.Digest // the digest of this root, common across all outputIndexes for this root
	Metadata *pb.OpMetadata // metadata for the root
	Inputs   []*OpDAG       // the inputs to the root
	// contains filtered or unexported fields
}

func DefToDAG added in v0.8.8

func DefToDAG(def *pb.Definition) (*OpDAG, error)

func (*OpDAG) AsBlob added in v0.8.8

func (dag *OpDAG) AsBlob() (*BlobOp, bool)

func (*OpDAG) AsDiff added in v0.8.8

func (dag *OpDAG) AsDiff() (*DiffOp, bool)

func (*OpDAG) AsExec added in v0.8.8

func (dag *OpDAG) AsExec() (*ExecOp, bool)

func (*OpDAG) AsFile added in v0.8.8

func (dag *OpDAG) AsFile() (*FileOp, bool)

func (*OpDAG) AsGit added in v0.8.8

func (dag *OpDAG) AsGit() (*GitOp, bool)

func (*OpDAG) AsHTTP added in v0.8.8

func (dag *OpDAG) AsHTTP() (*HTTPOp, bool)

func (*OpDAG) AsImage added in v0.8.8

func (dag *OpDAG) AsImage() (*ImageOp, bool)

func (*OpDAG) AsLocal added in v0.8.8

func (dag *OpDAG) AsLocal() (*LocalOp, bool)

func (*OpDAG) AsMerge added in v0.8.8

func (dag *OpDAG) AsMerge() (*MergeOp, bool)

func (*OpDAG) AsOCI added in v0.8.8

func (dag *OpDAG) AsOCI() (*OCIOp, bool)

func (*OpDAG) BlobDependencies added in v0.8.8

func (dag *OpDAG) BlobDependencies() (map[digest.Digest]*ocispecs.Descriptor, error)

func (*OpDAG) Marshal added in v0.8.8

func (dag *OpDAG) Marshal() (*pb.Definition, error)

Marshal will convert the dag back to a flat pb.Definition, updating all digests based on any modifications made to the dag.

func (*OpDAG) String added in v0.8.8

func (dag *OpDAG) String() string

func (*OpDAG) Walk added in v0.8.8

func (dag *OpDAG) Walk(f func(*OpDAG) error) error

type Opts

type Opts struct {
	ServerID string

	BaseWorker     *Worker
	SessionManager *bksession.Manager
	GenericSolver  *bksolver.Solver
	CacheManager   bksolver.CacheManager

	PrivilegedExecEnabled bool
	Entitlements          []string

	SecretStore  bksecrets.SecretStore
	AuthProvider *auth.RegistryAuthProvider

	UpstreamCacheImporters map[string]remotecache.ResolveCacheImporterFunc
	UpstreamCacheImports   []bkgw.CacheOptionsEntry

	// MainClientCaller is the caller who initialized the server associated with this
	// client. It is special in that when it shuts down, the client will be closed and
	// that registry auth and sockets are currently only ever sourced from this caller,
	// not any nested clients (may change in future).
	MainClientCaller bksession.Caller
	DNSConfig        *oci.DNSConfig
	Frontends        map[string]bkfrontend.Frontend
	BuildkitLogSink  io.Writer
	// contains filtered or unexported fields
}

Opts for a Client that are shared across all instances for a given DaggerServer

type ResolveCacheExporterFunc

type ResolveCacheExporterFunc func(ctx context.Context, g bksession.Group) (remotecache.Exporter, error)

type Result

type Result = solverresult.Result[*ref]

type Worker added in v0.11.3

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

Worker is Dagger's custom worker. Most of the buildkit Worker interface methods are just inherited from buildkit's base.Worker, with the exception of methods involving executor.Executor (most importantly ResolveOp).

We need a custom Executor implementation for setting up containers (currently, just for providing ServerID, but in the future everything the shim does will be migrated here). For simplicity, this Worker struct also implements that Executor interface (in executor.go) since Worker+Executor are so tightly bound together anyways.

func NewWorker added in v0.11.3

func NewWorker(ctx context.Context, opts *NewWorkerOpts) (*Worker, error)

func (*Worker) AsWorkerController added in v0.11.3

func (w *Worker) AsWorkerController() (*worker.Controller, error)

Buildkit's worker.Controller is a bit odd; it exists to manage multiple workers because that was a planned feature years ago, but it never got implemented. So it exists to manage a single worker, which doesn't really add much.

We still need to provide a worker.Controller value to a few places though, which this method enables.

func (*Worker) Exec added in v0.11.3

func (w *Worker) Exec(ctx context.Context, id string, process executor.ProcessInfo) (err error)

func (*Worker) Executor added in v0.11.3

func (w *Worker) Executor() executor.Executor

func (*Worker) ResolveOp added in v0.11.3

func (w *Worker) ResolveOp(vtx solver.Vertex, s frontend.FrontendLLBBridge, sm *session.Manager) (solver.Op, error)

func (*Worker) Run added in v0.11.3

func (w *Worker) Run(
	ctx context.Context,
	id string,
	root executor.Mount,
	mounts []executor.Mount,
	process executor.ProcessInfo,
	started chan<- struct{},
) (_ resourcestypes.Recorder, rerr error)

func (*Worker) WithServerID added in v0.11.3

func (w *Worker) WithServerID(serverID string) *Worker

func (*Worker) WithVertex added in v0.11.3

func (w *Worker) WithVertex(vtx solver.Vertex) *Worker

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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