Documentation ¶
Index ¶
- Constants
- Variables
- func AsWorkerController(w worker.Worker) (*worker.Controller, error)
- func ConvertToWorkerCacheResult(ctx context.Context, res *solverresult.Result[*ref]) (*solverresult.Result[bkcache.ImmutableRef], error)
- func IgnoreErrs(fn func() error, ignored ...error) func() error
- func Infallible(fn func()) func() error
- func NewSecretScrubReader(r io.Reader, env []string, secretEnvs []string, secretFiles []string) (io.Reader, error)
- func RunInNetNS[T any](ctx context.Context, c *Client, ns Namespaced, fn func() (T, error)) (T, error)
- func ToEntitlementStrings(ents entitlements.Set) []string
- type BlobOp
- type CleanupFunc
- type Cleanups
- type Client
- func (c *Client) BytesToBlob(ctx context.Context, fileName string, perms fs.FileMode, bs []byte, ...) (_ *bksolverpb.Definition, desc specs.Descriptor, _ error)
- func (c *Client) CombinedResult(ctx context.Context) (*Result, error)
- func (c *Client) ContainerImageToTarball(ctx context.Context, engineHostPlatform specs.Platform, fileName string, ...) (*bksolverpb.Definition, error)
- func (c *Client) DefToBlob(ctx context.Context, pbDef *bksolverpb.Definition, ...) (_ *bksolverpb.Definition, desc specs.Descriptor, _ error)
- func (c *Client) EngineContainerLocalImport(ctx context.Context, platform specs.Platform, srcPath string, ...) (*bksolverpb.Definition, specs.Descriptor, error)
- func (c *Client) ExportContainerImage(ctx context.Context, inputByPlatform map[string]ContainerExport, ...) (map[string]string, error)
- func (c *Client) GetCredential(ctx context.Context, protocol, host, path string) (*session.CredentialInfo, error)
- func (c *Client) GetSessionCaller(ctx context.Context, wait bool) (_ bksession.Caller, rerr error)
- func (c *Client) ID() string
- func (c *Client) IOReaderExport(ctx context.Context, r io.Reader, destPath string, destMode os.FileMode) (rerr error)
- func (c *Client) ListenHostToContainer(ctx context.Context, hostListenAddr, proto, upstream string) (*session.ListenResponse, func() error, error)
- func (c *Client) LocalDirExport(ctx context.Context, def *bksolverpb.Definition, destPath string, merge bool) (rerr error)
- func (c *Client) LocalFileExport(ctx context.Context, def *bksolverpb.Definition, destPath string, ...) (rerr error)
- func (c *Client) LocalImport(ctx context.Context, platform specs.Platform, srcPath string, ...) (*bksolverpb.Definition, specs.Descriptor, error)
- func (c *Client) NewContainer(ctx context.Context, req NewContainerRequest) (*Container, error)
- func (c *Client) NewNetworkNamespace(ctx context.Context, hostname string) (Namespaced, error)
- func (c *Client) OpenTerminal(ctx context.Context) (*TerminalClient, error)
- func (c *Client) PublishContainerImage(ctx context.Context, inputByPlatform map[string]ContainerExport, ...) (map[string]string, error)
- func (c *Client) ReadCallerHostFile(ctx context.Context, path string) ([]byte, error)
- func (c *Client) ResolveImageConfig(ctx context.Context, ref string, opt sourceresolver.Opt) (string, digest.Digest, []byte, error)
- func (c *Client) ResolveSourceMetadata(ctx context.Context, op *bksolverpb.SourceOp, opt sourceresolver.Opt) (*sourceresolver.MetaResponse, error)
- func (c *Client) Solve(ctx context.Context, req bkgw.SolveRequest) (_ *Result, rerr error)
- func (c *Client) StatCallerHostPath(ctx context.Context, path string, returnAbsPath bool) (*fsutiltypes.Stat, error)
- func (c *Client) UpstreamCacheExport(ctx context.Context, cacheExportFuncs []ResolveCacheExporterFunc) error
- type Container
- type ContainerExport
- type ContainerMount
- type DiffOp
- type ExecError
- type ExecOp
- type ExecutionMetadata
- type FileOp
- type GitOp
- type HTTPOp
- type ImageOp
- type LocalOp
- type MergeOp
- type Namespaced
- type NewContainerRequest
- type NewWorkerOpts
- type OCIOp
- type OpDAG
- func (dag *OpDAG) AsBlob() (*BlobOp, bool)
- func (dag *OpDAG) AsDiff() (*DiffOp, bool)
- func (dag *OpDAG) AsExec() (*ExecOp, bool)
- func (dag *OpDAG) AsFile() (*FileOp, bool)
- func (dag *OpDAG) AsGit() (*GitOp, bool)
- func (dag *OpDAG) AsHTTP() (*HTTPOp, bool)
- func (dag *OpDAG) AsImage() (*ImageOp, bool)
- func (dag *OpDAG) AsLocal() (*LocalOp, bool)
- func (dag *OpDAG) AsMerge() (*MergeOp, bool)
- func (dag *OpDAG) AsOCI() (*OCIOp, bool)
- func (dag *OpDAG) BlobDependencies() (map[digest.Digest]*ocispecs.Descriptor, error)
- func (dag *OpDAG) Marshal() (*pb.Definition, error)
- func (dag *OpDAG) String() string
- func (dag *OpDAG) Walk(f func(*OpDAG) error) error
- type Opts
- type Reference
- type ResolveCacheExporterFunc
- type Result
- type SpanProcessor
- type TerminalClient
- type Trie
- type TrieIter
- type WalkDirRequest
- type Worker
- func (w *Worker) Exec(ctx context.Context, id string, process executor.ProcessInfo) (err error)
- func (w *Worker) Executor() executor.Executor
- func (w *Worker) ResolveOp(vtx solver.Vertex, s frontend.FrontendLLBBridge, sm *bksession.Manager) (solver.Op, error)
- func (w *Worker) Run(ctx context.Context, id string, rootMount executor.Mount, ...) (_ bkresourcestypes.Recorder, rerr error)
Constants ¶
const ( InternalPrefix = "[internal] " // from buildkit, cannot change EntitlementsJobKey = "llb.entitlements" // 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" )
const ( DaggerSessionIDEnv = "_DAGGER_SESSION_ID" DaggerClientIDEnv = "_DAGGER_NESTED_CLIENT_ID" DaggerCallDigestEnv = "_DAGGER_CALL_DIGEST" DaggerEngineVersionEnv = "_DAGGER_ENGINE_VERSION" DaggerRedirectStdoutEnv = "_DAGGER_REDIRECT_STDOUT" DaggerRedirectStderrEnv = "_DAGGER_REDIRECT_STDERR" DaggerHostnameAliasesEnv = "_DAGGER_HOSTNAME_ALIASES" DaggerNoInitEnv = "_DAGGER_NOINIT" DaggerSessionPortEnv = "DAGGER_SESSION_PORT" DaggerSessionTokenEnv = "DAGGER_SESSION_TOKEN" // this is set by buildkit, we cannot change BuildkitSessionIDHeader = "x-docker-expose-session-uuid" OTelTraceParentEnv = "TRACEPARENT" OTelExporterProtocolEnv = "OTEL_EXPORTER_OTLP_PROTOCOL" OTelExporterEndpointEnv = "OTEL_EXPORTER_OTLP_ENDPOINT" OTelTracesProtocolEnv = "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL" OTelTracesEndpointEnv = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT" OTelTracesLiveEnv = "OTEL_EXPORTER_OTLP_TRACES_LIVE" OTelLogsProtocolEnv = "OTEL_EXPORTER_OTLP_LOGS_PROTOCOL" OTelLogsEndpointEnv = "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT" OTelMetricsProtocolEnv = "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL" OTelMetricsEndpointEnv = "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT" )
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" MetaMountExitCodePath = "exitCode" MetaMountStdinPath = "stdin" MetaMountStdoutPath = "stdout" MetaMountStderrPath = "stderr" MetaMountClientIDPath = "clientID" )
const InstrumentationLibrary = "dagger.io/engine.buildkit"
const TelemetryComponent = "buildkit"
Variables ¶
var SkipInputs = fmt.Errorf("skip inputs") //nolint:stylecheck // Err prefix isn't convention for Walk control errors
Functions ¶
func AsWorkerController ¶ added in v0.11.8
func AsWorkerController(w worker.Worker) (*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 ConvertToWorkerCacheResult ¶
func ConvertToWorkerCacheResult(ctx context.Context, res *solverresult.Result[*ref]) (*solverresult.Result[bkcache.ImmutableRef], error)
func IgnoreErrs ¶ added in v0.11.8
func Infallible ¶ added in v0.11.8
func Infallible(fn func()) func() error
func NewSecretScrubReader ¶ added in v0.11.5
func RunInNetNS ¶ added in v0.11.5
func ToEntitlementStrings ¶ added in v0.11.8
func ToEntitlementStrings(ents entitlements.Set) []string
Types ¶
type BlobOp ¶ added in v0.8.8
func (*BlobOp) OCIDescriptor ¶ added in v0.8.8
func (op *BlobOp) OCIDescriptor() (ocispecs.Descriptor, error)
type CleanupFunc ¶ added in v0.11.8
type CleanupFunc struct {
// contains filtered or unexported fields
}
type Cleanups ¶ added in v0.11.8
type Cleanups struct {
// contains filtered or unexported fields
}
func (*Cleanups) Add ¶ added in v0.11.8
func (c *Cleanups) Add(msg string, f func() error) CleanupFunc
func (*Cleanups) ReAdd ¶ added in v0.11.8
func (c *Cleanups) ReAdd(f CleanupFunc) CleanupFunc
ReAdd allows you to decide to run an already added cleanup function at a later time. Once readded, it will only be run at this time rather than both times. This is occasionally needed when you want to ensure some state is cleaned up right after it's created, but if more state is created later you ned to run this cleanup at that later time (e.g. closing a network connection in all cases).
type Client ¶
type Client struct { *Opts // contains filtered or unexported fields }
Client is dagger's internal interface to buildkit APIs
func (*Client) BytesToBlob ¶ added in v0.11.7
func (c *Client) BytesToBlob( ctx context.Context, fileName string, perms fs.FileMode, bs []byte, compressionType compression.Type, ) (_ *bksolverpb.Definition, desc specs.Descriptor, _ error)
func (*Client) CombinedResult ¶
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, compressionType compression.Type, ) (_ *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 (*Client) GetCredential ¶ added in v0.14.0
func (*Client) GetSessionCaller ¶
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 (*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 (*Client) NewNetworkNamespace ¶ added in v0.11.5
func (*Client) OpenTerminal ¶ added in v0.12.0
func (c *Client) OpenTerminal( ctx context.Context, ) (*TerminalClient, error)
func (*Client) PublishContainerImage ¶
func (*Client) ReadCallerHostFile ¶
func (*Client) ResolveImageConfig ¶
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) StatCallerHostPath ¶ added in v0.9.9
func (*Client) UpstreamCacheExport ¶
func (c *Client) UpstreamCacheExport(ctx context.Context, cacheExportFuncs []ResolveCacheExporterFunc) error
type Container ¶ added in v0.11.5
func (*Container) NamespaceID ¶ added in v0.11.5
type ContainerExport ¶
type ContainerExport struct { Definition *bksolverpb.Definition Config specs.ImageConfig }
type ContainerMount ¶ added in v0.12.0
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) Extensions ¶
type ExecOp ¶ added in v0.8.8
func (*ExecOp) OutputMount ¶ added in v0.8.8
func (*ExecOp) OutputMountBase ¶ added in v0.8.8
type ExecutionMetadata ¶ added in v0.11.3
type ExecutionMetadata struct { ClientID string SessionID string SecretToken string Hostname string // The "stable" ID of the client that is used to identify filesync cache refs // across different clients running on the same host. // For now, nested execs are just always given a random unique ID each exec (as // opposed to clients running on the host which re-use a persisted ID). ClientStableID string // Unique (random) ID for this execution. // This is used to deduplicate the same execution that gets evaluated multiple times. ExecID string // Internal execution initiated by dagger and not the user. // Used when executing the module runtime itself. Internal bool // TODO: can rm EncodedModuleID now CallID *call.ID EncodedModuleID string EncodedFunctionCall json.RawMessage CallerClientID string // Client resource IDs passed to this client from parent object fields. // Needed to handle finding any secrets, sockets or other client resources // that this client should have access to due to being set in the parent // object. ParentIDs map[digest.Digest]*resource.ID // If true, scope the exec cache key to the current session ID. It will be cached in the context // of the session but invalidated across different sessions. CachePerSession bool // If true, scope the exec cache key to the current dagql call digest. This is needed currently // for module function calls specifically so that their cache key is based on their arguments and // receiver object. CacheByCall bool // hostname -> list of aliases HostAliases map[string][]string // search domains to install prior to the session's domain ExtraSearchDomains []string RedirectStdoutPath string RedirectStderrPath string SecretEnvNames []string SecretFilePaths []string SystemEnvNames []string EnabledGPUs []string SpanContext propagation.MapCarrier // Path to the SSH auth socket. Used for Dagger-in-Dagger support. SSHAuthSocketPath string // If true, skip injecting dumb-init into the container. NoInit bool }
func ExecutionMetadataFromDescription ¶ added in v0.11.5
func ExecutionMetadataFromDescription(desc map[string]string) (*ExecutionMetadata, bool, error)
func (ExecutionMetadata) AsConstraintsOpt ¶ added in v0.11.3
func (md ExecutionMetadata) AsConstraintsOpt() (llb.ConstraintsOpt, error)
type Namespaced ¶ added in v0.11.5
Namespaced is something that has Linux namespaces set up. Currently this is either a full-blown container or just a raw network namespace that's setns'd into to support service tunneling and similar.
type NewContainerRequest ¶ added in v0.11.5
type NewContainerRequest struct { Mounts []ContainerMount Platform *bksolverpb.Platform Hostname string ExecutionMetadata }
type NewWorkerOpts ¶ added in v0.11.3
type NewWorkerOpts struct { WorkerRoot string ExecutorRoot string BaseWorker *base.Worker TelemetryPubSub http.Handler BKSessionManager *bksession.Manager SessionHandler sessionHandler Runc *runc.Runc DefaultCgroupParent string ProcessMode oci.ProcessMode IDMapping *idtools.IdentityMapping DNSConfig *oci.DNSConfig ApparmorProfile string SELinux bool Entitlements entitlements.Set NetworkProviders map[pb.NetMode]network.Provider ParallelismSem *semaphore.Weighted WorkerCache bkcache.Manager }
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 (*OpDAG) BlobDependencies ¶ added in v0.8.8
func (dag *OpDAG) BlobDependencies() (map[digest.Digest]*ocispecs.Descriptor, error)
type Opts ¶
type Opts struct { Worker *Worker SessionManager *bksession.Manager BkSession *bksession.Session LLBBridge bkfrontend.FrontendLLBBridge Dialer *net.Dialer GetMainClientCaller func() (bksession.Caller, error) Entitlements entitlements.Set UpstreamCacheImports []bkgw.CacheOptionsEntry Frontends map[string]bkfrontend.Frontend Refs map[Reference]struct{} RefsMu *sync.Mutex Containers map[bkgw.Container]struct{} ContainersMu *sync.Mutex Interactive bool InteractiveCommand []string }
Opts for a Client that are shared across all instances for a given DaggerServer
type Result ¶
type Result = solverresult.Result[*ref]
type SpanProcessor ¶ added in v0.12.0
type SpanProcessor struct{}
SpanProcessor modifies spans coming from the Buildkit component to integrate them with Dagger's telemetry stack.
It must be used in combination with the buildkitTraceProvider.
func (SpanProcessor) ForceFlush ¶ added in v0.12.0
func (sp SpanProcessor) ForceFlush(context.Context) error
func (SpanProcessor) OnEnd ¶ added in v0.12.0
func (sp SpanProcessor) OnEnd(sdktrace.ReadOnlySpan)
func (SpanProcessor) OnStart ¶ added in v0.12.0
func (sp SpanProcessor) OnStart(ctx context.Context, span sdktrace.ReadWriteSpan)
type TerminalClient ¶ added in v0.12.0
type TerminalClient struct { Stdin io.ReadCloser Stdout io.WriteCloser Stderr io.WriteCloser ResizeCh chan bkgw.WinSize ErrCh chan error Close func(exitCode int) error }
type Trie ¶ added in v0.11.5
type Trie struct {
// contains filtered or unexported fields
}
Trie is a simple implementation of a compressed trie (or radix tree). In essence, it's a key-value store that allows easily selecting all entries that have a given prefix.
Why not an off-the-shelf implementation? Well, most of those don't allow navigating character-by-character through the tree, like we do with Step.
type TrieIter ¶ added in v0.12.4
type TrieIter struct { *Trie // contains filtered or unexported fields }
TrieIter is an iterator that allows navigating through a Trie.
This is used so that we can navigate through the compressed Trie structure easily - not every node "exists", but the TrieIter handles this case. For example, a node might have a direct of `foo`, so the node `fo` is virtual.
type WalkDirRequest ¶ added in v0.12.5
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 SessionID, 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(opts *NewWorkerOpts) *Worker