driver

package
v1.9.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MountTypeBind   = "bind"
	MountTypeVolume = "volume"
	MountTypeTmpfs  = "tmpfs"
)

Variables

This section is empty.

Functions

func DriverSupportsMountType added in v1.10.0

func DriverSupportsMountType(d Driver, mountType string) bool

DriverSupportsMountType reports whether the driver can honor mountType, defaulting to true for drivers that do not advertise the capability.

Types

type BuildRequest

type BuildRequest struct {
	PrebuildHash         string
	ParsedConfig         *config.SubstitutedConfig
	ExtendedBuildInfo    *feature.ExtendedBuildInfo
	DockerfilePath       string
	DockerfileContent    string
	LocalWorkspaceFolder string
	Options              provider.BuildOptions
}

type CommandParams added in v1.3.1

type CommandParams struct {
	WorkspaceID string
	User        string
	Command     string
	Stdin       io.Reader
	Stdout      io.Writer
	Stderr      io.Writer
}

CommandParams holds the parameters for running a command inside a devcontainer.

type ComposeDriver added in v1.10.0

type ComposeDriver interface {
	Driver

	// ComposeHelper returns the compose helper
	ComposeHelper() (*compose.ComposeHelper, error)
}

ComposeDriver is a capability interface implemented by drivers that can run docker-compose based devcontainers. Not every container runtime has a compose engine (e.g. Apple's `container`), so callers detect support via a type assertion rather than forcing every driver to stub the method.

type DockerHelperProvider added in v1.10.0

type DockerHelperProvider interface {
	Driver

	// DockerHelper returns the docker helper
	DockerHelper() (*docker.DockerHelper, error)
}

DockerHelperProvider is a capability interface implemented by drivers backed by a Docker-compatible CLI that can expose the low-level *docker.DockerHelper. Runtimes without one (e.g. the Apple driver) simply do not implement it.

type Driver

type Driver interface {
	// FindDevContainer returns a running devcontainer details
	FindDevContainer(ctx context.Context, workspaceID string) (*config.ContainerDetails, error)

	// CommandDevContainer runs the given command inside the devcontainer
	CommandDevContainer(ctx context.Context, params *CommandParams) error

	// TargetArchitecture returns the architecture of the container runtime. e.g. amd64 or arm64
	TargetArchitecture(ctx context.Context, workspaceID string) (string, error)

	// DeleteDevContainer deletes the devcontainer
	DeleteDevContainer(ctx context.Context, workspaceID string) error

	// StartDevContainer starts the devcontainer
	StartDevContainer(ctx context.Context, workspaceID string) error

	// StopDevContainer stops the devcontainer
	StopDevContainer(ctx context.Context, workspaceID string) error

	// GetContainerLogs returns the logs of the devcontainer
	GetDevContainerLogs(
		ctx context.Context,
		workspaceID string,
		stdout io.Writer,
		stderr io.Writer,
	) error
}

Driver is the default interface for Devsy drivers.

type ImageDriver added in v1.10.0

type ImageDriver interface {
	Driver

	// InspectImage inspects the given image name
	InspectImage(ctx context.Context, imageName string) (*config.ImageDetails, error)

	// GetImageTag returns latest tag for input image id
	GetImageTag(ctx context.Context, imageName string) (string, error)

	// RunImageDevContainer runs an image-based devcontainer
	RunImageDevContainer(ctx context.Context, params *RunImageDevContainerParams) error

	// BuildDevContainer builds a devcontainer
	BuildDevContainer(ctx context.Context, req BuildRequest) (*config.BuildInfo, error)

	// PushDevContainer pushes the given image to a registry
	PushDevContainer(ctx context.Context, image string) error

	// TagDevContainer tags the given image with the given tag
	TagDevContainer(ctx context.Context, image, tag string) error

	// UpdateContainerUserUID updates the container user UID/GID to match local user
	UpdateContainerUserUID(
		ctx context.Context,
		workspaceId string,
		parsedConfig *config.DevContainerConfig,
		writer io.Writer,
	) error
}

ImageDriver is a capability interface for drivers that build and run a local OCI image directly (e.g. Docker/Podman and Apple's `container`). It is named for the behavior, not a concrete runtime, since multiple runtimes implement it.

type MountCapableDriver added in v1.10.0

type MountCapableDriver interface {
	Driver

	SupportsMountType(mountType string) bool
}

MountCapableDriver is implemented by drivers that can report which mount types they support. Drivers that do not implement it are assumed to support the bind/volume/tmpfs types the docker driver has always handled.

type ReprovisioningDriver

type ReprovisioningDriver interface {
	RunOptionsDriver

	// CanReprovision returns true if the driver can reprovision the devcontainer
	CanReprovision() bool
}

ReprovisioningDriver is a capability interface for drivers that can reprovision an existing devcontainer in place. Reprovisioning re-runs the container, so it embeds RunOptionsDriver.

type RunImageDevContainerParams added in v1.10.0

type RunImageDevContainerParams struct {
	WorkspaceID          string
	Options              *RunOptions
	ParsedConfig         *config.DevContainerConfig
	IDE                  string
	IDEOptions           map[string]config2.OptionValue
	LocalWorkspaceFolder string
	GPUAvailability      string
}

type RunOptions

type RunOptions struct {
	// UID is a unique identifier for this workspace
	UID string `json:"uid,omitempty"`

	// Image is the image to run
	Image string `json:"image,omitempty"`

	// User is the user to run the container as
	User string `json:"user,omitempty"`

	// Entrypoint is the entrypoint of the container
	Entrypoint string `json:"entrypoint,omitempty"`

	// Cmd are the cmd for the entrypoint
	Cmd []string `json:"cmd,omitempty"`

	// Env are additional environment variables to set
	Env map[string]string `json:"env,omitempty"`

	// CapAdd are additional capabilities for the container
	CapAdd []string `json:"capAdd,omitempty"`

	// SecurityOpt are additional security options
	SecurityOpt []string `json:"securityOpt,omitempty"`

	// Labels are labels to set on the container
	Labels []string `json:"labels,omitempty"`

	// Privileged indicates if the container should run with elevated permissions
	Privileged *bool `json:"privileged,omitempty"`

	// Init passes the --init flag when creating the container
	Init *bool `json:"init,omitempty"`

	// WorkspaceMount is the mount where the workspace should get mounted
	WorkspaceMount *config.Mount `json:"workspaceMount,omitempty"`

	// Mounts are additional mounts on the container. Supported are volume and bind mounts.
	// Bind mounts are expected to get copied from local to remote once. Volume mounts are expected
	// to be persisted for the lifetime of the container.
	Mounts []*config.Mount `json:"mounts,omitempty"`

	// Userns is the user namespace to use for the container
	Userns string `json:"userns,omitempty"`

	// UidMap are UID mappings for user namespace
	UidMap []string `json:"uidMap,omitempty"`

	// GidMap are GID mappings for user namespace
	GidMap []string `json:"gidMap,omitempty"`

	// Platform is the target platform (os/arch) to run the container under,
	// e.g. "linux/amd64". Empty means use the host's native platform.
	Platform string `json:"platform,omitempty"`
}

RunOptions are the options for running a container.

type RunOptionsDriver added in v1.10.0

type RunOptionsDriver interface {
	Driver

	// RunDevContainer runs a devcontainer
	RunDevContainer(ctx context.Context, workspaceID string, options *RunOptions) error
}

RunOptionsDriver is a capability interface for drivers that run a devcontainer directly from RunOptions. These drivers delegate container management to an external orchestrator (e.g. a Kubernetes pod or a custom command) rather than building and running a local OCI image; image drivers use ImageDriver instead.

type Streams added in v1.3.1

type Streams struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

Streams bundles the standard IO streams for an exec.

Directories

Path Synopsis
Package apple implements a Devsy driver for Apple's `container` CLI, which runs Linux containers as lightweight VMs on Apple silicon (macOS 26+).
Package apple implements a Devsy driver for Apple's `container` CLI, which runs Linux containers as lightweight VMs on Apple silicon (macOS 26+).

Jump to

Keyboard shortcuts

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