Documentation
¶
Index ¶
- func CopyFile(src, dst string, perm os.FileMode) error
- func InferOwner(user string) string
- func InferRemoteHome(user string) string
- func ShellQuote(s string) string
- func ShellQuoteJoin(args []string) string
- type BasePlugin
- type ExecFunc
- type FileCopy
- type Manager
- type Plugin
- type PostContainerCreateRequest
- type PostContainerCreateResponse
- type PreContainerRunRequest
- type PreContainerRunResponse
- type StreamExecFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFile ¶
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 ¶
InferOwner returns the container user for chown operations. Empty user maps to "root", otherwise returns the user as-is.
func InferRemoteHome ¶
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.
func ShellQuote ¶ added in v0.7.1
ShellQuote escapes single quotes in s for safe embedding in single-quoted shell strings. The result is the inner content, not the outer quotes.
func ShellQuoteJoin ¶ added in v0.7.1
ShellQuoteJoin single-quotes each argument and joins them with spaces, producing a shell-safe command string. Arguments with spaces, single quotes, or metacharacters are preserved as single tokens.
Types ¶
type BasePlugin ¶ added in v0.8.0
type BasePlugin struct{}
BasePlugin provides no-op implementations of optional Plugin methods. Embed it in plugin structs to satisfy the interface without boilerplate.
func (BasePlugin) PostContainerCreate ¶ added in v0.8.0
func (BasePlugin) PostContainerCreate(_ context.Context, _ *PostContainerCreateRequest) (*PostContainerCreateResponse, error)
PostContainerCreate is a no-op. Override in plugins that need post-creation logic.
func (BasePlugin) PreContainerRun ¶ added in v0.8.0
func (BasePlugin) PreContainerRun(_ context.Context, _ *PreContainerRunRequest) (*PreContainerRunResponse, error)
PreContainerRun is a no-op. Override in plugins that need pre-run logic.
type ExecFunc ¶ added in v0.8.0
ExecFunc runs a command inside the container. Returns combined output and error.
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 ¶
NewManager creates a Manager with the given logger.
func (*Manager) RunPostContainerCreate ¶ added in v0.8.0
func (m *Manager) RunPostContainerCreate(ctx context.Context, req *PostContainerCreateRequest)
RunPostContainerCreate dispatches the post-container-create event to all registered plugins. Called between create-time hooks (postCreateCommand) and start-time hooks (postStartCommand). Errors are logged and skipped (fail-open).
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
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)
PostContainerCreate(ctx context.Context, req *PostContainerCreateRequest) (*PostContainerCreateResponse, error)
}
Plugin is the interface all plugins implement.
type PostContainerCreateRequest ¶ added in v0.8.0
type PostContainerCreateRequest struct {
WorkspaceID string
WorkspaceDir string
ContainerID string
RemoteUser string
WorkspaceFolder string
Exec ExecFunc
StreamExec StreamExecFunc
}
PostContainerCreateRequest provides context for post-creation hooks. Plugins that need to run commands inside the container (e.g. dotfiles installation) use the Exec callback (captured) or StreamExec (streamed).
type PostContainerCreateResponse ¶ added in v0.8.0
type PostContainerCreateResponse struct{}
PostContainerCreateResponse carries results from post-creation hooks. Empty for now, keeps the interface consistent with PreContainerRun.
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.