Documentation
¶
Index ¶
- Constants
- Variables
- func AddConfigToImageMetadata(config *DevContainerConfig, imageMetadataConfig *ImageMetadataConfig)
- func CalculatePrebuildHash(params PrebuildHashParams) (string, error)
- func ComputeDevContainerID(labels map[string]string) string
- func Convert(from any, to any) error
- func DefaultIDLabels(localWorkspaceFolder, configFilePath string) map[string]string
- func DeriveDevContainerID(localWorkspaceFolder, configFilePath string) string
- func GetContextPath(parsedConfig *DevContainerConfig) string
- func GetDockerLabelForID(id string) []string
- func GetIDLabels(id string, idLabels []string) []string
- func GetRemoteUser(result *Result) string
- func LegacyDeriveDevContainerID(localWorkspaceFolder string) string
- func ListDevContainerIDs(folder string) ([]string, error)
- func ListToObject(list []string) map[string]string
- func MergeExtraRemoteEnv(mergedConfig *MergedDevContainerConfig, extraConfigPath string) error
- func ObjectToList(object map[string]string) []string
- func ParseKeyValueFile(filename string) ([]string, error)
- func ParseSizeToBytes(s string) (uint64, error)
- func PrepareCmdUser(cmd *exec.Cmd, userName string) error
- func ProbeUserEnv(ctx context.Context, probe string, userName string) (map[string]string, error)
- func ResolveString(val string, replace ReplaceFunction) string
- func ReverseSlice[T comparable](s []T) []T
- func SaveDevContainerJSON(config *DevContainerConfig) error
- func Substitute(substitutionCtx *SubstitutionContext, config any, out any) error
- func SubstituteContainerEnv(containerEnv map[string]string, config any, out any) error
- func ValidateHostRequirements(reqs *HostRequirements, host HostInfo, workspacePath string) (warnings []string, err error)
- func ValidateIDLabels(labels []string) error
- func WriteErrorJSON(w io.Writer, msg string) error
- func WriteResultJSON(w io.Writer, containerID, user, workdir string, warnings []string) error
- type BuildInfo
- type BuildInfoDockerless
- type ComposeContainer
- type ConfigBuildOptions
- type ContainerDetails
- type ContainerDetailsConfig
- type ContainerDetailsState
- type DependsOnField
- type DevContainerActions
- type DevContainerConfig
- func CloneDevContainerConfig(config *DevContainerConfig) *DevContainerConfig
- func ParseDevContainerJSON(folder, relativePath string) (*DevContainerConfig, error)
- func ParseDevContainerJSONFile(jsonFilePath string) (*DevContainerConfig, error)
- func ParseDevContainerJSONWithSelector(folder, relativePath string, selector func([]string) (string, error)) (*DevContainerConfig, error)
- type DevContainerConfigBase
- type DevContainerConfigWithPath
- type DevsyCustomizations
- type DockerfileContainer
- func (d DockerfileContainer) GetArgs() map[string]string
- func (d DockerfileContainer) GetCacheFrom() types.StrArray
- func (d DockerfileContainer) GetContext() string
- func (d DockerfileContainer) GetDockerfile() string
- func (d DockerfileContainer) GetOptions() []string
- func (d DockerfileContainer) GetTarget() string
- type ErrorEnvelope
- type ExtendsRef
- type FeatureConfig
- type FeatureConfigOption
- type FeatureSet
- type GPURequirement
- type HostInfo
- type HostRequirements
- type ImageBuildInfo
- type ImageContainer
- type ImageDetails
- type ImageDetailsConfig
- type ImageMetadata
- type ImageMetadataConfig
- type JetBrainsCustomizations
- type MergedDevContainerConfig
- type Mount
- type NonComposeBase
- type PortAttribute
- type PrebuildHashParams
- type ReplaceFunction
- type Result
- type ResultEnvelope
- type RunningContainer
- type SecretConfig
- type SubstitutedConfig
- type SubstitutionContext
- type SystemHostInfo
- type UpdatedConfigProperties
- type UserEnvProbe
- type VSCodeCustomizations
Constants ¶
const ( DockerIDLabel = "dev.containers.id" DockerfileDefaultTarget = "dev_container_auto_added_stage_label" DevsyContextFeatureFolder = pkgconfig.ConfigDirName + "-internal" DevsyDockerlessBuildInfoFolder = "/workspaces/.dockerless" )
const ( ShutdownActionNone = "none" ShutdownActionStopContainer = "stopContainer" ShutdownActionStopCompose = "stopCompose" )
const ( AutoForwardIgnore = "ignore" AutoForwardNotify = "notify" AutoForwardSilent = "silent" ProtocolHTTPS = "https" )
const ( LabelLocalFolder = "devcontainer.local_folder" LabelConfigFile = "devcontainer.config_file" )
const DEVCONTAINER_FEATURE_FILE_NAME = "devcontainer-feature.json"
const UserLabel = pkgconfig.BinaryName + ".user"
Variables ¶
var ErrHostRequirementsNotMet = errors.New("host does not meet minimum requirements")
ErrHostRequirementsNotMet is returned when the host does not satisfy hard requirements (CPU count, memory, or GPU) declared in devcontainer.json.
var VariableRegExp = regexp.MustCompile(`\${(.*?)}`)
Functions ¶
func AddConfigToImageMetadata ¶
func AddConfigToImageMetadata( config *DevContainerConfig, imageMetadataConfig *ImageMetadataConfig, )
AddConfigToImageMetadata adds a configuration to the given image metadata and used to generate the final image metadata.
func CalculatePrebuildHash ¶
func CalculatePrebuildHash(params PrebuildHashParams) (string, error)
CalculatePrebuildHash computes a deterministic hash for prebuild caching. The hash includes: architecture, normalized config, dockerfile content, and context files. The hash format is "devsy-" followed by 32 hex characters.
func ComputeDevContainerID ¶ added in v1.1.0
ComputeDevContainerID implements the official devcontainer CLI algorithm: SHA-256(JSON.stringify(labels, sorted keys)) → BigInt → base-32 (0-9a-v) → left-pad to 52 chars.
func DefaultIDLabels ¶ added in v1.1.0
DefaultIDLabels returns the default labels used for devcontainerId derivation.
func DeriveDevContainerID ¶ added in v1.1.0
DeriveDevContainerID computes the spec-compliant devcontainerId from workspace and config paths.
func GetContextPath ¶
func GetContextPath(parsedConfig *DevContainerConfig) string
func GetDockerLabelForID ¶
func GetIDLabels ¶ added in v1.1.0
func GetRemoteUser ¶
GetRemoteUser determines the remote user using DevContainer specification priority order: 1. remoteUser from configuration 2. devsy.user label from container 3. User field from Docker inspect 4. containerUser from configuration
Per DevContainer specification (https://containers.dev/implementors/json_reference/): "remoteUser: Overrides the user that devcontainer.json supporting services tools / runs as in the container... Defaults to the user the container as a whole is running as (often root).".
func LegacyDeriveDevContainerID ¶ added in v1.1.0
LegacyDeriveDevContainerID is the old derivation (SHA-256 hex prefix of folder path).
func ListDevContainerIDs ¶
ListDevContainerIDs returns available devcontainer IDs in the folder.
func ListToObject ¶
func MergeExtraRemoteEnv ¶ added in v1.1.0
func MergeExtraRemoteEnv(mergedConfig *MergedDevContainerConfig, extraConfigPath string) error
func ObjectToList ¶
func ParseKeyValueFile ¶
func ParseSizeToBytes ¶ added in v1.1.0
ParseSizeToBytes converts a human-readable size string (e.g. "8gb", "512mb") to bytes. If no unit suffix is present, the value is treated as bytes.
func ProbeUserEnv ¶
func ResolveString ¶
func ResolveString(val string, replace ReplaceFunction) string
func ReverseSlice ¶
func ReverseSlice[T comparable](s []T) []T
func SaveDevContainerJSON ¶
func SaveDevContainerJSON(config *DevContainerConfig) error
func Substitute ¶
func Substitute(substitutionCtx *SubstitutionContext, config any, out any) error
func SubstituteContainerEnv ¶
func ValidateHostRequirements ¶ added in v1.1.0
func ValidateHostRequirements( reqs *HostRequirements, host HostInfo, workspacePath string, ) (warnings []string, err error)
ValidateHostRequirements checks whether the host satisfies the resource requirements declared in devcontainer.json. Hard failures (insufficient CPUs, memory, or required GPU unavailable) are collected into a non-nil error. Soft issues (detection errors, insufficient storage) are returned as warnings.
func ValidateIDLabels ¶ added in v1.1.0
Types ¶
type BuildInfo ¶
type BuildInfo struct {
ImageDetails *ImageDetails
ImageMetadata *ImageMetadataConfig
ImageName string
PrebuildHash string
RegistryCache string
Tags []string
Dockerless *BuildInfoDockerless
}
type BuildInfoDockerless ¶
type ComposeContainer ¶
type ComposeContainer struct {
// The name of the docker-compose file(s) used to start the services.
DockerComposeFile types.StrArray `json:"dockerComposeFile,omitempty"`
// The service you want to work on. This is considered the primary container for your dev environment which your editor will connect to.
Service string `json:"service,omitempty"`
// An array of services that should be started and stopped.
RunServices []string `json:"runServices,omitempty"`
}
type ConfigBuildOptions ¶
type ConfigBuildOptions struct {
// The location of the Dockerfile that defines the contents of the container. The path is relative to the folder containing the `devcontainer.json` file.
Dockerfile string `json:"dockerfile,omitempty"`
// The location of the context folder for building the Docker image. The path is relative to the folder containing the `devcontainer.json` file.
Context string `json:"context,omitempty"`
// Target stage in a multi-stage build.
Target string `json:"target,omitempty"`
// Build arguments.
Args map[string]string `json:"args,omitempty"`
// The image to consider as a cache. Use an array to specify multiple images.
CacheFrom types.StrArray `json:"cacheFrom,omitempty"`
// Build cli options
Options []string `json:"options,omitempty"`
}
type ContainerDetails ¶
type ContainerDetails struct {
ID string `json:"ID,omitempty"`
Created string `json:"Created,omitempty"`
State ContainerDetailsState `json:"State"`
Config ContainerDetailsConfig `json:"Config"`
}
type ContainerDetailsConfig ¶
type ContainerDetailsConfig struct {
Labels map[string]string `json:"Labels,omitempty"`
// WorkingDir specifies default working directory inside the container
WorkingDir string `json:"WorkingDir,omitempty"`
// User specifies the user that the container runs as
User string `json:"User,omitempty"`
// LegacyImage shouldn't get used anymore and is only there for testing
LegacyImage string `json:"Image,omitempty"`
}
type ContainerDetailsState ¶
type DependsOnField ¶
func (*DependsOnField) UnmarshalJSON ¶
func (d *DependsOnField) UnmarshalJSON(data []byte) error
type DevContainerActions ¶
type DevContainerActions struct {
// A command to run when creating the container. This command is run after "initializeCommand" and before "updateContentCommand". If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell.
OnCreateCommand types.LifecycleHook `json:"onCreateCommand,omitempty"`
// A command to run when creating the container and rerun when the workspace content was updated while creating the container.
// This command is run after "onCreateCommand" and before "postCreateCommand". If this is a single string, it will be run in a shell.
// If this is an array of strings, it will be run as a single command without shell.
UpdateContentCommand types.LifecycleHook `json:"updateContentCommand,omitempty"`
// A command to run after creating the container. This command is run after "updateContentCommand" and before "postStartCommand".
// If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell.
PostCreateCommand types.LifecycleHook `json:"postCreateCommand,omitempty"`
// A command to run after starting the container. This command is run after "postCreateCommand" and before "postAttachCommand".
// If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell.
PostStartCommand types.LifecycleHook `json:"postStartCommand,omitempty"`
// A command to run when attaching to the container. This command is run after "postStartCommand".
// If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell.
PostAttachCommand types.LifecycleHook `json:"postAttachCommand,omitempty"`
// Tool-specific configuration. Each tool should use a JSON object subproperty with a unique name to group its customizations.
Customizations map[string]any `json:"customizations,omitempty"`
}
type DevContainerConfig ¶
type DevContainerConfig struct {
DevContainerConfigBase `json:",inline"`
DevContainerActions `json:",inline"`
NonComposeBase `json:",inline"`
ImageContainer `json:",inline"`
ComposeContainer `json:",inline"`
DockerfileContainer `json:",inline"`
RunningContainer `json:",inline"`
// Origin is the origin from where this config was loaded
Origin string `json:"-"`
}
func CloneDevContainerConfig ¶
func CloneDevContainerConfig(config *DevContainerConfig) *DevContainerConfig
func ParseDevContainerJSON ¶
func ParseDevContainerJSON(folder, relativePath string) (*DevContainerConfig, error)
ParseDevContainerJSON check if a file named devcontainer.json exists in the given directory and parse it if it does.
func ParseDevContainerJSONFile ¶
func ParseDevContainerJSONFile(jsonFilePath string) (*DevContainerConfig, error)
ParseDevContainerJSONFile parse the given a devcontainer.json file.
func ParseDevContainerJSONWithSelector ¶
func ParseDevContainerJSONWithSelector( folder, relativePath string, selector func([]string) (string, error), ) (*DevContainerConfig, error)
ParseDevContainerJSONWithSelector allows custom selection when multiple devcontainer configs exist.
type DevContainerConfigBase ¶
type DevContainerConfigBase struct {
// Path(s) to other devcontainer.json files to inherit from.
Extends ExtendsRef `json:"extends,omitempty"`
// A name for the dev container which can be displayed to the user.
Name string `json:"name,omitempty"`
// Features to add to the dev container.
Features map[string]any `json:"features,omitempty"`
// Array consisting of the Feature id (without the semantic version) of Features in the order the user wants them to be installed.
OverrideFeatureInstallOrder []string `json:"overrideFeatureInstallOrder,omitempty"`
// Ports that are forwarded from the container to the local machine. Can be an integer port number, or a string of the format "host:port_number".
ForwardPorts types.StrIntArray `json:"forwardPorts,omitempty"`
// Set default properties that are applied when a specific port number is forwarded.
PortsAttributes map[string]PortAttribute `json:"portsAttributes,omitempty"`
// Set default properties that are applied to all ports that don't get properties from the setting `remote.portsAttributes`.
OtherPortsAttributes *PortAttribute `json:"otherPortsAttributes,omitempty"`
// Controls whether on Linux the container's user should be updated with the local user's UID and GID. On by default when opening from a local folder.
UpdateRemoteUserUID *bool `json:"updateRemoteUserUID,omitempty"`
// Remote environment variables to set for processes spawned in the container including lifecycle scripts and any remote editor/IDE server process.
RemoteEnv map[string]*string `json:"remoteEnv,omitempty"`
// The username to use for spawning processes in the container including lifecycle scripts and any remote editor/IDE server process. The default is the same user as the container.
RemoteUser string `json:"remoteUser,omitempty"`
// A command to run locally before anything else. This command is run before "onCreateCommand". If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell.
InitializeCommand types.LifecycleHook `json:"initializeCommand,omitempty"`
// Action to take when the user disconnects from the container in their editor. The default is to stop the container.
ShutdownAction string `json:"shutdownAction,omitempty"`
// The user command to wait for before continuing execution in the background while the UI is starting up. The default is "updateContentCommand".
WaitFor string `json:"waitFor,omitempty"`
// User environment probe to run. The default is "loginInteractiveShell".
UserEnvProbe string `json:"userEnvProbe,omitempty"`
// Host hardware requirements.
HostRequirements *HostRequirements `json:"hostRequirements,omitempty"`
// Whether to overwrite the command specified in the image. The default is true.
OverrideCommand *bool `json:"overrideCommand,omitempty"`
// The path of the workspace folder inside the container.
WorkspaceFolder string `json:"workspaceFolder,omitempty"`
// DEPRECATED: Use 'customizations/vscode/settings' instead
// Machine specific settings that should be copied into the container. These are only copied when connecting to the container for the first time, rebuilding the container then triggers it again.
Settings map[string]any `json:"settings,omitempty"`
// DEPRECATED: Use 'customizations/vscode/extensions' instead
// An array of extensions that should be installed into the container.
Extensions []string `json:"extensions,omitempty"`
// DEPRECATED: Use 'customizations/vscode/devPort' instead
// The port VS Code can use to connect to its backend.
DevPort int `json:"devPort,omitempty"`
// Secrets declared by the dev container. Keys are secret names; values describe the secret.
// At runtime, each key is looked up in the host environment and, if set, injected into lifecycle commands.
Secrets map[string]SecretConfig `json:"secrets,omitempty"`
}
type DevContainerConfigWithPath ¶
type DevContainerConfigWithPath struct {
// Config is the devcontainer.json config
Config *DevContainerConfig `json:"config,omitempty"`
// Path is the relative path to the devcontainer.json from the workspace folder
Path string `json:"path,omitempty"`
}
type DevsyCustomizations ¶
type DevsyCustomizations struct {
PrebuildRepository types.StrArray `json:"prebuildRepository,omitempty"`
FeatureDownloadHTTPHeaders map[string]string `json:"featureDownloadHTTPHeaders,omitempty"`
}
func GetDevsyCustomizations ¶
func GetDevsyCustomizations(parsedConfig *DevContainerConfig) *DevsyCustomizations
type DockerfileContainer ¶
type DockerfileContainer struct {
// The location of the Dockerfile that defines the contents of the container. The path is relative to the folder containing the `devcontainer.json` file.
Dockerfile string `json:"dockerFile,omitempty"`
// The location of the context folder for building the Docker image. The path is relative to the folder containing the `devcontainer.json` file.
Context string `json:"context,omitempty"`
// Docker build-related options.
Build *ConfigBuildOptions `json:"build,omitempty"`
}
func (DockerfileContainer) GetArgs ¶
func (d DockerfileContainer) GetArgs() map[string]string
func (DockerfileContainer) GetCacheFrom ¶
func (d DockerfileContainer) GetCacheFrom() types.StrArray
func (DockerfileContainer) GetContext ¶
func (d DockerfileContainer) GetContext() string
func (DockerfileContainer) GetDockerfile ¶
func (d DockerfileContainer) GetDockerfile() string
func (DockerfileContainer) GetOptions ¶
func (d DockerfileContainer) GetOptions() []string
func (DockerfileContainer) GetTarget ¶
func (d DockerfileContainer) GetTarget() string
type ErrorEnvelope ¶ added in v1.1.0
type ExtendsRef ¶ added in v1.1.0
type ExtendsRef []string
ExtendsRef holds one or more paths to parent devcontainer.json files. JSON accepts either a single string or an array of strings.
func (ExtendsRef) IsEmpty ¶ added in v1.1.0
func (e ExtendsRef) IsEmpty() bool
func (ExtendsRef) MarshalJSON ¶ added in v1.1.0
func (e ExtendsRef) MarshalJSON() ([]byte, error)
func (*ExtendsRef) UnmarshalJSON ¶ added in v1.1.0
func (e *ExtendsRef) UnmarshalJSON(data []byte) error
type FeatureConfig ¶
type FeatureConfig struct {
// ID of the Feature. The id should be unique in the context of the repository/published package where the feature exists and must match the name of the directory where the devcontainer-feature.json resides.
ID string `json:"id,omitempty"`
// Display name of the Feature.
Name string `json:"name,omitempty"`
// The version of the Feature. Follows the semanatic versioning (semver) specification.
Version string `json:"version,omitempty"`
// Description of the Feature. For the best appearance in an implementing tool, refrain from including markdown or HTML in the description.
Description string `json:"description,omitempty"`
// Entrypoint script that should fire at container start up.
Entrypoint string `json:"entrypoint,omitempty"`
// Indicates that the Feature is deprecated, and will not receive any further updates/support. This property is intended to be used by the supporting tools for highlighting Feature deprecation.
Deprecated bool `json:"deprecated,omitempty"`
// Array of old IDs used to publish this Feature. The property is useful for renaming a currently published Feature within a single namespace.
LegacyIds []string `json:"legacyIds,omitempty"`
// Possible user-configurable options for this Feature. The selected options will be passed as environment variables when installing the Feature into the container.
Options map[string]FeatureConfigOption `json:"options,omitempty"`
// URL to documentation for the Feature.
DocumentationURL string `json:"documentationURL,omitempty"`
// URL to the license for the Feature.
LicenseURL string `json:"licenseURL,omitempty"`
// Passes docker capabilities to include when creating the dev container.
CapAdd []string `json:"capAdd,omitempty"`
// Adds the tiny init process to the container (--init) when the Feature is used.
Init *bool `json:"init,omitempty"`
// Sets privileged mode (--privileged) for the container.
Privileged *bool `json:"privileged,omitempty"`
// Sets container security options to include when creating the container.
SecurityOpt []string `json:"securityOpt,omitempty"`
// Mounts a volume or bind mount into the container.
Mounts []*Mount `json:"mounts,omitempty"`
// Array of ID's of Features that should execute before this one. Allows control for feature authors on soft dependencies between different Features.
InstallsAfter []string `json:"installsAfter,omitempty"`
// The optional dependsOn property indicates a set of required, “hard” dependencies for a given Feature. Hard dependencies must be satisfied before this Feature is installed.
DependsOn DependsOnField `json:"dependsOn,omitempty"`
// Container environment variables.
ContainerEnv map[string]string `json:"containerEnv,omitempty"`
// Lifecycle hooks
DevContainerActions `json:",inline"`
// OCI manifest annotations (populated only for OCI-sourced features).
Annotations map[string]string `json:"-"`
// Origin is the path where the feature was loaded from
Origin string `json:"-"`
}
func ParseDevContainerFeature ¶
func ParseDevContainerFeature(folder string) (*FeatureConfig, error)
type FeatureConfigOption ¶
type FeatureConfigOption struct {
// Default value if the user omits this option from their configuration.
Default types.StrBool `json:"default,omitempty"`
// A description of the option displayed to the user by a supporting tool.
Description string `json:"description,omitempty"`
// The type of the option. Can be 'boolean' or 'string'. Options of type 'string' should use the 'enum' or 'proposals' property to provide a list of allowed values.
Type string `json:"type,omitempty"`
// Allowed values for this option. Unlike 'proposals', the user cannot provide a custom value not included in the 'enum' array.
Enum []string `json:"enum,omitempty"`
// Suggested values for this option. Unlike 'enum', the 'proposals' attribute indicates the installation script can handle arbitrary values provided by the user.
Proposals []string `json:"proposals,omitempty"`
}
type FeatureSet ¶
type FeatureSet struct {
ConfigID string
Version string
Folder string
Config *FeatureConfig
Options any
}
type GPURequirement ¶ added in v1.1.0
type GPURequirement struct {
Value string // "true", "false", or "optional"
Cores int // Object format, advisory
GPUMemory string // Object format, advisory
}
GPURequirement represents the gpu field in hostRequirements. It supports bool, string, and object formats per the devcontainer spec.
func (GPURequirement) MarshalJSON ¶ added in v1.1.0
func (g GPURequirement) MarshalJSON() ([]byte, error)
MarshalJSON produces the canonical JSON format so that round-tripping through json.Marshal/Unmarshal (used by Convert for deep copies) is lossless.
func (*GPURequirement) UnmarshalJSON ¶ added in v1.1.0
func (g *GPURequirement) UnmarshalJSON(data []byte) error
UnmarshalJSON handles bool, string, and object formats for the gpu field.
type HostInfo ¶ added in v1.1.0
type HostInfo interface {
NumCPU() int
TotalMemoryBytes() (uint64, error)
AvailableStorageBytes(path string) (uint64, error)
}
HostInfo provides system resource information for validation. Abstracted as an interface to allow testing with mock values.
type HostRequirements ¶
type HostRequirements struct {
// Number of required CPUs.
CPUs int `json:"cpus,omitempty"`
// Amount of required RAM in bytes. Supports units tb, gb, mb and kb.
Memory string `json:"memory,omitempty"`
// Amount of required disk space in bytes. Supports units tb, gb, mb and kb.
Storage string `json:"storage,omitempty"`
// If GPU support should be enabled. Accepts bool, string ("optional"), or object with cores/memory.
GPU *GPURequirement `json:"gpu,omitempty"`
}
func (*HostRequirements) ShouldEnableGPU ¶
func (h *HostRequirements) ShouldEnableGPU(gpuAvailable bool) (enable bool, warnIfMissing bool)
ShouldEnableGPU determines if GPU should be enabled based on requirements and availability.
type ImageBuildInfo ¶
type ImageBuildInfo struct {
User string
Metadata *ImageMetadataConfig
// Either on of these will be filled as will
Dockerfile *dockerfile.Dockerfile
ImageDetails *ImageDetails
}
type ImageContainer ¶
type ImageContainer struct {
// The docker image that will be used to create the container.
Image string `json:"image,omitempty"`
}
type ImageDetails ¶
type ImageDetails struct {
ID string
Config ImageDetailsConfig
}
type ImageDetailsConfig ¶
type ImageMetadata ¶
type ImageMetadata struct {
ID string `json:"id,omitempty"`
Entrypoint string `json:"entrypoint,omitempty"`
DevContainerConfigBase ` json:",inline"`
DevContainerActions ` json:",inline"`
NonComposeBase ` json:",inline"`
}
type ImageMetadataConfig ¶
type ImageMetadataConfig struct {
Raw []*ImageMetadata
Config []*ImageMetadata
}
type JetBrainsCustomizations ¶
type JetBrainsCustomizations struct {
Plugins []string `json:"plugins,omitempty"`
}
func GetJetBrainsConfiguration ¶
func GetJetBrainsConfiguration(mergedConfig *MergedDevContainerConfig) *JetBrainsCustomizations
type MergedDevContainerConfig ¶
type MergedDevContainerConfig struct {
DevContainerConfigBase `json:",inline"`
UpdatedConfigProperties `json:",inline"`
NonComposeBase `json:",inline"`
ImageContainer `json:",inline"`
ComposeContainer `json:",inline"`
DockerfileContainer `json:",inline"`
RunningContainer `json:",inline"`
// Origin is the origin from where this config was loaded
Origin string `json:"-"`
}
func MergeConfiguration ¶
func MergeConfiguration( config *DevContainerConfig, imageMetadataEntries []*ImageMetadata, ) (*MergedDevContainerConfig, error)
type Mount ¶
type Mount struct {
Type string `json:"type,omitempty"`
Source string `json:"source,omitempty"`
Target string `json:"target,omitempty"`
External bool `json:"external,omitempty"`
Other []string `json:"other,omitempty"`
}
func ParseMount ¶
func (*Mount) UnmarshalJSON ¶
type NonComposeBase ¶
type NonComposeBase struct {
// Application ports that are exposed by the container. This can be a single port or an array of ports. Each port can be a number or a string.
// A number is mapped to the same port on the host. A string is passed to Docker unchanged and can be used to map ports differently,
// e.g. "8000:8010".
AppPort types.StrIntArray `json:"appPort,omitempty"`
// Container environment variables.
ContainerEnv map[string]string `json:"containerEnv,omitempty"`
// The user the container will be started with. The default is the user on the Docker image.
ContainerUser string `json:"containerUser,omitempty"`
// Mounts points to set up when creating the container. See Docker's documentation for the --mount option for the supported syntax.
Mounts []*Mount `json:"mounts,omitempty"`
// Passes the --init flag when creating the dev container.
Init *bool `json:"init,omitempty"`
// Passes the --privileged flag when creating the dev container.
Privileged *bool `json:"privileged,omitempty"`
// Passes docker capabilities to include when creating the dev container.
CapAdd []string `json:"capAdd,omitempty"`
// Passes docker security options to include when creating the dev container.
SecurityOpt []string `json:"securityOpt,omitempty"`
// The arguments required when starting in the container.
RunArgs []string `json:"runArgs,omitempty"`
// The --mount parameter for docker run. The default is to mount the project folder at /workspaces/$project.
// Per the devcontainer spec, empty string suppresses the default workspace mount.
WorkspaceMount *string `json:"workspaceMount,omitempty"`
}
type PortAttribute ¶
type PortAttribute struct {
// Defines the action that occurs when the port is discovered for automatic forwarding
// default=notify
OnAutoForward string `json:"onAutoForward,omitempty"`
// Automatically prompt for elevation (if needed) when this port is forwarded. Elevate is required if the local port is a privileged port.
ElevateIfNeeded bool `json:"elevateIfNeeded,omitempty"`
// Label that will be shown in the UI for this port.
// default=Application
Label string `json:"label,omitempty"`
// When true, a modal dialog will show if the chosen local port isn't used for forwarding.
RequireLocalPort bool `json:"requireLocalPort,omitempty"`
// The protocol to use when forwarding this port.
Protocol string `json:"protocol,omitempty"`
}
func ResolvePortAttribute ¶ added in v1.1.0
func ResolvePortAttribute( port int, portsAttrs map[string]PortAttribute, fallback *PortAttribute, ) PortAttribute
ResolvePortAttribute returns the PortAttribute for a given port number. It checks portsAttributes (including range keys like "8080-8090") first, then falls back to otherPortsAttributes.
func (PortAttribute) ShouldAutoForward ¶ added in v1.1.0
func (p PortAttribute) ShouldAutoForward() bool
ShouldAutoForward returns true if the port attribute allows auto-forwarding.
type PrebuildHashParams ¶
type PrebuildHashParams struct {
Config *DevContainerConfig
Platform string
Architecture string
ContextPath string
DockerfilePath string
DockerfileContent string
BuildInfo *ImageBuildInfo
}
PrebuildHashParams contains all parameters needed to calculate a prebuild hash.
type ReplaceFunction ¶
type Result ¶
type Result struct {
DevContainerConfigWithPath *DevContainerConfigWithPath `json:"DevContainerConfigWithPath"`
MergedConfig *MergedDevContainerConfig `json:"MergedConfig"`
SubstitutionContext *SubstitutionContext `json:"SubstitutionContext"`
ContainerDetails *ContainerDetails `json:"ContainerDetails"`
HostWarnings []string `json:"HostWarnings,omitempty"`
}
type ResultEnvelope ¶ added in v1.1.0
type RunningContainer ¶
type RunningContainer struct {
ContainerID string `json:"containerID,omitempty"`
}
type SecretConfig ¶ added in v1.1.0
type SecretConfig struct {
Description string `json:"description,omitempty"`
DocumentationUrl string `json:"documentationUrl,omitempty"`
}
SecretConfig describes a secret declared in devcontainer.json.
type SubstitutedConfig ¶
type SubstitutedConfig struct {
Config *DevContainerConfig
Raw *DevContainerConfig
}
type SubstitutionContext ¶
type SubstitutionContext struct {
DevContainerID string `json:"DevContainerID,omitempty"`
LocalWorkspaceFolder string `json:"LocalWorkspaceFolder,omitempty"`
ContainerWorkspaceFolder string `json:"ContainerWorkspaceFolder,omitempty"`
Env map[string]string `json:"Env,omitempty"`
WorkspaceMount string `json:"WorkspaceMount,omitempty"`
Userns string `json:"Userns,omitempty"`
UidMap []string `json:"UidMap,omitempty"`
GidMap []string `json:"GidMap,omitempty"`
}
type SystemHostInfo ¶ added in v1.1.0
type SystemHostInfo struct {
WorkspacePath string
}
SystemHostInfo provides real system resource information.
func (SystemHostInfo) AvailableStorageBytes ¶ added in v1.1.0
func (s SystemHostInfo) AvailableStorageBytes(path string) (uint64, error)
func (SystemHostInfo) NumCPU ¶ added in v1.1.0
func (s SystemHostInfo) NumCPU() int
func (SystemHostInfo) TotalMemoryBytes ¶ added in v1.1.0
func (s SystemHostInfo) TotalMemoryBytes() (uint64, error)
type UpdatedConfigProperties ¶
type UpdatedConfigProperties struct {
// Entrypoint script that should fire at container start up.
Entrypoints []string `json:"entrypoints,omitempty"`
// A command to run when creating the container. This command is run after "initializeCommand" and before "updateContentCommand". If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell.
OnCreateCommands []types.LifecycleHook `json:"onCreateCommand,omitempty"`
// A command to run when creating the container and rerun when the workspace content was updated while creating the container.
// This command is run after "onCreateCommand" and before "postCreateCommand". If this is a single string, it will be run in a shell.
// If this is an array of strings, it will be run as a single command without shell.
UpdateContentCommands []types.LifecycleHook `json:"updateContentCommand,omitempty"`
// A command to run after creating the container. This command is run after "updateContentCommand" and before "postStartCommand".
// If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell.
PostCreateCommands []types.LifecycleHook `json:"postCreateCommand,omitempty"`
// A command to run after starting the container. This command is run after "postCreateCommand" and before "postAttachCommand".
// If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell.
PostStartCommands []types.LifecycleHook `json:"postStartCommand,omitempty"`
// A command to run when attaching to the container. This command is run after "postStartCommand".
// If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell.
PostAttachCommands []types.LifecycleHook `json:"postAttachCommand,omitempty"`
// Tool-specific configuration. Each tool should use a JSON object subproperty with a unique name to group its customizations.
Customizations map[string][]any `json:"customizations,omitempty"`
}
type UserEnvProbe ¶
type UserEnvProbe string
const ( LoginInteractiveShellProbe UserEnvProbe = "loginInteractiveShell" LoginShellProbe UserEnvProbe = "loginShell" InteractiveShellProbe UserEnvProbe = "interactiveShell" NoneProbe UserEnvProbe = "none" DefaultUserEnvProbe UserEnvProbe = LoginInteractiveShellProbe )
func NewUserEnvProbe ¶
func NewUserEnvProbe(probe string) (UserEnvProbe, error)
type VSCodeCustomizations ¶
type VSCodeCustomizations struct {
Settings map[string]any `json:"settings,omitempty"`
Extensions []string `json:"extensions,omitempty"`
DevPort int `json:"devPort,omitempty"`
}
func GetVSCodeConfiguration ¶
func GetVSCodeConfiguration(mergedConfig *MergedDevContainerConfig) *VSCodeCustomizations