ns

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatEnv

func FormatEnv(base []string, brokerSock, shimPath string) []string

FormatEnv builds the environment slice for the child process, injecting machineproxy-specific variables needed by the shim.

Types

type Deps

type Deps struct {
	// LookPath resolves the bwrap binary. Defaults to exec.LookPath.
	LookPath func(file string) (string, error)
	Log      *slog.Logger
}

Deps allows dependency injection for testing.

type Namespace

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

Namespace builds and executes a bubblewrap (bwrap) sandbox that bind-mounts the host filesystem and overlays a FUSE-backed workspace.

func New

func New(deps Deps) *Namespace

New creates a Namespace. Call Prepare before Run.

func (*Namespace) Command

func (n *Namespace) Command(fuseMountDir, containerPath, workingDir string, cmdline []string) (string, []string)

Command returns the bwrap binary path and full argument list without executing anything. Useful for inspection and testing.

func (*Namespace) Leave

func (n *Namespace) Leave()

Leave is a no-op retained for interface compatibility. Bwrap cleans up its own namespaces on exit.

func (*Namespace) Prepare

func (n *Namespace) Prepare(ctx context.Context) error

Prepare locates the bwrap binary. Must be called before Run.

func (*Namespace) Run

func (n *Namespace) Run(ctx context.Context, fuseMountDir, containerPath, workingDir string, cmdline []string, env []string) error

Run executes cmdline inside a bwrap sandbox. The host root is bind-mounted read-write, and fuseMountDir is bound over containerPath so the FUSE workspace is visible at the expected location. workingDir sets the initial working directory inside the container.

Jump to

Keyboard shortcuts

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