features

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package features implements backend-agnostic modeling, downloading, and ordering of Dev Container Features as described in https://containers.dev/implementors/features/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Feature

type Feature interface {
	// ID returns the feature identifier as declared in the workspace config.
	ID() string
	// Download resolves the feature into destDir (fetching from a registry or
	// copying from the local file tree) and returns the parsed metadata.
	Download(ctx context.Context, destDir string) (FeatureMetadata, error)
}

Feature models a devcontainer feature that can be resolved to a local directory.

func FromMap

func FromMap(m map[string]map[string]interface{}, workspaceConfigDir string) ([]Feature, map[string]map[string]interface{}, error)

FromMap converts the workspace Features map (feature ID → user options) to:

  • a slice of Feature instances sorted by ID (deterministic, pre-ordering)
  • the user-supplied options map, keyed by feature ID

workspaceConfigDir is the directory containing workspace.json; it is used to resolve relative paths for local features. Returns an error if any ID is an unsupported Tgz URI.

func NewOCIFeatureWithClient

func NewOCIFeatureWithClient(id string, client *http.Client) Feature

NewOCIFeatureWithClient returns an OCI Feature that uses the provided HTTP client. Intended for testing; production code uses the Feature instances returned by FromMap.

func Order

func Order(feats []Feature, metadata map[string]FeatureMetadata) ([]Feature, error)

Order returns features in the correct installation order, respecting the installsAfter fields read from each feature's devcontainer-feature.json. metadata must contain an entry for every feature in feats; an error is returned if any entry is missing. Per the Dev Container spec, installsAfter is a hint: references to IDs not present in feats are silently ignored. Returns an error if a cycle is detected.

type FeatureMetadata

type FeatureMetadata interface {
	// ContainerEnv returns persistent environment variables to set in the image
	// after the feature is installed. Values may use ${VAR} expansion.
	ContainerEnv() map[string]string
	// Options returns the feature's option specifications with merge/validation.
	Options() FeatureOptions
	// InstallsAfter returns the IDs of features that must be installed before this one.
	InstallsAfter() []string
}

FeatureMetadata holds data parsed from devcontainer-feature.json.

type FeatureOptions

type FeatureOptions interface {
	// Merge merges user-supplied options with the spec defaults, validates
	// user values (type, enum membership), and normalizes keys per spec:
	// uppercased, non-alphanumeric chars replaced with '_'.
	// (e.g. "install-tools" → "INSTALL_TOOLS", "go.version" → "GO_VERSION")
	// Returns a map of normalized key → string value, or an error if any
	// user-supplied value is invalid (wrong type, not in enum, etc.).
	Merge(userOptions map[string]interface{}) (map[string]string, error)
}

FeatureOptions provides access to a feature's option specifications.

Jump to

Keyboard shortcuts

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