sandbox

package
v0.0.0-...-dac86b4 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package sandbox provides Docker-based sandboxed execution for CI/CD pipeline steps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DockerSandbox

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

DockerSandbox wraps the Docker Engine SDK to execute commands in isolated containers.

func NewDockerSandbox

func NewDockerSandbox(config SandboxConfig) (*DockerSandbox, error)

NewDockerSandbox creates a new DockerSandbox with the given configuration. It initializes a Docker client using environment variables (DOCKER_HOST, etc.).

func (*DockerSandbox) Close

func (s *DockerSandbox) Close() error

Close cleans up the Docker client.

func (*DockerSandbox) CopyIn

func (s *DockerSandbox) CopyIn(ctx context.Context, srcPath, destPath string) error

CopyIn copies a file from the host into a running or created container.

func (*DockerSandbox) CopyOut

func (s *DockerSandbox) CopyOut(ctx context.Context, srcPath string) (io.ReadCloser, error)

CopyOut copies a file out of a container. Returns a ReadCloser with the file contents.

func (*DockerSandbox) Exec

func (s *DockerSandbox) Exec(ctx context.Context, cmd []string) (*ExecResult, error)

Exec creates a container, runs the given command, captures output, and removes the container.

func (*DockerSandbox) ExecInContainer

func (s *DockerSandbox) ExecInContainer(ctx context.Context, cmd []string, copyIn map[string]string, copyOutPaths []string) (*ExecResult, map[string]io.ReadCloser, error)

ExecInContainer creates a container, copies files in, runs the command, and allows file extraction. This is the higher-level API that manages the full container lifecycle with file I/O.

type ExecResult

type ExecResult struct {
	ExitCode int
	Stdout   string
	Stderr   string
}

ExecResult holds the output from a command execution inside the sandbox.

type Mount

type Mount struct {
	Source   string `yaml:"source"`
	Target   string `yaml:"target"`
	ReadOnly bool   `yaml:"read_only"`
}

Mount describes a bind mount from host to container.

type SandboxConfig

type SandboxConfig struct {
	Image       string            `yaml:"image"`
	WorkDir     string            `yaml:"work_dir"`
	Env         map[string]string `yaml:"env"`
	Mounts      []Mount           `yaml:"mounts"`
	MemoryLimit int64             `yaml:"memory_limit"`
	CPULimit    float64           `yaml:"cpu_limit"`
	Timeout     time.Duration     `yaml:"timeout"`
	NetworkMode string            `yaml:"network_mode"`
}

SandboxConfig holds configuration for a Docker sandbox execution environment.

Jump to

Keyboard shortcuts

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