plugin

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string, perm os.FileMode) error

CopyFile copies a single file from src to dst with the given permissions. Shared by plugins that stage host files into workspace state directories.

func InferOwner

func InferOwner(user string) string

InferOwner returns the container user for chown operations. Empty user maps to "root", otherwise returns the user as-is.

func InferRemoteHome

func InferRemoteHome(user string) string

InferRemoteHome returns the home directory path for the given user inside the container. Root or empty user maps to /root, others to /home/{user}. Used by plugins that need to place files in the container user's home before the container exists.

Types

type FileCopy

type FileCopy struct {
	Source      string // path on host
	Target      string // path inside container
	Mode        string // chmod mode (e.g. "0600"), empty for default
	User        string // chown user inside container (e.g. "vscode"), empty for default
	IfNotExists bool   // skip copy if the target file already exists in the container
}

FileCopy describes a file to copy into the container after creation.

type Manager

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

Manager holds registered plugins and dispatches events to them.

func NewManager

func NewManager(logger *slog.Logger) *Manager

NewManager creates a Manager with the given logger.

func (*Manager) Register

func (m *Manager) Register(p Plugin)

Register adds a plugin to the manager.

func (*Manager) RunPreContainerRun

func (m *Manager) RunPreContainerRun(ctx context.Context, req *PreContainerRunRequest) (*PreContainerRunResponse, error)

RunPreContainerRun dispatches the pre-container-run event to all registered plugins and merges their responses. Mounts and RunArgs are appended in plugin order. Env vars are merged with last-plugin-wins on conflicts. Plugin errors are logged and skipped (fail-open).

func (*Manager) SetProgress added in v0.5.0

func (m *Manager) SetProgress(fn func(string))

SetProgress sets a callback for user-facing progress messages (e.g. "Running plugin: foo").

type Plugin

type Plugin interface {
	Name() string
	PreContainerRun(ctx context.Context, req *PreContainerRunRequest) (*PreContainerRunResponse, error)
}

Plugin is the interface all plugins implement.

type PreContainerRunRequest

type PreContainerRunRequest struct {
	WorkspaceID     string         // unique workspace identifier
	WorkspaceDir    string         // ~/.crib/workspaces/{id}/
	SourceDir       string         // project root on host
	Runtime         string         // "docker" or "podman"
	ImageName       string         // resolved image name
	RemoteUser      string         // user inside the container
	WorkspaceFolder string         // path inside container
	ContainerName   string         // crib-{workspace-id}
	Customizations  map[string]any // customizations.crib from devcontainer.json
}

PreContainerRunRequest carries context about the workspace and container that is about to be created. Plugins use this to decide what mounts, env vars, or extra args to inject.

type PreContainerRunResponse

type PreContainerRunResponse struct {
	Mounts      []config.Mount
	Env         map[string]string
	RunArgs     []string
	Copies      []FileCopy
	PathPrepend []string // absolute paths to prepend to PATH in remoteEnv
}

PreContainerRunResponse carries additions that the plugin wants injected into the container run command. Nil means no-op.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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