Documentation
¶
Index ¶
- Constants
- Variables
- func NewSecretScrubReader(r io.Reader, env []string, secretEnvs []string, secretFiles []string) (io.Reader, error)
- func ReadSnapshotPath(ctx context.Context, c *Client, mntable bkcache.MountableRef, filePath string, ...) ([]byte, error)
- func RunInNetNS[T any](ctx context.Context, c *Client, ns Namespaced, fn func() (T, error)) (T, error)
- func ScrubStrings(env, secretEnvs, secretFiles, in []string) ([]string, error)
- func ShutdownGlobalNamespaceWorkerPool()
- func StateIdx(ctx context.Context, st llb.State, idx solverpb.OutputIndex, ...) llb.State
- func Tracer(ctx context.Context) trace.Tracer
- type BlobOp
- type Client
- func (c *Client) AbsPath(ctx context.Context, path string) (string, error)
- func (c *Client) Exec(ctx context.Context, id string, process executor.ProcessInfo) (err error)
- func (c *Client) ExportContainerImage(ctx context.Context, destPath string, ...) (*imageexport.ExportResponse, error)
- func (c *Client) GetCredential(ctx context.Context, protocol, host, path string) (*git.CredentialInfo, error)
- func (c *Client) GetGitConfig(ctx context.Context) ([]*git.GitConfigEntry, error)
- func (c *Client) GetSessionCaller(ctx context.Context) (_ SessionCaller, rerr error)
- func (c *Client) GitCheckoutState(ctx context.Context, checkoutPath string) (string, error)
- func (c *Client) GlobCallerHostPath(ctx context.Context, dir string, pattern string) ([]string, error)
- 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) (*h2c.ListenResponse, func() error, error)
- func (c *Client) LocalDirExport(ctx context.Context, srcPath string, destPath string, merge bool, ...) (rerr error)
- func (c *Client) LocalFileExport(ctx context.Context, srcPath string, filePath string, destPath string, ...) (rerr error)
- func (c *Client) NewNetworkNamespace(ctx context.Context, hostname string) (Namespaced, error)
- func (c *Client) OpenPipe(ctx context.Context) (io.ReadWriteCloser, error)
- func (c *Client) OpenTerminal(ctx context.Context) (*TerminalClient, error)
- func (c *Client) PackGitCheckout(ctx context.Context, checkoutPath, expectedStateDigest string) (_ *GitCheckoutPack, rerr error)
- func (c *Client) PackGitUncommitted(ctx context.Context, checkoutPath, expectedHeadSHA string) (_ *GitUncommittedPack, rerr error)
- func (c *Client) PrepareContainerImage(ctx context.Context, inputByPlatform map[string]ContainerExport, ...) (*PreparedContainerImage, error)
- func (c *Client) PromptAllowLLM(ctx context.Context, moduleRepoURL string) error
- func (c *Client) PromptHumanHelp(ctx context.Context, title, question string) (string, error)
- func (c *Client) PublishContainerImage(ctx context.Context, inputByPlatform map[string]ContainerExport, ...) (*imageexport.ExportResponse, error)
- func (c *Client) ReadCallerHostFile(ctx context.Context, path string) ([]byte, error)
- func (c *Client) ReadImage(ctx context.Context, name string) (*ImageReader, error)
- func (c *Client) Run(ctx context.Context, id string, rootMount executor.Mount, ...) (rerr error)
- func (c *Client) SearchCallerHostPath(ctx context.Context, dir string, opts *engine.LocalSearchOpts) ([]engine.LocalSearchResult, error)
- func (c *Client) StatCallerHostPath(ctx context.Context, path string, returnAbsPath bool) (*fsutiltypes.Stat, error)
- func (c *Client) WriteContainerImageTarball(ctx context.Context, w io.Writer, inputByPlatform map[string]ContainerExport, ...) error
- func (c *Client) WriteImage(ctx context.Context, name string) (*ImageWriter, error)
- type ContainerExport
- type ContainerImageBlob
- type DiffOp
- type ExecOp
- type ExecutionMetadata
- type FileOp
- type GitCheckoutPack
- type GitOp
- type GitUncommittedPack
- type GlobalNamespaceWorkerPool
- func (gwp *GlobalNamespaceWorkerPool) RunInNamespaces(ctx context.Context, containerID string, namespaces []specs.LinuxNamespace, ...) error
- func (gwp *GlobalNamespaceWorkerPool) Start()
- func (gwp *GlobalNamespaceWorkerPool) Stop()
- func (gwp *GlobalNamespaceWorkerPool) SubmitJob(ctx context.Context, job *NamespaceJob) error
- type HTTPOp
- type ImageOp
- type ImageReader
- type ImageWriter
- type LocalOp
- type MergeOp
- type NamespaceJob
- type Namespaced
- 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) EffectID() string
- func (dag *OpDAG) Marshal() (*pb.Definition, error)
- func (dag *OpDAG) OutputIndex() pb.OutputIndex
- func (dag *OpDAG) String() string
- func (dag *OpDAG) Walk(f func(*OpDAG) error) error
- type Opts
- type PreparedContainerImage
- type SessionCaller
- type TerminalClient
- type Trie
- type TrieIter
Constants ¶
const ( DaggerSessionIDEnv = "_DAGGER_SESSION_ID" DaggerClientIDEnv = "_DAGGER_NESTED_CLIENT_ID" DaggerCallDigestEnv = "_DAGGER_CALL_DIGEST" DaggerEngineVersionEnv = "_DAGGER_ENGINE_VERSION" DaggerRedirectStdinEnv = "_DAGGER_REDIRECT_STDIN" DaggerRedirectStdoutEnv = "_DAGGER_REDIRECT_STDOUT" DaggerRedirectStderrEnv = "_DAGGER_REDIRECT_STDERR" DaggerHostnameAliasesEnv = "_DAGGER_HOSTNAME_ALIASES" DaggerNoInitEnv = "_DAGGER_NOINIT" DaggerSessionPortEnv = "DAGGER_SESSION_PORT" DaggerSessionTokenEnv = "DAGGER_SESSION_TOKEN" DaggerEngineNumCPUEnv = "DAGGER_ENGINE_NUM_CPU" DaggerQemuEmulatorMountPoint = "/dev/.dagger_qemu_emulator" )
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" MetaMountStdoutPath = "stdout" MetaMountStderrPath = "stderr" MetaMountCombinedOutputPath = "combinedOutput" )
const InstrumentationLibrary = "dagger.io/engine.buildkit"
Variables ¶
var ErrGitCheckoutStateChanged = errors.New("git checkout state changed")
ErrGitCheckoutStateChanged reports that a checkout moved while the engine was selecting or receiving its pack. The caller should read its state again and retry under the new cache key.
var ErrGitPackUnsupported = errors.New("client cannot pack git checkouts")
ErrGitPackUnsupported reports that the client cannot pack a checkout with its own git: either the client predates the PackCheckout RPC or it has no git binary. Callers may degrade to whatever git state the synced tree itself carries.
var ErrGitUncommittedUnsupported = errors.New("client cannot pack git worktrees")
ErrGitUncommittedUnsupported reports that the client cannot provide a packed working-tree delta. Callers may fall back to syncing the checkout directory.
var SkipInputs = fmt.Errorf("skip inputs") //nolint:staticcheck // Err prefix isn't convention for Walk control errors
Functions ¶
func NewSecretScrubReader ¶
func ReadSnapshotPath ¶
func RunInNetNS ¶
func ScrubStrings ¶
ScrubStrings redacts the engine's registered session secrets from each input string, returning a new slice (the input is left unchanged). It builds the secret trie ONCE from the same (env, secretEnvs, secretFiles) the stdout/stderr scrubbers use, so a value scrubbed from process output is scrubbed here too. All inputs may be nil/empty: with no registered secrets the strings pass through unchanged (an empty trie matches nothing). Used to redact a user exec's argv before it is emitted to the wcprof profile (native + OTel).
func ShutdownGlobalNamespaceWorkerPool ¶
func ShutdownGlobalNamespaceWorkerPool()
ShutdownGlobalNamespaceWorkerPool gracefully shuts down the global namespace worker pool This should be called during application shutdown
Types ¶
type Client ¶
type Client struct {
*Opts
// contains filtered or unexported fields
}
Client is dagger's internal engine utility client
func (*Client) AbsPath ¶
Return the absolute path of the given path as calculated by the caller's host using OS-specific rules.
func (*Client) ExportContainerImage ¶
func (c *Client) ExportContainerImage( ctx context.Context, destPath string, inputByPlatform map[string]ContainerExport, forceCompression string, tarExport bool, _ string, useOCIMediaTypes bool, ) (*imageexport.ExportResponse, error)
func (*Client) GetCredential ¶
func (*Client) GetGitConfig ¶
func (*Client) GetSessionCaller ¶
func (c *Client) GetSessionCaller(ctx context.Context) (_ SessionCaller, rerr error)
func (*Client) GitCheckoutState ¶
GitCheckoutState asks the client for a digest of a local checkout's current git state (HEAD, symbolic HEAD, branch and tag refs), resolved by the client's own git so every checkout layout works. The digest changes exactly when the checkout's refs move, making it the cache key for PackGitCheckout.
A checkout that is not a git repository reports gitutil.ErrGitNoRepo.
func (*Client) GlobCallerHostPath ¶
func (*Client) IOReaderExport ¶
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 ¶
func (*Client) LocalDirExport ¶
func (*Client) LocalFileExport ¶
func (*Client) NewNetworkNamespace ¶
func (*Client) OpenTerminal ¶
func (c *Client) OpenTerminal( ctx context.Context, ) (*TerminalClient, error)
func (*Client) PackGitCheckout ¶
func (c *Client) PackGitCheckout(ctx context.Context, checkoutPath, expectedStateDigest string) (_ *GitCheckoutPack, rerr error)
PackGitCheckout asks the client to pack a local checkout's repository with its own git. See GitCheckoutPack. A checkout that is not a git repository reports gitutil.ErrGitNoRepo.
func (*Client) PackGitUncommitted ¶
func (c *Client) PackGitUncommitted(ctx context.Context, checkoutPath, expectedHeadSHA string) (_ *GitUncommittedPack, rerr error)
PackGitUncommitted asks the client to stream the working-tree delta relative to expectedHeadSHA. Older clients and checkout states without a canonical HEAD report ErrGitUncommittedUnsupported so callers can retain the directory-sync fallback.
func (*Client) PrepareContainerImage ¶
func (c *Client) PrepareContainerImage( ctx context.Context, inputByPlatform map[string]ContainerExport, useOCIMediaTypes bool, forceCompression string, ) (*PreparedContainerImage, error)
func (*Client) PromptAllowLLM ¶
func (*Client) PromptHumanHelp ¶
func (*Client) PublishContainerImage ¶
func (c *Client) PublishContainerImage( ctx context.Context, inputByPlatform map[string]ContainerExport, refName string, useOCIMediaTypes bool, forceCompression string, network serverresolver.NetworkConfig, registryTransport serverresolver.RegistryTransport, ) (*imageexport.ExportResponse, error)
func (*Client) ReadCallerHostFile ¶
func (*Client) Run ¶
func (c *Client) Run( ctx context.Context, id string, rootMount executor.Mount, mounts []executor.Mount, procInfo executor.ProcessInfo, started chan<- struct{}, causeCtx trace.SpanContext, execMD *ExecutionMetadata, sessionID string, callerClientID string, nestedClientMetadata *engine.ClientMetadata, nestedClientModule dagql.AnyObjectResult, nestedClientFunctionCall dagql.Typed, ) (rerr error)
func (*Client) SearchCallerHostPath ¶
func (c *Client) SearchCallerHostPath(ctx context.Context, dir string, opts *engine.LocalSearchOpts) ([]engine.LocalSearchResult, error)
func (*Client) StatCallerHostPath ¶
func (*Client) WriteContainerImageTarball ¶
func (*Client) WriteImage ¶
type ContainerExport ¶
type ContainerExport struct {
Ref bkcache.ImmutableRef
Config dockerspec.DockerOCIImageConfig
Annotations []containerutil.ContainerAnnotation
}
type ContainerImageBlob ¶
type ContainerImageBlob struct {
// contains filtered or unexported fields
}
func (ContainerImageBlob) Descriptor ¶
func (blob ContainerImageBlob) Descriptor() specs.Descriptor
type ExecutionMetadata ¶
type ExecutionMetadata struct {
// Internal execution initiated by dagger and not the user.
// Used when executing the module runtime itself.
Internal bool
// UseRecipeIDsByDefault configures nested clients started by this exec to
// resolve id() as recipe-form IDs unless explicitly requested otherwise.
UseRecipeIDsByDefault bool
CallDigest digest.Digest
// hostname -> list of aliases
HostAliases map[string][]string
// search domains to install prior to the session's domain
ExtraSearchDomains []string
RedirectStdinPath string
RedirectStdoutPath string
RedirectStderrPath string
SecretEnvNames []string
SecretFilePaths []string
SystemEnvNames []string
EnabledGPUs []string
// If true, skip injecting dagger-init into the container.
NoInit bool
// ProfArgs is the fully-resolved user command (entrypoint + args), captured
// in core at exec-run time BEFORE any engine shim (the QEMU emulator, the
// executor's /.init) wraps it, so wall-clock profiling can headline the user's
// real program (e.g. "go build") instead of a shim. It is read at the executor
// emit site (executor_spec.go) by both the native recorder and the OTel source.
//
// json:"-" is load-bearing: ExecutionMetadata is JSON-serialized into exec
// cache keys (dagql.SerializedString/DigestedSerializedString), and ProfArgs
// must never perturb a cache key. It is excluded structurally here; it is also
// set only at run time (after every execMD digest is computed), and the
// core->executor hand-off is an in-process pointer (never re-serialized), so
// excluding it from JSON cannot drop it before the emit.
ProfArgs []string `json:"-"`
// UserFacingSpanCtx is the last user-facing (non-profiling) span of the API
// call this exec runs under, captured in core at exec-setup time (see
// dagql.UserFacingSpanContext). The executor injects IT as the container's
// traceparent — not its own current span: the exec runs on a detached
// execution context (shared/deduped, possibly lazily resumed) whose current
// span is a profiling span (the call_exec twin / a resume span) and which
// does not carry the caller's context mark, so only core still knows the
// user-facing span. Everything the container emits (nested SDK client
// spans, user process logs, returned Error origin extensions) parents to
// the injected id, and telemetry parented to an unrendered passthrough span
// vanishes from the row that should show it.
//
// json:"-" is load-bearing for the same reason as ProfArgs above: this
// run-time-only value must never perturb an exec cache key, and the
// core->executor hand-off is an in-process pointer, so excluding it from
// JSON cannot drop it before use.
UserFacingSpanCtx trace.SpanContext `json:"-"`
// HostAliasFQDNs maps a HostAliases key (a bound service's advertised
// hostname) to the fully qualified name the running service actually
// registered in DNS under. A service with a custom hostname is namespaced
// into the domain of whichever module started it (core.Service.startContainer),
// and that FQDN is the only name the dnsname CNI plugin registers. The
// consuming exec only searches its own module domain plus the session
// domain, so re-deriving the name from the bare hostname fails outright
// whenever the service was first started by a different module. Recording
// the FQDN keeps an explicit WithServiceBinding working across that
// boundary without installing the producer's domain as a search domain,
// which would expose every other service scoped to it.
//
// Only entries for names in the engine's DNS domain are set; tunnel
// services report a host-side dial address instead and must keep resolving
// through the search-domain sweep in setupNetwork.
//
// json:"-" is load-bearing for the same reason as ProfArgs above: this
// run-time-only value must never perturb an exec cache key, and the
// core->executor hand-off is an in-process pointer, so excluding it from
// JSON cannot drop it before use.
HostAliasFQDNs map[string]string `json:"-"`
}
type GitCheckoutPack ¶
type GitCheckoutPack struct {
HeadSHA string
HeadRef string
ObjectFormat string
StateDigest string
BundlePath string
}
GitCheckoutPack is a client checkout's repository, packed by the client's own git: a bundle of HEAD plus all branches and tags, with the metadata needed to reconstruct a standalone repository from it. A repository with no commits yet (unborn HEAD) has an empty HeadSHA and no BundlePath. The caller must call Close to release the owned bundle file.
func (*GitCheckoutPack) Close ¶
func (pack *GitCheckoutPack) Close() error
Close releases the checkout bundle owned by pack.
type GitUncommittedPack ¶
GitUncommittedPack is a checkout's git-visible working-tree delta relative to HeadSHA. PatchPath names an owned binary git patch. NestedRepositories are omitted from the patch but retain their boundaries when it is materialized engine-side. The caller must call Close to release the patch file.
func (*GitUncommittedPack) Close ¶
func (pack *GitUncommittedPack) Close() error
Close releases the uncommitted patch owned by pack.
type GlobalNamespaceWorkerPool ¶
type GlobalNamespaceWorkerPool struct {
// contains filtered or unexported fields
}
GlobalNamespaceWorkerPool manages a global pool of workers that can enter different namespace contexts based on PID and namespace type
func GetGlobalNamespaceWorkerPool ¶
func GetGlobalNamespaceWorkerPool() *GlobalNamespaceWorkerPool
GetGlobalNamespaceWorkerPool returns the singleton global namespace worker pool
func (*GlobalNamespaceWorkerPool) RunInNamespaces ¶
func (gwp *GlobalNamespaceWorkerPool) RunInNamespaces(ctx context.Context, containerID string, namespaces []specs.LinuxNamespace, fn func() error) error
RunInNamespaces executes a function in the context of specific namespaces for a given PID
func (*GlobalNamespaceWorkerPool) Start ¶
func (gwp *GlobalNamespaceWorkerPool) Start()
Start initializes and starts the global worker pool
func (*GlobalNamespaceWorkerPool) Stop ¶
func (gwp *GlobalNamespaceWorkerPool) Stop()
Stop gracefully shuts down the global worker pool
func (*GlobalNamespaceWorkerPool) SubmitJob ¶
func (gwp *GlobalNamespaceWorkerPool) SubmitJob(ctx context.Context, job *NamespaceJob) error
SubmitJob submits a job to be executed in the specified namespace context
type ImageReader ¶
type ImageWriter ¶
type NamespaceJob ¶
type NamespaceJob struct {
Container string // Container whose namespaces to enter
Namespaces []specs.LinuxNamespace // Namespaces to enter (e.g., network, mount, etc.)
Fn func() error // Function to execute
ResultCh chan error // Channel to send result back
}
NamespaceJob represents a job to be executed in a specific namespace context
type Namespaced ¶
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.
func NewDirectNS ¶
func NewDirectNS(id string) Namespaced
NewDirectNS creates a namespace, that's externally managed.
type OpDAG ¶
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) Marshal ¶
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) OutputIndex ¶
func (dag *OpDAG) OutputIndex() pb.OutputIndex
OutputIndex returns the specific output of this op represented by this OpDAG instance.
type Opts ¶
type Opts struct {
ID string
Labels map[string]string
Platforms []ocispecs.Platform
NetworkProviders map[pb.NetMode]network.Provider
Snapshotter bkcache.Snapshotter
ContentStore *containerdsnapshot.Store
Applier diff.Applier
Differ diff.Comparer
IdentityMapping *idtools.IdentityMapping
ExecutorRoot string
TelemetryPubSub http.Handler
SessionHandler sessionHandler
Runc *runc.Runc
DefaultCgroupParent string
ProcessMode oci.ProcessMode
DNSConfig *oci.DNSConfig
ApparmorProfile string
SELinux bool
Entitlements entitlements.Set
HostMntNS *os.File
CleanMntNS *os.File
Dialer *net.Dialer
GetClientCaller func(context.Context, string) (SessionCaller, error)
GetHostServiceCaller func(context.Context, string) (SessionCaller, error)
GetMainClientCaller func(context.Context) (SessionCaller, error)
GetRegistryResolver func(context.Context) (*serverresolver.Resolver, error)
Interactive bool
InteractiveCommand []string
// contains filtered or unexported fields
}
Opts combines server-scoped runtime dependencies with per-client session plumbing. Server-scoped fields are initialized once with NewOpts and shallow-copied for each client.
type PreparedContainerImage ¶
type PreparedContainerImage struct {
// contains filtered or unexported fields
}
func (*PreparedContainerImage) Blob ¶
func (image *PreparedContainerImage) Blob(id string) (ContainerImageBlob, error)
func (*PreparedContainerImage) Manifest ¶
func (image *PreparedContainerImage) Manifest() ContainerImageBlob
type SessionCaller ¶
type SessionCaller interface {
Conn() *grpc.ClientConn
Supports(method string) bool
}
type TerminalClient ¶
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 ¶
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 ¶
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.