Documentation
¶
Index ¶
- type Client
- func (c *Client) CreateSandbox(ctx context.Context, cfg SandboxConfig) (*Sandbox, error)
- func (c *Client) CreateSnapshot(ctx context.Context, id string, name string) (*SnapshotInfo, error)
- func (c *Client) DestroySandbox(ctx context.Context, id string) error
- func (c *Client) Exec(ctx context.Context, id string, opts ExecOpts) (*ExecResult, error)
- func (c *Client) GetSandbox(ctx context.Context, id string) (*Sandbox, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) ListSandboxes(ctx context.Context) ([]Sandbox, error)
- func (c *Client) ReadFile(ctx context.Context, id string, path string) ([]byte, error)
- func (c *Client) RestoreSnapshot(ctx context.Context, snapshotID string) (*Sandbox, error)
- func (c *Client) StopSandbox(ctx context.Context, id string) error
- func (c *Client) WriteFile(ctx context.Context, id string, path string, content []byte) error
- type ExecOpts
- type ExecResult
- type Option
- type PortMapping
- type S3SyncConfig
- type Sandbox
- type SandboxConfig
- type SnapshotInfo
- type StorageConfig
- type TmpfsMount
- type VolumeMount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Go client for the Den API.
func (*Client) CreateSandbox ¶
CreateSandbox creates a new sandbox.
func (*Client) CreateSnapshot ¶
CreateSnapshot creates a snapshot of a sandbox.
func (*Client) DestroySandbox ¶
DestroySandbox removes a sandbox.
func (*Client) GetSandbox ¶
GetSandbox returns a sandbox by ID.
func (*Client) ListSandboxes ¶
ListSandboxes returns all sandboxes.
func (*Client) RestoreSnapshot ¶
RestoreSnapshot restores a sandbox from a snapshot.
func (*Client) StopSandbox ¶
StopSandbox stops a sandbox.
type ExecOpts ¶
type ExecOpts struct {
Cmd []string `json:"cmd"`
Env map[string]string `json:"env,omitempty"`
WorkDir string `json:"workdir,omitempty"`
Timeout int `json:"timeout,omitempty"` // seconds
}
ExecOpts holds options for command execution.
type ExecResult ¶
type ExecResult struct {
ExitCode int `json:"exit_code"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}
ExecResult holds the result of command execution.
type Option ¶
type Option func(*Client)
Option configures the Client.
func WithAPIKey ¶
WithAPIKey sets the API key for authentication.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client.
type PortMapping ¶ added in v0.0.3
type PortMapping struct {
SandboxPort int `json:"sandbox_port"`
HostPort int `json:"host_port"`
Protocol string `json:"protocol,omitempty"`
}
PortMapping defines a port forwarding between host and sandbox.
type S3SyncConfig ¶ added in v0.0.3
type S3SyncConfig struct {
Endpoint string `json:"endpoint,omitempty"`
Bucket string `json:"bucket"`
Prefix string `json:"prefix,omitempty"`
Region string `json:"region,omitempty"`
AccessKey string `json:"access_key,omitempty"`
SecretKey string `json:"secret_key,omitempty"`
Mode string `json:"mode"`
MountPath string `json:"mount_path,omitempty"`
SyncPath string `json:"sync_path,omitempty"`
}
S3SyncConfig holds S3 synchronization settings for a sandbox.
type Sandbox ¶
type Sandbox struct {
ID string `json:"id"`
Image string `json:"image"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
}
Sandbox represents a sandbox instance.
type SandboxConfig ¶
type SandboxConfig struct {
Image string `json:"image,omitempty"`
Env map[string]string `json:"env,omitempty"`
WorkDir string `json:"workdir,omitempty"`
Timeout int `json:"timeout,omitempty"` // seconds
CPU int64 `json:"cpu,omitempty"` // NanoCPUs (1e9 = 1 core)
Memory int64 `json:"memory,omitempty"` // bytes
PidLimit int64 `json:"pid_limit,omitempty"`
Ports []PortMapping `json:"ports,omitempty"`
Storage *StorageConfig `json:"storage,omitempty"`
}
SandboxConfig holds sandbox creation options.
type SnapshotInfo ¶
type SnapshotInfo struct {
ID string `json:"id"`
SandboxID string `json:"sandbox_id"`
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
}
SnapshotInfo holds snapshot metadata.
type StorageConfig ¶ added in v0.0.3
type StorageConfig struct {
Volumes []VolumeMount `json:"volumes,omitempty"`
Tmpfs []TmpfsMount `json:"tmpfs,omitempty"`
S3 *S3SyncConfig `json:"s3,omitempty"`
}
StorageConfig holds storage settings for a sandbox.
type TmpfsMount ¶ added in v0.0.3
type TmpfsMount struct {
Path string `json:"path"`
Size string `json:"size"`
Options string `json:"options,omitempty"`
}
TmpfsMount defines a tmpfs filesystem to mount inside a sandbox.
type VolumeMount ¶ added in v0.0.3
type VolumeMount struct {
Name string `json:"name"`
MountPath string `json:"mount_path"`
ReadOnly bool `json:"read_only,omitempty"`
}
VolumeMount defines a named volume to mount into a sandbox.