Create(WithTemplate("my-template")) to boot sandboxes that start from a known state.
TemplateSpec
TemplateSpec defines how to build a sandbox template.
CopyItem
declaw.BuildTemplate()
Build a new template and wait for the build to complete. Builds usually take
several minutes; bound the wait with ctx.
(*BuildInfo, error). On success Status is declaw.BuildStatusCompleted.
A failed build returns a *BuildError whose message quotes the end of the build
output and whose Logs holds all of it. If ctx ends first, the error is
ctx.Err() and the returned BuildInfo still carries the BuildID: the build
keeps running, and GetBuildStatus or WaitForBuild follows it. Status checks
that fail temporarily (5xx, 429, no response) are retried for up to two minutes.
declaw.WaitForBuild()
Wait for a build started with BuildTemplateBackground to finish, passing each new
line of build output to a callback. It returns like BuildTemplate.
... [earlier build output truncated] line marks the gap.
Returns (*BuildInfo, error)
declaw.BuildTemplateBackground()
Start a template build and return immediately without waiting for completion.
(*BuildInfo, error) with Status declaw.BuildStatusBuilding.
declaw.RebuildTemplate()
Needs
github.com/declaw-ai/declaw-go v0.8.0 or later. Upgrade with
go get github.com/declaw-ai/declaw-go@latest.BuildTemplate. The rebuild reuses the template’s stored spec.
*ConflictError. A failed template keeps its
alias: BuildTemplate with the same alias is refused with a *ConflictError
whose message names the template to rebuild.
Returns (*BuildInfo, error) — the completed build, a *BuildError for a
failed one, or ctx’s error once ctx ends (the build keeps running).
declaw.RebuildTemplateBackground()
Queue a rebuild of a failed template and return as soon as the server has
accepted it, with status building. Follow it with WaitForBuild or
GetBuildStatus.
(*BuildInfo, error)
declaw.GetBuildStatus()
Poll the status of a background build.
(*BuildInfo, error)
declaw.ListTemplates()
List all templates owned by the caller.
([]TemplateInfo, error)
declaw.GetTemplate()
Get information about a specific template.
(*TemplateInfo, error)
declaw.DeleteTemplate()
Delete a template by its ID.
error