template

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package template provides a fluent builder and a Client for building E2B sandbox templates. It mirrors the public surface of the Python Template and JS TemplateBase classes.

A Builder accumulates instructions and can be serialized with ToDockerfile or ToJSON. To register a template with the E2B backend, construct a Client via NewClient and call Build / BuildStream / BuildInBackground. Client methods honor context cancellation and are safe for concurrent use; a *Builder is not — construct one per goroutine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLogger

func DefaultLogger(w io.Writer) func(LogEntry)

DefaultLogger returns a function that prints log entries to stderr.

Types

type AptOption

type AptOption func(*aptOpts)

AptOption configures Builder.AptInstall.

func WithAptFixMissing

func WithAptFixMissing() AptOption

WithAptFixMissing passes --fix-missing to apt-get install.

func WithAptNoInstallRecommends

func WithAptNoInstallRecommends() AptOption

WithAptNoInstallRecommends passes --no-install-recommends to apt-get install.

type BuildError

type BuildError struct {
	Op         string
	TemplateID string
	BuildID    string
	Step       string
	Message    string
	LogTail    []LogEntry
	Err        error
}

BuildError describes a failure during a server-side template build. Unwrap() returns e2b.ErrTemplateBuild so callers can use errors.Is.

func (*BuildError) Error

func (e *BuildError) Error() string

func (*BuildError) Unwrap

func (e *BuildError) Unwrap() error

type BuildEvent

type BuildEvent struct {
	Log  *LogEntry
	Done *BuildInfo
	Err  error
}

BuildEvent is one emission from Client.BuildStream. Exactly one of Log, Done, or Err is non-nil at a time. The channel closes after emitting a terminal Done or Err.

type BuildInfo

type BuildInfo struct {
	TemplateID string
	BuildID    string
	Name       string
	Tags       []string
}

BuildInfo identifies a completed or in-flight template build. Returned from Client.Build and Client.BuildInBackground.

type BuildLogsOptions

type BuildLogsOptions struct {
	// CursorMs is the starting timestamp in milliseconds. 0 means server default.
	CursorMs int64
	// Limit caps the number of log entries returned (0–1000). 0 means server default.
	Limit int32
	// Direction is "asc" or "desc". Empty means server default.
	Direction string
	// Level filters out entries below this level. Empty means no filter.
	Level LogLevel
}

BuildLogsOptions filters Client.GetBuildLogs.

type BuildOptions

type BuildOptions struct {
	Name         string
	Tags         []string
	CPUCount     int32
	MemoryMB     int32
	SkipCache    bool
	PollInterval time.Duration
}

BuildOptions captures every caller-tunable parameter of a template build.

type BuildReason

type BuildReason struct {
	Step    string
	Message string
	Logs    []LogEntry
}

BuildReason describes why a build ended in the error state.

type BuildStatus

type BuildStatus struct {
	TemplateID string
	BuildID    string
	Status     BuildStatusValue
	Logs       []LogEntry
	Reason     *BuildReason
}

BuildStatus is the server-reported state of a template build.

type BuildStatusValue

type BuildStatusValue string

BuildStatusValue enumerates the possible states of a running template build, mirroring the upstream API enum.

const (
	BuildStatusBuilding BuildStatusValue = "building"
	BuildStatusWaiting  BuildStatusValue = "waiting"
	BuildStatusReady    BuildStatusValue = "ready"
	BuildStatusError    BuildStatusValue = "error"
)

type Builder

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

Builder constructs a template. A *Builder is not safe for concurrent use — construct one per goroutine, or fully finalize it with SetStartCmd / SetReadyCmd (which return a *FinalBuilder) before handing the result off.

func New

func New() *Builder

New returns an empty builder. Use FromImage / FromDockerfile to specify a base.

func (*Builder) AddMCPServer

func (b *Builder) AddMCPServer(servers []string) *Builder

AddMCPServer adds one or more MCP servers using mcp-gateway. Only valid when the builder was initialized with FromTemplate("mcp-gateway"); the error is captured on the builder and surfaced at serialize().

func (*Builder) AptInstall

func (b *Builder) AptInstall(packages []string, opts ...AptOption) *Builder

AptInstall emits the Python SDK's canonical "apt-get update && apt-get install -y ..." one-liner so the update and install share a single cache layer and partial updates never go stale. Each flag literal carries its own trailing space; that space is consumed by the space before the packages join, which is why no explicit TrimRight is needed. Callers are expected to pass at least one package.

func (*Builder) BaseImage

func (b *Builder) BaseImage() string

BaseImage returns the base image (empty when building on an E2B template).

func (*Builder) BaseTemplate

func (b *Builder) BaseTemplate() string

BaseTemplate returns the base template ID (empty when building on an image).

func (*Builder) BetaDevContainerPrebuild

func (b *Builder) BetaDevContainerPrebuild(dir string) *Builder

BetaDevContainerPrebuild runs a devcontainer build during the template build. Only valid when the builder was initialized with FromTemplate("devcontainer").

func (*Builder) BetaSetDevContainerStart

func (b *Builder) BetaSetDevContainerStart(dir string) *FinalBuilder

BetaSetDevContainerStart wires the devcontainer-specific start+ready commands to a workspace directory. Requires FromTemplate("devcontainer").

func (*Builder) BunInstall

func (b *Builder) BunInstall(packages []string, opts ...BunOption) *Builder

BunInstall emits a RUN that installs JS/TS packages via bun. Nil/empty packages produce a bare "bun install".

func (*Builder) Copy

func (b *Builder) Copy(src, dst string, opts ...CopyOption) *Builder

Copy adds a COPY instruction from the template build context. The Args slice carries four positional slots — src, dst, user, mode. When mode is unset the slot stays "", otherwise it is formatted as a zero-padded 4-digit octal string.

func (*Builder) CopyItems

func (b *Builder) CopyItems(items []CopyItem) *Builder

CopyItems adds a COPY instruction for each item, translating struct fields to CopyOptions so validation and defaults match single Copy calls.

func (*Builder) Entrypoint

func (b *Builder) Entrypoint(cmd string) *Builder

Entrypoint sets the container entrypoint. Retained for Dockerfile-level parity; the server build API has no direct ENTRYPOINT step, so serialize() does not emit one.

func (*Builder) Env

func (b *Builder) Env(key, value string) *Builder

Env sets an environment variable.

func (*Builder) Expose

func (b *Builder) Expose(port int) *Builder

Expose documents a port.

func (*Builder) FromAWSRegistry

func (b *Builder) FromAWSRegistry(image, accessKeyID, secretAccessKey, region string) *Builder

FromAWSRegistry sets the base image and configures AWS ECR authentication.

func (*Builder) FromBaseImage

func (b *Builder) FromBaseImage() *Builder

FromBaseImage resets to the default e2bdev/base image.

func (*Builder) FromBunImage

func (b *Builder) FromBunImage(variant string) *Builder

FromBunImage starts a template from an official Bun image. The default variant is "latest".

func (*Builder) FromDebianImage

func (b *Builder) FromDebianImage(variant string) *Builder

FromDebianImage starts a template from an official Debian image. The default variant is "stable".

func (*Builder) FromDockerfile

func (b *Builder) FromDockerfile(contents string) *Builder

FromDockerfile parses inline Dockerfile content. Deprecated: prefer FromDockerfileContent (clearer name) or FromDockerfileFile.

func (*Builder) FromDockerfileContent

func (b *Builder) FromDockerfileContent(content string) *Builder

FromDockerfileContent parses inline Dockerfile text and applies the instructions to this builder. Supported instructions: FROM, RUN, COPY (two-token form), WORKDIR, USER, ENV. Others are silently ignored.

func (*Builder) FromDockerfileFile

func (b *Builder) FromDockerfileFile(path string) *Builder

FromDockerfileFile reads a file from disk and parses it with FromDockerfileContent.

func (*Builder) FromGCPRegistry

func (b *Builder) FromGCPRegistry(image, serviceAccountJSON string) *Builder

FromGCPRegistry sets the base image and configures GCP Artifact/Container Registry authentication via a service-account JSON blob.

func (*Builder) FromGoImage

func (b *Builder) FromGoImage(tag string) *Builder

FromGoImage uses the official golang image.

func (*Builder) FromImage

func (b *Builder) FromImage(image string, creds ...RegistryCredentials) *Builder

FromImage sets the base Docker image. An optional RegistryCredentials argument supplies basic-auth credentials for a private registry; only the first value is consulted. When both Username and Password are empty the registry config is left nil.

func (*Builder) FromNodeImage

func (b *Builder) FromNodeImage(tag string) *Builder

FromNodeImage uses the official node image.

func (*Builder) FromPythonImage

func (b *Builder) FromPythonImage(tag string) *Builder

FromPythonImage uses the official python image with the given tag (default "3").

func (*Builder) FromTemplate

func (b *Builder) FromTemplate(templateID string) *Builder

FromTemplate bases this template on another E2B template.

func (*Builder) FromUbuntuImage

func (b *Builder) FromUbuntuImage(variant string) *Builder

FromUbuntuImage starts a template from an official Ubuntu image. The default variant is "latest".

func (*Builder) GitClone

func (b *Builder) GitClone(url string, opts ...GitCloneOption) *Builder

GitClone emits a RUN that clones the given URL. Branch, depth, and path options append their tokens in the order git expects (branch adds three tokens, depth adds two, path adds one).

func (*Builder) MakeDir

func (b *Builder) MakeDir(paths []string, opts ...MkdirOption) *Builder

MakeDir creates one or more directories inside the template during build.

func (b *Builder) MakeSymlink(src, dest string, opts ...SymlinkOption) *Builder

MakeSymlink creates a symbolic link at dest pointing to src inside the template during build.

func (*Builder) NpmInstall

func (b *Builder) NpmInstall(packages []string, opts ...NpmOption) *Builder

NpmInstall emits a RUN that installs Node packages via npm. Nil/empty packages produce a bare "npm install" (install dependencies from package.json).

func (*Builder) PipInstall

func (b *Builder) PipInstall(packages []string, opts ...PipOption) *Builder

PipInstall emits a RUN that installs Python packages via pip. With a nil or empty packages slice it falls back to "pip install ." (install current directory). The default user is root; WithPipUserInstall clears that and appends --user.

func (*Builder) ReadyCmdString

func (b *Builder) ReadyCmdString() string

ReadyCmdString returns the configured readiness command.

func (*Builder) Remove

func (b *Builder) Remove(paths []string, opts ...RemoveOption) *Builder

Remove deletes files or directories inside the template during build.

func (*Builder) Rename

func (b *Builder) Rename(src, dest string, opts ...RenameOption) *Builder

Rename moves src to dest inside the template during build.

func (*Builder) Run

func (b *Builder) Run(cmd string) *Builder

Run adds a RUN instruction.

func (*Builder) RunCmd

func (b *Builder) RunCmd(cmd string, opts ...RunOption) *Builder

RunCmd appends a RUN instruction for a single shell command, with an optional user selection via WithRunUser.

func (*Builder) RunCmds

func (b *Builder) RunCmds(cmds []string, opts ...RunOption) *Builder

RunCmds joins the commands with " && " and delegates to RunCmd so the server sees a single RUN step.

func (*Builder) SetEnvs

func (b *Builder) SetEnvs(envs map[string]string) *Builder

SetEnvs emits a single ENV instruction whose Args interleave keys and values (k1, v1, k2, v2, ...). An empty or nil map is a no-op.

func (*Builder) SetReadyCmd

func (b *Builder) SetReadyCmd(ready ReadyCmd) *FinalBuilder

SetReadyCmd sets only the readiness check and finalizes the builder.

func (*Builder) SetStartCmd

func (b *Builder) SetStartCmd(cmd string, ready ReadyCmd) *FinalBuilder

SetStartCmd records the command run when a sandbox boots, plus the readiness check to wait on. Pass ReadyCmd{} to opt out of a readiness check.

func (*Builder) SetTag

func (b *Builder) SetTag(tag string) *Builder

SetTag tags the final template (e.g. "my-template:v2").

func (*Builder) SetUser

func (b *Builder) SetUser(user string) *Builder

SetUser emits a USER instruction that switches the default build user.

func (*Builder) SetWorkdir

func (b *Builder) SetWorkdir(path string) *Builder

SetWorkdir emits a WORKDIR instruction with the given path.

func (*Builder) SkipCache

func (b *Builder) SkipCache() *Builder

SkipCache marks the next instruction as force-rebuilt, ignoring the upstream cache. Chain before any instruction to invalidate just that layer; the flag resets after the next instruction is added.

func (*Builder) StartCmd

func (b *Builder) StartCmd() string

StartCmd returns the configured start command.

func (*Builder) Tag

func (b *Builder) Tag() string

Tag returns the tag associated with this template build.

func (*Builder) ToDockerfile

func (b *Builder) ToDockerfile() (string, error)

ToDockerfile serializes the builder to a Dockerfile. Templates based on another E2B template cannot be serialized and return an error.

func (*Builder) ToJSON

func (b *Builder) ToJSON() (string, error)

ToJSON returns the JSON payload that Client.Build would send to the server, pretty-printed. Useful for inspection and debugging.

func (*Builder) WithContext

func (b *Builder) WithContext(dir string) *Builder

WithContext sets the local directory used as the build context for COPY instructions. Subsequent COPY hashing and tar packaging reads files under this path.

func (*Builder) WithIgnore

func (b *Builder) WithIgnore(patterns ...string) *Builder

WithIgnore appends patterns (in .dockerignore syntax) that filter files during COPY hashing and tar packaging.

func (*Builder) Workdir

func (b *Builder) Workdir(path string) *Builder

Workdir sets the working directory. It records a WORKDIR instruction and persists the value for later fluent calls.

type BunOption

type BunOption func(*bunOpts)

BunOption configures Builder.BunInstall.

func WithBunDev

func WithBunDev() BunOption

WithBunDev appends --dev to the bun invocation (bun's equivalent of npm's --save-dev).

func WithBunGlobal

func WithBunGlobal() BunOption

WithBunGlobal appends -g to the bun invocation and sets the user to root.

type Client

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

Client is a server-side template builder/inspector. Methods on Client dispatch to the E2B template HTTP API. Safe for concurrent use.

func NewClient

func NewClient(cfg e2b.Config) (*Client, error)

NewClient constructs a Client from a Config, applying environment-variable fallbacks. Fails only when the API URL is malformed.

func (*Client) AssignTags

func (c *Client) AssignTags(ctx context.Context, target string, tags []string) (*TagInfo, error)

AssignTags assigns one or more tags to an existing template build.

func (*Client) Build

func (c *Client) Build(ctx context.Context, b *Builder, opts BuildOptions) (*BuildInfo, error)

Build runs a server-side template build to completion. Logs are discarded; for streaming use BuildStream. Returns the completed BuildInfo or the first error that terminates the build.

func (*Client) BuildInBackground

func (c *Client) BuildInBackground(ctx context.Context, b *Builder, opts BuildOptions) (*BuildInfo, error)

BuildInBackground kicks off a build without polling for completion. The caller can poll via GetBuildStatus using the returned BuildInfo.

func (*Client) BuildInBackgroundV2

func (c *Client) BuildInBackgroundV2(ctx context.Context, b *Builder, opts BuildOptions) (*BuildInfo, error)

BuildInBackgroundV2 is the POST /v2/templates counterpart of BuildInBackground.

func (*Client) BuildStream

func (c *Client) BuildStream(ctx context.Context, b *Builder, opts BuildOptions) (<-chan BuildEvent, error)

BuildStream kicks off a build and returns a channel of BuildEvents. The channel closes after emitting a terminal Done or Err event.

func (*Client) BuildStreamV2

func (c *Client) BuildStreamV2(ctx context.Context, b *Builder, opts BuildOptions) (<-chan BuildEvent, error)

BuildStreamV2 is the POST /v2/templates counterpart of BuildStream.

func (*Client) BuildV2

func (c *Client) BuildV2(ctx context.Context, b *Builder, opts BuildOptions) (*BuildInfo, error)

BuildV2 is the POST /v2/templates counterpart of Build, intended for self-hosted E2B deployments that predate /v3/templates (≤ 2.1.x). The v2 request body has no tags field; BuildOptions.Tags must be empty.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, templateID string) error

Delete removes a template by ID.

func (*Client) Exists

func (c *Client) Exists(ctx context.Context, alias string) (bool, error)

Exists returns true if a template with the given alias exists and the caller can see it (200 or 403). 404 means it does not exist; other non-2xx status codes are returned as errors.

func (*Client) Get

func (c *Client) Get(ctx context.Context, templateID string, opts GetOptions) (*TemplateDetail, error)

Get returns metadata and one page of build history for a single template.

func (*Client) GetBuildLogs

func (c *Client) GetBuildLogs(ctx context.Context, templateID, buildID string, opts BuildLogsOptions) ([]LogEntry, error)

GetBuildLogs fetches structured build logs for a specific build.

func (*Client) GetBuildStatus

func (c *Client) GetBuildStatus(ctx context.Context, info BuildInfo, logsOffset int) (*BuildStatus, error)

GetBuildStatus fetches the current status of an in-flight build.

func (*Client) GetTags

func (c *Client) GetTags(ctx context.Context, templateID string) ([]TemplateTag, error)

GetTags returns every tag associated with a template.

func (*Client) List

func (c *Client) List(ctx context.Context, opts ListOptions) ([]Template, error)

List returns every template visible to the caller. Pass opts.TeamID to restrict the result to a specific team.

func (*Client) RemoveTags

func (c *Client) RemoveTags(ctx context.Context, name string, tags []string) error

RemoveTags removes one or more tags from a template.

func (*Client) SetPublic

func (c *Client) SetPublic(ctx context.Context, templateID string, public bool) ([]string, error)

SetPublic toggles the template's public visibility flag via PATCH /v2/templates/{id}. Returns the current names (namespace/alias format when namespaced).

func (*Client) SetPublicV1

func (c *Client) SetPublicV1(ctx context.Context, templateID string, public bool) error

SetPublicV1 is the PATCH /templates/{id} counterpart of SetPublic for self-hosted E2B deployments that predate /v2/templates/{id} (≤ 2.1.x). The legacy endpoint has no response body, so no names are returned.

type CopyItem

type CopyItem struct {
	Src             string
	Dest            string
	User            string
	Mode            os.FileMode
	ForceUpload     bool
	ResolveSymlinks *bool
}

CopyItem mirrors the Python SDK's CopyItem dict. All fields except Src and Dest are optional.

type CopyOption

type CopyOption func(*copyOpts)

CopyOption is a functional option for Copy.

func WithCopyForceUpload

func WithCopyForceUpload() CopyOption

WithCopyForceUpload forces re-upload of the COPY layer even when a matching hash already exists on the server.

func WithCopyMode

func WithCopyMode(m os.FileMode) CopyOption

WithCopyMode sets the file mode applied to the copied files.

func WithCopyResolveSymlinks(b bool) CopyOption

WithCopyResolveSymlinks overrides the default symlink resolution behavior for this COPY. Pass true to follow symlinks, false to preserve them.

func WithCopyUser

func WithCopyUser(u string) CopyOption

WithCopyUser sets the owning user for the copied files (USER arg of COPY).

type FinalBuilder

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

FinalBuilder is the terminal state of the fluent API. After setting the start/ready commands, callers may only serialize or hand off to the Client.

func (*FinalBuilder) Builder

func (f *FinalBuilder) Builder() *Builder

Builder returns the underlying *Builder. Use sparingly; the point of FinalBuilder is to discourage adding more instructions. Required by the Client so it can call serialize/instructionsWithHashes.

func (*FinalBuilder) ToDockerfile

func (f *FinalBuilder) ToDockerfile() (string, error)

ToDockerfile delegates to the underlying Builder.

func (*FinalBuilder) ToJSON

func (f *FinalBuilder) ToJSON() (string, error)

ToJSON delegates to the underlying Builder.

type GetOptions

type GetOptions struct {
	NextToken string
	Limit     int32
}

GetOptions paginates the build history returned by Client.Get. Zero value uses server defaults.

type GitCloneOption

type GitCloneOption func(*gitOpts)

GitCloneOption configures Builder.GitClone.

func WithGitBranch

func WithGitBranch(branch string) GitCloneOption

WithGitBranch checks out the given branch via --branch + --single-branch.

func WithGitDepth

func WithGitDepth(depth int) GitCloneOption

WithGitDepth sets the clone depth (shallow clone when > 0).

func WithGitPath

func WithGitPath(path string) GitCloneOption

WithGitPath clones into the given local path.

func WithGitUser

func WithGitUser(user string) GitCloneOption

WithGitUser runs the git clone command as the given user.

type ListOptions

type ListOptions struct {
	// TeamID restricts results to a specific team. Empty means no filter.
	TeamID string
}

ListOptions filters Client.List results. Zero value lists every template visible to the caller.

type LogEntry

type LogEntry struct {
	Level     LogLevel
	Message   string
	Timestamp time.Time
}

LogEntry is one structured line from a template build.

type LogEntryEnd

type LogEntryEnd struct {
	Phase string
	OK    bool
}

LogEntryEnd marks the end of a build phase.

type LogEntryStart

type LogEntryStart struct {
	Phase string
}

LogEntryStart marks the beginning of a build phase.

type LogLevel

type LogLevel string

LogLevel mirrors the upstream log severity enum.

const (
	LogLevelDebug LogLevel = "debug"
	LogLevelInfo  LogLevel = "info"
	LogLevelWarn  LogLevel = "warn"
	LogLevelError LogLevel = "error"
)

type MkdirOption

type MkdirOption func(*mkdirOpts)

MkdirOption configures Builder.MakeDir.

func WithMkdirMode

func WithMkdirMode(m os.FileMode) MkdirOption

WithMkdirMode sets the mode bits passed to mkdir via -m.

func WithMkdirUser

func WithMkdirUser(u string) MkdirOption

WithMkdirUser runs the mkdir command as the given user.

type NpmOption

type NpmOption func(*npmOpts)

NpmOption configures Builder.NpmInstall.

func WithNpmDev

func WithNpmDev() NpmOption

WithNpmDev appends --save-dev to the npm invocation.

func WithNpmGlobal

func WithNpmGlobal() NpmOption

WithNpmGlobal appends -g to the npm invocation and sets the user to root.

type PipOption

type PipOption func(*pipOpts)

PipOption configures Builder.PipInstall.

func WithPipUserInstall

func WithPipUserInstall() PipOption

WithPipUserInstall appends --user to the pip invocation and clears the default user (so the command does not force root).

type ReadyCmd

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

ReadyCmd wraps a shell command evaluated by envd to decide when the sandbox has finished starting.

func WaitForFile

func WaitForFile(path string) ReadyCmd

WaitForFile checks for the existence of a file.

func WaitForPort

func WaitForPort(port int) ReadyCmd

WaitForPort checks whether the given TCP port is listening.

func WaitForProcess

func WaitForProcess(name string) ReadyCmd

WaitForProcess checks whether a process with the given name is running.

func WaitForTimeoutMs

func WaitForTimeoutMs(ms int) ReadyCmd

WaitForTimeoutMs sleeps for the given number of milliseconds (rounded up to at least 1 second).

func WaitForURL

func WaitForURL(url string, statusCode int) ReadyCmd

WaitForURL polls an HTTP endpoint until it returns the expected status code.

func (ReadyCmd) Cmd

func (r ReadyCmd) Cmd() string

Cmd returns the underlying shell snippet.

type RegistryCredentials

type RegistryCredentials struct {
	Username string
	Password string
}

RegistryCredentials carries basic-auth credentials for a private registry.

type RemoveOption

type RemoveOption func(*removeOpts)

RemoveOption configures Builder.Remove.

func WithRemoveForce

func WithRemoveForce() RemoveOption

WithRemoveForce adds -f to the emitted rm command.

func WithRemoveRecursive

func WithRemoveRecursive() RemoveOption

WithRemoveRecursive adds -r to the emitted rm command.

func WithRemoveUser

func WithRemoveUser(u string) RemoveOption

WithRemoveUser runs the rm command as the given user.

type RenameOption

type RenameOption func(*renameOpts)

RenameOption configures Builder.Rename.

func WithRenameForce

func WithRenameForce() RenameOption

WithRenameForce adds -f to the emitted mv command.

func WithRenameUser

func WithRenameUser(u string) RenameOption

WithRenameUser runs the mv command as the given user.

type RunOption

type RunOption func(*runOpts)

RunOption configures Builder.RunCmd and Builder.RunCmds.

func WithRunUser

func WithRunUser(u string) RunOption

WithRunUser runs the command as the given user.

type SymlinkOption

type SymlinkOption func(*symOpts)

SymlinkOption configures Builder.MakeSymlink.

func WithSymlinkForce

func WithSymlinkForce() SymlinkOption

WithSymlinkForce adds -f to the emitted ln command.

func WithSymlinkUser

func WithSymlinkUser(u string) SymlinkOption

WithSymlinkUser runs the ln command as the given user.

type TagInfo

type TagInfo struct {
	BuildID string
	Tags    []string
}

TagInfo is returned from Client.AssignTags.

type Template

type Template struct {
	TemplateID    string
	BuildID       string
	Names         []string
	Public        bool
	CPUCount      int32
	MemoryMB      int32
	DiskSizeMB    int32
	EnvdVersion   string
	BuildStatus   BuildStatusValue
	BuildCount    int32
	SpawnCount    int64
	CreatedAt     time.Time
	UpdatedAt     time.Time
	LastSpawnedAt *time.Time
	CreatedBy     *TemplateUser
}

Template is a single row returned from Client.List and the summary portion of Client.Get. Mirrors the upstream Template schema but keeps internal API types private.

type TemplateBuild

type TemplateBuild struct {
	BuildID     string
	Status      BuildStatusValue
	CPUCount    int32
	MemoryMB    int32
	DiskSizeMB  *int32
	EnvdVersion string
	CreatedAt   time.Time
	UpdatedAt   time.Time
	FinishedAt  *time.Time
}

TemplateBuild is one historical build entry returned inside TemplateDetail.

type TemplateDetail

type TemplateDetail struct {
	TemplateID    string
	Names         []string
	Public        bool
	SpawnCount    int64
	CreatedAt     time.Time
	UpdatedAt     time.Time
	LastSpawnedAt *time.Time
	Builds        []TemplateBuild
}

TemplateDetail is the response from Client.Get: template identity plus one page of its build history. Per-build resource settings live on each TemplateBuild entry because they can differ across builds.

type TemplateTag

type TemplateTag struct {
	Tag       string
	BuildID   string
	CreatedAt time.Time
}

TemplateTag is one row returned from Client.GetTags.

type TemplateUser

type TemplateUser struct {
	ID    string
	Email string
}

TemplateUser identifies the creator of a template.

type UploadError

type UploadError struct {
	Src, Hash string
	Err       error
}

UploadError describes a failure while uploading a template COPY layer.

func (*UploadError) Error

func (e *UploadError) Error() string

func (*UploadError) Unwrap

func (e *UploadError) Unwrap() error

Jump to

Keyboard shortcuts

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