devcontainer

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HostFolderLabel    = "devcontainer.local_folder"
	ConfigFileLabel    = "devcontainer.config_file"
	ManagedByLabel     = "devcontainer.managed_by"
	ManagedByValue     = "hatchctl"
	BridgeEnabledLabel = "devcontainer.bridge.enabled"
	SSHAgentLabel      = "devcontainer.ssh_agent.enabled"
)
View Source
const ImageMetadataLabel = "devcontainer.metadata"

Variables

This section is empty.

Functions

func ComposeOverrideFile

func ComposeOverrideFile(stateDir string) string

func ComposeProjectName

func ComposeProjectName(workspace string, configPath string) string

func ContainerCommand

func ContainerCommand(config Config) []string

func EffectiveContext

func EffectiveContext(config Config) string

func EffectiveDockerfile

func EffectiveDockerfile(config Config) string

func FeatureLockFilePath

func FeatureLockFilePath(configPath string) string

func KeepAliveCommand added in v0.1.6

func KeepAliveCommand() string

func MetadataLabelValue

func MetadataLabelValue(entries []MetadataEntry) (string, error)

func RemoteExecUser

func RemoteExecUser(config Config) string

func ResolveComposeFiles

func ResolveComposeFiles(configDir string, raw any) ([]string, error)

func ResolveConfigPath added in v0.6.5

func ResolveConfigPath(workspace string, configArg string) (string, error)

func ResolveWorkspacePath added in v0.6.5

func ResolveWorkspacePath(workspaceArg string) (string, error)

func ResolvedDockerfile added in v0.8.2

func ResolvedDockerfile(configDir string, config Config) string

func ShellQuote

func ShellQuote(value string) string

func SortedMapKeys

func SortedMapKeys(values map[string]string) []string

func StandardizeJSONC added in v0.8.2

func StandardizeJSONC(path string, data []byte) ([]byte, error)

func WriteFeatureLockFile

func WriteFeatureLockFile(configPath string, features []ResolvedFeature) error

func WriteFeatureStateFile

func WriteFeatureStateFile(stateDir string, features []ResolvedFeature) error

Types

type BuildConfig

type BuildConfig struct {
	Dockerfile string            `json:"dockerfile,omitempty"`
	Context    string            `json:"context,omitempty"`
	Target     string            `json:"target,omitempty"`
	Args       map[string]string `json:"args,omitempty"`
	CacheFrom  any               `json:"cacheFrom,omitempty"`
	Options    []string          `json:"options,omitempty"`
}

type Config

type Config struct {
	Name                 string            `json:"name,omitempty"`
	Image                string            `json:"image,omitempty"`
	DockerFile           string            `json:"dockerFile,omitempty"`
	WorkspaceFolder      string            `json:"workspaceFolder,omitempty"`
	WorkspaceMount       string            `json:"workspaceMount,omitempty"`
	Mounts               []string          `json:"mounts,omitempty"`
	ContainerEnv         map[string]string `json:"containerEnv,omitempty"`
	RemoteEnv            map[string]string `json:"remoteEnv,omitempty"`
	ContainerUser        string            `json:"containerUser,omitempty"`
	RemoteUser           string            `json:"remoteUser,omitempty"`
	RunArgs              []string          `json:"runArgs,omitempty"`
	ForwardPorts         ForwardPorts      `json:"forwardPorts,omitempty"`
	InitializeCommand    LifecycleCommand  `json:"initializeCommand,omitempty"`
	OnCreateCommand      LifecycleCommand  `json:"onCreateCommand,omitempty"`
	UpdateContentCommand LifecycleCommand  `json:"updateContentCommand,omitempty"`
	PostCreateCommand    LifecycleCommand  `json:"postCreateCommand,omitempty"`
	PostStartCommand     LifecycleCommand  `json:"postStartCommand,omitempty"`
	PostAttachCommand    LifecycleCommand  `json:"postAttachCommand,omitempty"`
	WaitFor              string            `json:"waitFor,omitempty"`
	OverrideCommand      *bool             `json:"overrideCommand,omitempty"`
	UpdateRemoteUserUID  *bool             `json:"updateRemoteUserUID,omitempty"`
	Init                 *bool             `json:"init,omitempty"`
	Privileged           *bool             `json:"privileged,omitempty"`
	CapAdd               []string          `json:"capAdd,omitempty"`
	SecurityOpt          []string          `json:"securityOpt,omitempty"`
	Build                *BuildConfig      `json:"build,omitempty"`
	Customizations       map[string]any    `json:"customizations,omitempty"`
	Features             map[string]any    `json:"features,omitempty"`
	DockerComposeFile    any               `json:"dockerComposeFile,omitempty"`
	Service              string            `json:"service,omitempty"`
	Raw                  map[string]any    `json:"-"`
}

func Load

func Load(configPath string) (Config, error)

type FeatureLockEntry

type FeatureLockEntry = storefs.FeatureLockEntry

type FeatureLockFile

type FeatureLockFile = storefs.FeatureLockFile

func ReadFeatureLockFile

func ReadFeatureLockFile(configPath string) (FeatureLockFile, bool, error)

type FeatureLockfilePolicy

type FeatureLockfilePolicy string
const (
	FeatureLockfilePolicyAuto   FeatureLockfilePolicy = "auto"
	FeatureLockfilePolicyFrozen FeatureLockfilePolicy = "frozen"
	FeatureLockfilePolicyUpdate FeatureLockfilePolicy = "update"
)

func ParseFeatureLockfilePolicy

func ParseFeatureLockfilePolicy(value string) (FeatureLockfilePolicy, error)

type FeatureResolveOptions

type FeatureResolveOptions struct {
	AllowNetwork   bool
	WriteLockFile  bool
	WriteStateFile bool
	StateDir       string
	HTTPTimeout    time.Duration
	LockfilePolicy FeatureLockfilePolicy
	VerifyImage    func(context.Context, string) security.VerificationResult
}

type FeatureStateEntry

type FeatureStateEntry = storefs.FeatureStateEntry

type FeatureStateFile

type FeatureStateFile = storefs.FeatureStateFile

type ForwardPorts

type ForwardPorts []string

func MergeForwardPorts

func MergeForwardPorts(entries ...ForwardPorts) ForwardPorts

func NormalizeForwardPorts

func NormalizeForwardPorts(raw []any) (ForwardPorts, error)

func (ForwardPorts) MarshalJSON

func (p ForwardPorts) MarshalJSON() ([]byte, error)

func (*ForwardPorts) UnmarshalJSON

func (p *ForwardPorts) UnmarshalJSON(data []byte) error

type LifecycleCommand

type LifecycleCommand struct {
	Kind   string
	Value  string
	Args   []string
	Steps  map[string]LifecycleCommand
	Exists bool
}

func (LifecycleCommand) Empty

func (c LifecycleCommand) Empty() bool

func (LifecycleCommand) MarshalJSON

func (c LifecycleCommand) MarshalJSON() ([]byte, error)

func (LifecycleCommand) SortedSteps

func (c LifecycleCommand) SortedSteps() []LifecycleStep

func (*LifecycleCommand) UnmarshalJSON

func (c *LifecycleCommand) UnmarshalJSON(data []byte) error

type LifecycleStep

type LifecycleStep struct {
	Name    string
	Command LifecycleCommand
}

type MergedConfig

type MergedConfig struct {
	Config                Config
	Init                  bool
	Privileged            bool
	CapAdd                []string
	SecurityOpt           []string
	Mounts                []string
	RemoteUser            string
	ContainerUser         string
	RemoteEnv             map[string]string
	ContainerEnv          map[string]string
	OverrideCommand       *bool
	UpdateRemoteUserUID   *bool
	WaitFor               string
	ForwardPorts          ForwardPorts
	OnCreateCommands      []LifecycleCommand
	UpdateContentCommands []LifecycleCommand
	PostCreateCommands    []LifecycleCommand
	PostStartCommands     []LifecycleCommand
	PostAttachCommands    []LifecycleCommand
	Customizations        map[string][]any
	Metadata              []MetadataEntry
}

func MergeMetadata

func MergeMetadata(config Config, metadata []MetadataEntry) MergedConfig

type MetadataEntry

type MetadataEntry struct {
	ID                   string            `json:"id,omitempty"`
	Init                 *bool             `json:"init,omitempty"`
	Privileged           *bool             `json:"privileged,omitempty"`
	CapAdd               []string          `json:"capAdd,omitempty"`
	SecurityOpt          []string          `json:"securityOpt,omitempty"`
	Mounts               []string          `json:"mounts,omitempty"`
	OnCreateCommand      LifecycleCommand  `json:"onCreateCommand,omitempty"`
	UpdateContentCommand LifecycleCommand  `json:"updateContentCommand,omitempty"`
	PostCreateCommand    LifecycleCommand  `json:"postCreateCommand,omitempty"`
	PostStartCommand     LifecycleCommand  `json:"postStartCommand,omitempty"`
	PostAttachCommand    LifecycleCommand  `json:"postAttachCommand,omitempty"`
	WaitFor              string            `json:"waitFor,omitempty"`
	RemoteUser           string            `json:"remoteUser,omitempty"`
	ContainerUser        string            `json:"containerUser,omitempty"`
	RemoteEnv            map[string]string `json:"remoteEnv,omitempty"`
	ContainerEnv         map[string]string `json:"containerEnv,omitempty"`
	OverrideCommand      *bool             `json:"overrideCommand,omitempty"`
	UpdateRemoteUserUID  *bool             `json:"updateRemoteUserUID,omitempty"`
	ForwardPorts         ForwardPorts      `json:"forwardPorts,omitempty"`
	Customizations       map[string]any    `json:"customizations,omitempty"`
}

func ConfigMetadata

func ConfigMetadata(config Config) MetadataEntry

func FeaturesMetadata added in v0.8.1

func FeaturesMetadata(features []ResolvedFeature) []MetadataEntry

func MetadataFromLabel

func MetadataFromLabel(value string) ([]MetadataEntry, error)

func (MetadataEntry) MarshalJSON

func (m MetadataEntry) MarshalJSON() ([]byte, error)

type MountSpec added in v0.1.5

type MountSpec struct {
	Type            string
	Source          string
	Target          string
	ReadOnly        bool
	Consistency     string
	BindPropagation string
	CreateHostPath  *bool
	SELinux         string
	NoCopy          bool
	Subpath         string
	Raw             string
}

func ParseMountSpec added in v0.1.5

func ParseMountSpec(raw string) (MountSpec, bool)

type ResolveOptions

type ResolveOptions struct {
	AllowNetwork       bool
	ReadPlanCache      bool
	WritePlanCache     bool
	WriteFeatureLock   bool
	WriteFeatureState  bool
	Warn               func(string)
	StateBaseDir       string
	CacheBaseDir       string
	VerifyImage        func(context.Context, string) security.VerificationResult
	FeatureHTTPTimeout time.Duration
	LockfilePolicy     FeatureLockfilePolicy
}

type ResolvedConfig

type ResolvedConfig struct {
	WorkspaceFolder string
	ConfigPath      string
	ConfigDir       string
	Config          Config
	Features        []ResolvedFeature
	Merged          MergedConfig
	StateDir        string
	CacheDir        string
	WorkspaceMount  string
	RemoteWorkspace string
	ImageName       string
	SourceKind      string
	ContainerName   string
	ComposeFiles    []string
	ComposeService  string
	ComposeProject  string
	Labels          map[string]string
}

func Resolve

func Resolve(ctx context.Context, workspaceArg string, configArg string) (ResolvedConfig, error)

func ResolveReadOnly

func ResolveReadOnly(ctx context.Context, workspaceArg string, configArg string) (ResolvedConfig, error)

func ResolveReadOnlyWithOptions

func ResolveReadOnlyWithOptions(ctx context.Context, workspaceArg string, configArg string, opts ResolveOptions) (ResolvedConfig, error)

func ResolveWithOptions

func ResolveWithOptions(ctx context.Context, workspaceArg string, configArg string, opts ResolveOptions) (ResolvedConfig, error)

func ResolveWorkspaceSpecWithOptions added in v0.6.15

func ResolveWorkspaceSpecWithOptions(ctx context.Context, workspaceSpec WorkspaceSpec, stateDir string, cacheDir string, opts ResolveOptions) (ResolvedConfig, error)

type ResolvedFeature

type ResolvedFeature struct {
	SourceKind    string
	Source        string
	Path          string
	Version       string
	Resolved      string
	Integrity     string
	Verification  security.VerificationResult
	Options       map[string]string
	DependsOn     []string
	InstallsAfter []string
	Metadata      MetadataEntry
}

func ResolveFeatures

func ResolveFeatures(ctx context.Context, configPath string, configDir string, cacheDir string, values map[string]any, opts FeatureResolveOptions) ([]ResolvedFeature, error)

type WorkspaceSpec added in v0.6.5

type WorkspaceSpec struct {
	WorkspaceFolder string
	ConfigPath      string
	ConfigDir       string
	Config          Config
	Merged          MergedConfig
	WorkspaceMount  string
	RemoteWorkspace string
	SourceKind      string
	ComposeFiles    []string
	ComposeService  string
}

func ResolveWorkspaceSpec added in v0.8.2

func ResolveWorkspaceSpec(workspaceArg string, configArg string) (WorkspaceSpec, error)

Jump to

Keyboard shortcuts

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