Help us shape the future of Go! Take the 2026 Go Developer Survey

feature

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MPL-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const CollectionLayerMediaType = "application/vnd.devcontainers.collection.layer.v1+json"
View Source
const DEVCONTAINER_MANIFEST_MEDIATYPE = "application/vnd.devcontainers"
View Source
const FEATURE_BASE_DOCKERFILE = `
FROM $_DEV_CONTAINERS_BASE_IMAGE AS dev_containers_target_stage

USER root

COPY ./` + config.DevsyContextFeatureFolder + `/ /tmp/build-features/
RUN chmod -R 0755 /tmp/build-features && ls /tmp/build-features

#{featureLayer}

ARG _DEV_CONTAINERS_IMAGE_USER=root
USER $_DEV_CONTAINERS_IMAGE_USER
`

Variables

This section is empty.

Functions

func FetchOCIManifest added in v1.1.0

func FetchOCIManifest(ref name.Reference) (*v1.Manifest, error)

func GetFeatureEnvVariables added in v1.1.0

func GetFeatureEnvVariables(feature *config.FeatureConfig, featureOptions any) []string

func GetFeatureInstallWrapperScript added in v1.1.0

func GetFeatureInstallWrapperScript(
	idWithoutVersion string,
	feature *config.FeatureConfig,
	options []string,
) string

func IsSecretOption added in v1.1.0

func IsSecretOption(option config.FeatureConfigOption) bool

IsSecretOption returns true if the given option has type "secret".

func LoadOCIAnnotations added in v1.1.0

func LoadOCIAnnotations(featureFolder string) map[string]string

func LockfilePath added in v1.10.0

func LockfilePath(configOrigin string) string

LockfilePath returns the lockfile path for a devcontainer config origin.

func ProcessFeatureID

func ProcessFeatureID(
	id string,
	devContainerConfig *config.DevContainerConfig,
	forceBuild bool,
) (string, error)

ProcessFeatureID resolves a feature identifier to a local folder containing the extracted feature, without lockfile pinning.

func PullFeatureToTemp added in v1.1.0

func PullFeatureToTemp(ref name.Reference, id string) (string, error)

func ResolveFeatureOrder added in v1.1.0

func ResolveFeatureOrder(
	devContainerConfig *config.DevContainerConfig,
) ([]*config.FeatureSet, error)

ResolveFeatureOrder parses the features in a DevContainerConfig, resolves their dependencies, and returns them in topological install order.

func ResolveFeatureOrderWithContext added in v1.20.0

func ResolveFeatureOrderWithContext(
	ctx context.Context,
	devContainerConfig *config.DevContainerConfig,
) ([]*config.FeatureSet, error)

ResolveFeatureOrderWithContext resolves features using the caller's cancellation context for concurrent and network-backed resolution.

func ResolveSecretOptions added in v1.1.0

func ResolveSecretOptions(
	featureID string,
	featureCfg *config.FeatureConfig,
	userOptions map[string]any,
	opts *SecretOptions,
) (map[string]any, error)

ResolveSecretOptions resolves secret-typed options for a feature. For each option with type "secret", it checks (in order): user-provided value, environment variable, secrets file, default value. Returns an error if a secret is required but not provided.

func ValidateFeatureOptions added in v1.1.0

func ValidateFeatureOptions(
	featureID string,
	featureCfg *config.FeatureConfig,
	userOptions any,
) error

ValidateFeatureOptions checks that user-provided option values satisfy the type and enum constraints declared in the feature configuration.

func WriteLockfile added in v1.10.0

func WriteLockfile(path string, lf *Lockfile, frozen bool) error

WriteLockfile persists the lockfile at path.

Types

type BuildInfo

type BuildInfo struct {
	FeaturesFolder          string
	DockerfileContent       string
	OverrideTarget          string
	DockerfilePrefixContent string
	BuildArgs               map[string]string
}

type Collection added in v1.1.0

type Collection struct {
	Features []CollectionFeature `json:"features"`
}

func FetchCollection added in v1.1.0

func FetchCollection(registry, namespace string) (*Collection, error)

type CollectionFeature added in v1.1.0

type CollectionFeature struct {
	ID               string         `json:"id"`
	Version          string         `json:"version"`
	Name             string         `json:"name"`
	Description      string         `json:"description"`
	DocumentationURL string         `json:"documentationURL,omitempty"`
	Options          map[string]any `json:"options,omitempty"`
	Deprecated       bool           `json:"deprecated,omitempty"`
}

func ListCollectionFeatures added in v1.1.0

func ListCollectionFeatures(registry, namespace string) ([]CollectionFeature, error)

type ExtendedBuildInfo

type ExtendedBuildInfo struct {
	Features          []*config.FeatureSet
	FeaturesBuildInfo *BuildInfo

	MetadataConfig *config.ImageMetadataConfig
	MetadataLabel  string
}

func GetExtendedBuildInfo

func GetExtendedBuildInfo(params *ExtendedBuildParams) (*ExtendedBuildInfo, error)

type ExtendedBuildParams added in v1.1.0

type ExtendedBuildParams struct {
	ExecutionContext   context.Context
	Ctx                *config.SubstitutionContext
	ImageBuildInfo     *config.ImageBuildInfo
	Target             string
	DevContainerConfig *config.SubstitutedConfig
	ForceBuild         bool
	SecretOpts         *SecretOptions
	FrozenLockfile     bool
	NoLockfile         bool
}

type LockedFeature added in v1.10.0

type LockedFeature struct {
	Version   string   `json:"version,omitempty"`
	Resolved  string   `json:"resolved,omitempty"`
	Integrity string   `json:"integrity,omitempty"`
	DependsOn []string `json:"dependsOn,omitempty"`
}

LockedFeature is a single pinned entry in a devcontainer-lock.json file. It mirrors the structure produced by the reference devcontainer CLI.

type Lockfile added in v1.10.0

type Lockfile struct {
	Features map[string]LockedFeature `json:"features"`
}

Lockfile mirrors the devcontainer-lock.json structure: a map of feature identifier to its pinned resolution.

func ReadLockfile added in v1.10.0

func ReadLockfile(path string) (*Lockfile, error)

ReadLockfile loads the lockfile at path. A missing or empty file yields an empty lockfile rather than an error.

type SecretOptions added in v1.1.0

type SecretOptions struct {
	SecretsFile string
	Prompter    SecretPrompter
}

SecretOptions holds configuration for resolving secret-typed feature options.

type SecretPrompter added in v1.1.0

type SecretPrompter interface {
	PromptSecret(featureID, optionName string) (string, error)
}

SecretPrompter prompts the user for a secret value. Implementations should mask input when running interactively, or handle non-interactive mode (e.g. emit a warning and return an empty string).

type TerminalSecretPrompter added in v1.1.0

type TerminalSecretPrompter struct {
	IsTerminal func() bool
}

TerminalSecretPrompter prompts for secrets interactively when stdin is a terminal, and emits a warning in non-interactive mode.

func (*TerminalSecretPrompter) PromptSecret added in v1.1.0

func (p *TerminalSecretPrompter) PromptSecret(featureID, optionName string) (string, error)

Jump to

Keyboard shortcuts

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