driver

package
v1.9.0-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

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 DockerDriver

type DockerDriver 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)

	// RunDockerDevContainer runs a docker devcontainer
	RunDockerDevContainer(ctx context.Context, params *RunDockerDevContainerParams) 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

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

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

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

	// RunDevContainer runs a devcontainer
	RunDevContainer(ctx context.Context, workspaceID string, options *RunOptions) 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 MountCapableDriver

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 {
	Driver

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

type RunDockerDevContainerParams

type RunDockerDevContainerParams 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 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

Jump to

Keyboard shortcuts

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