Documentation
¶
Index ¶
- func BuildImageFromDevcontainer(ctx context.Context, configPath string) (string, error)
- func FindConfigPath(baseDir string) (string, error)
- func RemoveDevcontainer(ctx context.Context, containerID string) error
- func StartDevcontainer(ctx context.Context, opts ...StartOption) (string, error)
- func StopDevcontainer(ctx context.Context, containerID string, timeout time.Duration) error
- type DevcontainerBuild
- type DevcontainerConfig
- type FeatureMetadata
- type FeatureMount
- type FeatureOptionDefinition
- type FeatureOptionValue
- type FeatureOptions
- type FeatureReference
- type FeatureSet
- type FeatureSource
- type LifecycleCommand
- type LifecycleCommands
- type Mount
- type MountSpec
- type NamedLifecycleCommand
- type PortList
- type ResolvedFeature
- type ResolvedFeatureOptions
- type ResolvedFeatures
- type ResourceLimits
- type StartOption
- func WithConfig(cfg *DevcontainerConfig) StartOption
- func WithConfigPath(path string) StartOption
- func WithDetach() StartOption
- func WithDetachValue(detach bool) StartOption
- func WithEnv(key, value string) StartOption
- func WithExtraMount(m Mount) StartOption
- func WithExtraPublish(mapping string) StartOption
- func WithLabel(key, value string) StartOption
- func WithMergeConfig(cfg *DevcontainerConfig) StartOption
- func WithNetwork(network string) StartOption
- func WithRemoveOnStop() StartOption
- func WithResources(resources ResourceLimits) StartOption
- func WithRunArg(arg string) StartOption
- func WithTTY() StartOption
- func WithTTYValue(tty bool) StartOption
- func WithTimeout(timeout time.Duration) StartOption
- func WithWorkdir(path string) StartOption
- type StringSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildImageFromDevcontainer ¶
BuildImageFromDevcontainer builds an image from devcontainer.json. Impact: It runs Docker builds and, when features are configured, produces a feature-enhanced image. Example:
imageRef, err := devcontainer.BuildImageFromDevcontainer(ctx, "./.devcontainer/devcontainer.json")
Similar: StartDevcontainer builds images and also starts containers and runs lifecycle hooks.
func FindConfigPath ¶
FindConfigPath searches baseDir for devcontainer.json and returns the first match. Impact: It checks filesystem paths and returns an error when no config is found. Example:
path, err := devcontainer.FindConfigPath(".")
Similar: LoadConfig assumes the path is known and performs decoding.
func RemoveDevcontainer ¶
RemoveDevcontainer force-removes the specified container and its volumes. Impact: The container and related volumes are deleted from Docker and cannot be restored. Example:
err := devcontainer.RemoveDevcontainer(ctx, containerID)
Similar: WithRemoveOnStop configures auto-removal on start rather than deleting existing containers.
func StartDevcontainer ¶
func StartDevcontainer(ctx context.Context, opts ...StartOption) (string, error)
StartDevcontainer reads devcontainer.json and performs image preparation and container start. Impact: It pulls/builds images, creates and starts containers, and runs feature and lifecycle commands. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithConfigPath("./.devcontainer/devcontainer.json"))
Similar: BuildImageFromDevcontainer only builds images and does not start containers or run lifecycle hooks.
func StopDevcontainer ¶
StopDevcontainer stops the specified container. Impact: It sends a stop request to Docker and uses the timeout as the grace period when provided. Example:
err := devcontainer.StopDevcontainer(ctx, containerID, 10*time.Second)
Similar: RemoveDevcontainer deletes containers, while WithRemoveOnStop enables auto-removal at start time.
Types ¶
type DevcontainerBuild ¶
type DevcontainerBuild struct {
Dockerfile string `json:"dockerfile"` // Dockerfile is the path to the Dockerfile.
Context string `json:"context"` // Context is the build context directory.
Args map[string]string `json:"args"` // Args holds Docker build arguments.
Target string `json:"target"` // Target selects a specific build stage.
CacheFrom StringSlice `json:"cacheFrom"` // CacheFrom lists cache sources.
Options []string `json:"options"` // Options carries additional build options.
}
DevcontainerBuild describes Docker build settings from devcontainer.json.
type DevcontainerConfig ¶
type DevcontainerConfig struct {
Name string `json:"name"` // Name is an optional container name override.
Image string `json:"image"` // Image is the base image reference when not building.
Build *DevcontainerBuild `json:"build"` // Build describes Docker build settings for the devcontainer.
DockerComposeFile StringSlice `json:"dockerComposeFile"` // DockerComposeFile lists compose files for Docker Compose mode.
Service string `json:"service"` // Service selects the primary compose service.
RunServices []string `json:"runServices"` // RunServices lists additional compose services to start.
ShutdownAction string `json:"shutdownAction"` // ShutdownAction controls container shutdown behavior.
ForwardPorts PortList `json:"forwardPorts"` // ForwardPorts lists ports to forward from the container.
AppPort PortList `json:"appPort"` // AppPort lists application ports for devcontainer tooling.
ContainerEnv map[string]string `json:"containerEnv"` // ContainerEnv defines environment variables set in the container.
Mounts []MountSpec `json:"mounts"` // Mounts defines additional mounts for the container.
WorkspaceMount string `json:"workspaceMount"` // WorkspaceMount overrides the workspace mount spec.
WorkspaceFolder string `json:"workspaceFolder"` // WorkspaceFolder sets the workspace path inside the container.
RunArgs []string `json:"runArgs"` // RunArgs lists extra docker run arguments.
Privileged bool `json:"privileged"` // Privileged requests privileged container mode.
CapAdd []string `json:"capAdd"` // CapAdd adds Linux capabilities.
SecurityOpt []string `json:"securityOpt"` // SecurityOpt supplies security options to Docker.
Init *bool `json:"init"` // Init controls Docker init usage.
ContainerUser string `json:"containerUser"` // ContainerUser sets the user for the container process.
RemoteUser string `json:"remoteUser"` // RemoteUser sets the default user for lifecycle commands.
RemoteEnv map[string]string `json:"remoteEnv"` // RemoteEnv defines environment variables for remote commands.
Features FeatureSet `json:"features"` // Features declares requested devcontainer features.
OverrideFeatureInstallOrder []string `json:"overrideFeatureInstallOrder"` // OverrideFeatureInstallOrder forces feature install order.
OverrideCommand *bool `json:"overrideCommand"` // OverrideCommand controls entrypoint override behavior.
InitializeCommand *LifecycleCommands `json:"initializeCommand"` // InitializeCommand runs on the host before container create.
OnCreateCommand *LifecycleCommands `json:"onCreateCommand"` // OnCreateCommand runs after the container is created.
UpdateContentCommand *LifecycleCommands `json:"updateContentCommand"` // UpdateContentCommand runs after content updates.
PostCreateCommand *LifecycleCommands `json:"postCreateCommand"` // PostCreateCommand runs after creation tasks.
PostStartCommand *LifecycleCommands `json:"postStartCommand"` // PostStartCommand runs after the container starts.
PostAttachCommand *LifecycleCommands `json:"postAttachCommand"` // PostAttachCommand runs after attaching to the container.
}
DevcontainerConfig represents the decoded devcontainer.json configuration.
func LoadConfig ¶
func LoadConfig(path string) (*DevcontainerConfig, error)
LoadConfig reads devcontainer.json, strips comments, and decodes it into DevcontainerConfig. Impact: It performs file I/O and returns errors for invalid JSON or spec violations. Example:
cfg, err := devcontainer.LoadConfig("./.devcontainer/devcontainer.json")
Similar: FindConfigPath only searches for the file path without decoding it.
func MergeConfig ¶
func MergeConfig(base, overlay *DevcontainerConfig) *DevcontainerConfig
type FeatureMetadata ¶
type FeatureMetadata struct {
ID string `json:"id"` // ID is the canonical feature identifier.
Version string `json:"version"` // Version is the feature version string.
Name string `json:"name"` // Name is the human-readable feature name.
Description string `json:"description"` // Description explains the feature behavior.
DocumentationURL string `json:"documentationURL"` // DocumentationURL points to feature docs.
LicenseURL string `json:"licenseURL"` // LicenseURL points to the feature license.
Keywords []string `json:"keywords"` // Keywords lists search keywords.
Options map[string]FeatureOptionDefinition `json:"options"` // Options declares configurable feature options.
ContainerEnv map[string]string `json:"containerEnv"` // ContainerEnv exports environment variables.
Privileged bool `json:"privileged"` // Privileged requests privileged container mode.
Init *bool `json:"init"` // Init controls Docker init usage.
CapAdd []string `json:"capAdd"` // CapAdd adds Linux capabilities.
SecurityOpt []string `json:"securityOpt"` // SecurityOpt supplies security options.
Entrypoint string `json:"entrypoint"` // Entrypoint points to a feature entrypoint script.
Customizations map[string]any `json:"customizations"` // Customizations exposes editor/tooling settings.
DependsOn FeatureSet `json:"dependsOn"` // DependsOn declares dependent features.
InstallsAfter []string `json:"installsAfter"` // InstallsAfter lists features that should be installed first.
LegacyIds []string `json:"legacyIds"` // LegacyIds lists legacy feature identifiers.
Deprecated bool `json:"deprecated"` // Deprecated marks the feature as deprecated.
Mounts []FeatureMount `json:"mounts"` // Mounts declares feature-provided mounts.
OnCreateCommand *LifecycleCommands `json:"onCreateCommand"` // OnCreateCommand runs after container create.
UpdateContentCommand *LifecycleCommands `json:"updateContentCommand"` // UpdateContentCommand runs after content update.
PostCreateCommand *LifecycleCommands `json:"postCreateCommand"` // PostCreateCommand runs after creation tasks.
PostStartCommand *LifecycleCommands `json:"postStartCommand"` // PostStartCommand runs after container start.
PostAttachCommand *LifecycleCommands `json:"postAttachCommand"` // PostAttachCommand runs after attach.
}
FeatureMetadata represents the devcontainer-feature.json payload.
type FeatureMount ¶
type FeatureMount struct {
Type string `json:"type"` // Type is the mount type.
Source string `json:"source"` // Source is the mount source.
Target string `json:"target"` // Target is the mount destination in the container.
}
FeatureMount describes a mount contributed by a feature.
type FeatureOptionDefinition ¶
type FeatureOptionDefinition struct {
Type string `json:"type"` // Type is the option type, such as string or boolean.
Default FeatureOptionValue `json:"default"` // Default is the default option value.
Enum []string `json:"enum"` // Enum lists allowed values.
Proposals []string `json:"proposals"` // Proposals lists suggested values for tooling.
Description string `json:"description"` // Description explains the option meaning.
}
FeatureOptionDefinition describes a feature option declared in metadata.
type FeatureOptionValue ¶
type FeatureOptionValue struct {
String *string // String holds the string value when the option is a string.
Bool *bool // Bool holds the boolean value when the option is a bool.
}
FeatureOptionValue represents a feature option value that may be a string or bool.
func (FeatureOptionValue) StringValue ¶
func (v FeatureOptionValue) StringValue() (string, error)
StringValue converts a FeatureOptionValue to its string representation. Impact: Bool values become "true"/"false", and missing values return an error. Example:
value := true
v := devcontainer.FeatureOptionValue{Bool: &value}
s, err := v.StringValue()
Similar: Directly reading String/Bool requires manual type checks; StringValue centralizes the conversion.
func (*FeatureOptionValue) UnmarshalJSON ¶
func (v *FeatureOptionValue) UnmarshalJSON(data []byte) error
UnmarshalJSON loads a JSON string or boolean into FeatureOptionValue. Impact: It rejects null and sets either String or Bool based on the input type. Example:
var v devcontainer.FeatureOptionValue _ = json.Unmarshal([]byte(`true`), &v)
Similar: StringSlice.UnmarshalJSON loads arrays of strings, while FeatureOptionValue holds a single typed value.
type FeatureOptions ¶
type FeatureOptions map[string]FeatureOptionValue
type FeatureReference ¶
type FeatureReference struct {
ID string // ID is the raw feature identifier string.
Source FeatureSource // Source indicates OCI, HTTP, or local resolution.
Registry string // Registry is the OCI registry hostname when Source is OCI.
Repository string // Repository is the OCI repository name when Source is OCI.
Reference string // Reference is the OCI tag or digest.
URL string // URL is the HTTP URL when Source is HTTP.
LocalPath string // LocalPath is the path when Source is local.
}
FeatureReference describes a parsed feature reference and its source.
type FeatureSet ¶
type FeatureSet map[string]FeatureOptions
func (*FeatureSet) UnmarshalJSON ¶
func (fs *FeatureSet) UnmarshalJSON(data []byte) error
UnmarshalJSON loads a JSON feature map into FeatureSet. Impact: It rejects empty feature IDs or options and expands "feature": "1.0" into a version option. Example:
var fs devcontainer.FeatureSet
_ = json.Unmarshal([]byte(`{"ghcr.io/devcontainers/features/git":"1.0"}`), &fs)
Similar: FeatureOptionValue.UnmarshalJSON parses a single option value, while FeatureSet structures full feature entries.
type FeatureSource ¶
type FeatureSource string
const ( FeatureSourceOCI FeatureSource = "oci" FeatureSourceHTTP FeatureSource = "http" FeatureSourceLocal FeatureSource = "local" )
type LifecycleCommand ¶
type LifecycleCommand struct {
Shell string // Shell is a shell-form command string.
Exec []string // Exec is an argv-style command array.
}
LifecycleCommand represents a lifecycle hook command in shell or exec form.
type LifecycleCommands ¶
type LifecycleCommands struct {
Single *LifecycleCommand // Single is the single-command form.
Parallel []NamedLifecycleCommand // Parallel is the named command set for parallel execution.
}
LifecycleCommands captures single or parallel lifecycle command definitions.
func (*LifecycleCommands) IsZero ¶
func (c *LifecycleCommands) IsZero() bool
IsZero reports whether LifecycleCommands is unset. Impact: It is a pure check; it returns true when both the single and parallel forms are empty. Example:
if cmds.IsZero() { /* no-op */ }
Similar: A nil pointer check only looks at the pointer value, while IsZero also treats empty slices as unset.
func (*LifecycleCommands) UnmarshalJSON ¶
func (c *LifecycleCommands) UnmarshalJSON(data []byte) error
UnmarshalJSON loads JSON string/array/object lifecycle commands into LifecycleCommands. Impact: It rejects empty values and sorts object keys to stabilize parallel execution order. Example:
var c devcontainer.LifecycleCommands
_ = json.Unmarshal([]byte(`{"postCreateCommand":"echo hi"}`), &c)
Similar: FeatureSet.UnmarshalJSON parses feature maps, while LifecycleCommands focuses on command shapes.
type Mount ¶
type Mount struct {
Source string // Source is the mount source path or volume name.
Target string // Target is the mount destination inside the container.
Type string // Type is the mount type, such as bind or volume.
ReadOnly bool // ReadOnly marks the mount as read-only.
Consistency string // Consistency sets the Docker mount consistency mode.
}
Mount describes an extra container mount to apply at start.
func ParseMountSpec ¶
ParseMountSpec converts a Docker --mount string into a Mount. Impact: It validates the string and returns an error when required fields are missing. Example:
m, err := devcontainer.ParseMountSpec("type=bind,source=/tmp,target=/work")
Similar: MountSpec.UnmarshalJSON parses devcontainer.json mounts rather than CLI strings.
type MountSpec ¶
type MountSpec struct {
Raw string // Raw holds the original string-form mount value, if provided.
Type string // Type is the mount type, such as bind or volume.
Source string // Source is the mount source path or volume name.
Target string // Target is the mount destination inside the container.
}
MountSpec represents a mount entry from devcontainer.json.
func (*MountSpec) UnmarshalJSON ¶
UnmarshalJSON loads a JSON string or object-form mount into MountSpec. Impact: Missing "type" or "target" returns an error, and string-form mounts are stored in Raw. Example:
var m devcontainer.MountSpec
_ = json.Unmarshal([]byte(`{"type":"bind","source":"/tmp","target":"/work"}`), &m)
Similar: ParseMountSpec converts CLI --mount strings into Mount values.
type NamedLifecycleCommand ¶
type NamedLifecycleCommand struct {
Name string // Name is the identifier for the command entry.
Command LifecycleCommand // Command is the lifecycle command payload.
}
NamedLifecycleCommand associates a command with a stable name.
type PortList ¶
type PortList []string
func (*PortList) UnmarshalJSON ¶
UnmarshalJSON loads numeric or string port values (or arrays) into PortList. Impact: Numeric ports like 3000 are normalized to "3000", and invalid values return an error. Example:
var p devcontainer.PortList _ = json.Unmarshal([]byte(`[3000,"9229"]`), &p)
Similar: StringSlice.UnmarshalJSON does not accept numeric values or normalize ports.
type ResolvedFeature ¶
type ResolvedFeature struct {
Reference FeatureReference // Reference is the parsed feature reference.
Metadata FeatureMetadata // Metadata is the parsed feature metadata file.
FeatureDir string // FeatureDir is the resolved feature directory.
ImageDir string // ImageDir is the optional image build directory.
Options ResolvedFeatureOptions // Options holds resolved option values.
DependencyKey string // DependencyKey is the unique key for dependency resolution.
DependsOnKeys []string // DependsOnKeys are dependency keys for required features.
InstallsAfterIDs []string // InstallsAfterIDs are normalized IDs to install after.
InstallsAfterKeys []string // InstallsAfterKeys are resolved keys to install after.
BaseName string // BaseName is the normalized feature name.
Tag string // Tag is the OCI tag when resolved from OCI.
CanonicalName string // CanonicalName is the canonical identifier with digest.
}
ResolvedFeature contains metadata and resolved paths for a feature.
type ResolvedFeatureOptions ¶
type ResolvedFeatureOptions struct {
Values map[string]string // Values are resolved option values (defaults + overrides).
UserValues map[string]string // UserValues are the values explicitly provided by users.
}
ResolvedFeatureOptions holds resolved option values for a feature.
type ResolvedFeatures ¶
type ResolvedFeatures struct {
Order []*ResolvedFeature // Order is the installation order for features.
ContainerEnv map[string]string // ContainerEnv is the merged container environment.
Mounts []MountSpec // Mounts are the merged mount specs.
Privileged bool // Privileged indicates whether privileged mode is required.
Init *bool // Init reflects merged init settings.
CapAdd []string // CapAdd is the merged capability list.
SecurityOpt []string // SecurityOpt is the merged security options list.
}
ResolvedFeatures aggregates resolved features and their merged config.
type ResourceLimits ¶
type ResourceLimits struct {
CPUQuota int64 // CPUQuota is the Docker CPU quota value.
Memory string // Memory is the memory limit string (e.g. "1g").
}
ResourceLimits defines CPU and memory limits for the container.
type StartOption ¶
type StartOption func(*startOptions)
func WithConfig ¶
func WithConfig(cfg *DevcontainerConfig) StartOption
WithConfig sets the devcontainer config struct used by StartDevcontainer. Impact: The provided config is used instead of loading devcontainer.json. Example:
cfg := &devcontainer.DevcontainerConfig{Name: "example"}
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithConfig(cfg))
Similar: WithConfigPath changes the file path, while WithConfig bypasses file loading.
func WithConfigPath ¶
func WithConfigPath(path string) StartOption
WithConfigPath sets the devcontainer.json path used by StartDevcontainer. Impact: The provided path is used directly instead of searching for the config. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithConfigPath("./.devcontainer/devcontainer.json"))
Similar: FindConfigPath only searches for the file path and does not configure StartDevcontainer.
func WithDetach ¶
func WithDetach() StartOption
WithDetach enables detached container start. Impact: StartDevcontainer returns after the container starts and does not wait for exit. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithDetach())
Similar: WithDetachValue allows explicit true/false and waits on exit when false.
func WithDetachValue ¶
func WithDetachValue(detach bool) StartOption
WithDetachValue sets the detached execution flag explicitly. Impact: When false, StartDevcontainer waits for the container to exit. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithDetachValue(false))
Similar: WithDetach is a convenience that always sets true.
func WithEnv ¶
func WithEnv(key, value string) StartOption
WithEnv adds one container environment variable. Impact: Values are merged with containerEnv and override keys with the same name. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithEnv("FOO", "bar"))
Similar: WithLabel adds Docker labels rather than environment variables.
func WithExtraMount ¶
func WithExtraMount(m Mount) StartOption
WithExtraMount adds an extra mount to the container configuration. Impact: It is appended to workspace and configured mounts and applied to HostConfig at create time. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithExtraMount(devcontainer.Mount{Source: "/tmp", Target: "/work", Type: "bind"}))
Similar: ParseMountSpec only parses CLI mount strings and does not change options.
func WithExtraPublish ¶
func WithExtraPublish(mapping string) StartOption
WithExtraPublish adds an extra port publish mapping. Impact: It is applied in addition to forwardPorts and appPort from devcontainer.json. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithExtraPublish("3000:3000"))
Similar: forwardPorts/appPort come from the config file, while WithExtraPublish is a runtime override.
func WithLabel ¶
func WithLabel(key, value string) StartOption
WithLabel adds one Docker label. Impact: Labels are merged and keys with the same name are overwritten. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithLabel("team", "dev"))
Similar: WithEnv adds environment variables, not labels.
func WithMergeConfig ¶
func WithMergeConfig(cfg *DevcontainerConfig) StartOption
WithMergeConfig adds a config overlay merged onto the base config. Impact: Later overlays override earlier values for scalar fields and append to slices. Example:
overlay := &devcontainer.DevcontainerConfig{RunArgs: []string{"--privileged"}}
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithMergeConfig(overlay))
Similar: WithConfig sets the base config, while WithMergeConfig layers changes on top.
func WithNetwork ¶
func WithNetwork(network string) StartOption
WithNetwork sets the Docker network mode to use. Impact: HostConfig.NetworkMode is set, overriding the default network resolution. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithNetwork("host"))
Similar: WithRunArg can pass --network, but WithNetwork is an explicit API.
func WithRemoveOnStop ¶
func WithRemoveOnStop() StartOption
WithRemoveOnStop enables automatic container removal when it stops. Impact: Docker AutoRemove is set to true so the container is removed after stopping. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithRemoveOnStop())
Similar: RemoveDevcontainer explicitly removes an existing container.
func WithResources ¶
func WithResources(resources ResourceLimits) StartOption
WithResources sets CPU and memory limits. Impact: Docker HostConfig CPUQuota/Memory are set, enabling resource limits. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithResources(devcontainer.ResourceLimits{Memory: "1g"}))
Similar: WithRunArg can pass --memory, but WithResources uses structured input.
func WithRunArg ¶
func WithRunArg(arg string) StartOption
WithRunArg appends one raw docker run argument. Impact: Selected flags (such as --cap-add) are parsed and affect privilege and network settings. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithRunArg("--cap-add=SYS_PTRACE"))
Similar: WithResources/WithNetwork use structured input, while WithRunArg uses a raw string.
func WithTTY ¶
func WithTTY() StartOption
WithTTY enables TTY allocation. Impact: The container is created with Tty=true, which changes stdio handling. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithTTY())
Similar: WithTTYValue allows explicit true/false and disables TTY when false.
func WithTTYValue ¶
func WithTTYValue(tty bool) StartOption
WithTTYValue sets the TTY allocation flag explicitly. Impact: When false, Tty is disabled on the container. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithTTYValue(false))
Similar: WithTTY is a convenience that always sets true.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) StartOption
WithTimeout sets the overall StartDevcontainer timeout. Impact: When the timeout is exceeded, the context is canceled and startup is aborted. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithTimeout(2*time.Minute))
Similar: context.WithTimeout can be used by callers, but WithTimeout keeps timing in options.
func WithWorkdir ¶
func WithWorkdir(path string) StartOption
WithWorkdir overrides the container working directory. Impact: It takes precedence over workspaceFolder from devcontainer.json. Example:
id, err := devcontainer.StartDevcontainer(ctx, devcontainer.WithWorkdir("/work"))
Similar: workspaceFolder is static in the config file, while WithWorkdir is runtime.
type StringSlice ¶
type StringSlice []string
func (*StringSlice) UnmarshalJSON ¶
func (s *StringSlice) UnmarshalJSON(data []byte) error
UnmarshalJSON loads a JSON string or string array into StringSlice. Impact: It accepts both "value" and ["value1","value2"] in devcontainer.json and errors on invalid types. Example:
var s devcontainer.StringSlice _ = json.Unmarshal([]byte(`["a","b"]`), &s)
Similar: PortList.UnmarshalJSON accepts numeric ports, while StringSlice only accepts strings.