Documentation
¶
Index ¶
- Constants
- func ExtractAndInitializeDevcontainerScripts(logger slog.Logger, expandPath func(string) (string, error), ...) (filteredScripts []codersdk.WorkspaceAgentScript, ...)
- type API
- type DevcontainerCLI
- type DevcontainerCLIUpOptions
- type DockerCLILister
- type DockerEnvInfoer
- type Lister
- type NoopLister
- type Option
- func WithClock(clock quartz.Clock) Option
- func WithDevcontainerCLI(dccli DevcontainerCLI) Option
- func WithDevcontainers(devcontainers []codersdk.WorkspaceAgentDevcontainer) Option
- func WithExecer(execer agentexec.Execer) Option
- func WithLister(cl Lister) Option
- func WithWatcher(w watcher.Watcher) Option
Constants ¶
const ( // DevcontainerLocalFolderLabel is the label that contains the path to // the local workspace folder for a devcontainer. DevcontainerLocalFolderLabel = "devcontainer.local_folder" // DevcontainerConfigFileLabel is the label that contains the path to // the devcontainer.json configuration file. DevcontainerConfigFileLabel = "devcontainer.config_file" )
Variables ¶
This section is empty.
Functions ¶
func ExtractAndInitializeDevcontainerScripts ¶ added in v2.21.0
func ExtractAndInitializeDevcontainerScripts( logger slog.Logger, expandPath func(string) (string, error), devcontainers []codersdk.WorkspaceAgentDevcontainer, scripts []codersdk.WorkspaceAgentScript, ) (filteredScripts []codersdk.WorkspaceAgentScript, devcontainerScripts []codersdk.WorkspaceAgentScript)
ExtractAndInitializeDevcontainerScripts extracts devcontainer scripts from the given scripts and devcontainers. The devcontainer scripts are removed from the returned scripts so that they can be run separately.
Dev Containers have an inherent dependency on start scripts, since they initialize the workspace (e.g. git clone, npm install, etc). This is important if e.g. a Coder module to install @devcontainer/cli is used.
Types ¶
type API ¶ added in v2.22.0
type API struct {
// contains filtered or unexported fields
}
API is responsible for container-related operations in the agent. It provides methods to list and manage containers.
func (*API) SignalReady ¶ added in v2.22.0
func (api *API) SignalReady()
SignalReady signals the API that we are ready to begin watching for file changes. This is used to prime the cache with the current list of containers and to start watching the devcontainer config files for changes. It should be called after the agent ready.
type DevcontainerCLI ¶ added in v2.22.0
type DevcontainerCLI interface {
Up(ctx context.Context, workspaceFolder, configPath string, opts ...DevcontainerCLIUpOptions) (id string, err error)
}
DevcontainerCLI is an interface for the devcontainer CLI.
func NewDevcontainerCLI ¶ added in v2.22.0
func NewDevcontainerCLI(logger slog.Logger, execer agentexec.Execer) DevcontainerCLI
type DevcontainerCLIUpOptions ¶ added in v2.22.0
type DevcontainerCLIUpOptions func(*devcontainerCLIUpConfig)
DevcontainerCLIUpOptions are options for the devcontainer CLI up command.
func WithRemoveExistingContainer ¶ added in v2.22.0
func WithRemoveExistingContainer() DevcontainerCLIUpOptions
WithRemoveExistingContainer is an option to remove the existing container.
type DockerCLILister ¶
type DockerCLILister struct {
// contains filtered or unexported fields
}
DockerCLILister is a ContainerLister that lists containers using the docker CLI
func (*DockerCLILister) List ¶
func (dcl *DockerCLILister) List(ctx context.Context) (codersdk.WorkspaceAgentListContainersResponse, error)
type DockerEnvInfoer ¶
type DockerEnvInfoer struct { usershell.SystemEnvInfo // contains filtered or unexported fields }
DockerEnvInfoer is an implementation of agentssh.EnvInfoer that returns information about a container.
func EnvInfo ¶
func EnvInfo(ctx context.Context, execer agentexec.Execer, container, containerUser string) (*DockerEnvInfoer, error)
EnvInfo returns information about the environment of a container.
func (*DockerEnvInfoer) ModifyCommand ¶
func (dei *DockerEnvInfoer) ModifyCommand(cmd string, args ...string) (string, []string)
type Lister ¶
type Lister interface { // List returns a list of containers visible to the workspace agent. // This should include running and stopped containers. List(ctx context.Context) (codersdk.WorkspaceAgentListContainersResponse, error) }
Lister is an interface for listing containers visible to the workspace agent.
type NoopLister ¶
type NoopLister struct{}
NoopLister is a Lister interface that never returns any containers.
func (NoopLister) List ¶
func (NoopLister) List(_ context.Context) (codersdk.WorkspaceAgentListContainersResponse, error)
type Option ¶
type Option func(*API)
Option is a functional option for API.
func WithClock ¶ added in v2.22.0
WithClock sets the quartz.Clock implementation to use. This is primarily used for testing to control time.
func WithDevcontainerCLI ¶ added in v2.22.0
func WithDevcontainerCLI(dccli DevcontainerCLI) Option
WithDevcontainerCLI sets the DevcontainerCLI implementation to use. This can be used in tests to modify @devcontainer/cli behavior.
func WithDevcontainers ¶ added in v2.22.0
func WithDevcontainers(devcontainers []codersdk.WorkspaceAgentDevcontainer) Option
WithDevcontainers sets the known devcontainers for the API. This allows the API to be aware of devcontainers defined in the workspace agent manifest.
func WithExecer ¶ added in v2.22.0
WithExecer sets the agentexec.Execer implementation to use.
func WithLister ¶
WithLister sets the agentcontainers.Lister implementation to use. The default implementation uses the Docker CLI to list containers.
func WithWatcher ¶ added in v2.22.0
WithWatcher sets the file watcher implementation to use. By default a noop watcher is used. This can be used in tests to modify the watcher behavior or to use an actual file watcher (e.g. fsnotify).
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package acmock is a generated GoMock package.
|
Package acmock is a generated GoMock package. |
Package dcspec contains an automatically generated Devcontainer specification.
|
Package dcspec contains an automatically generated Devcontainer specification. |
Package watcher provides file system watching capabilities for the agent.
|
Package watcher provides file system watching capabilities for the agent. |