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

containerdef

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package containerdef reads what a devcontainer.json declares its container is made from: an image it pulls, a Dockerfile it builds, or a Compose service it attaches to. It reads the declaration and nothing else — resolving it is the caller's, whether that is the merge fetching what the declaration names or a lint rule reading it from the linted directory.

Each declaration carries the byte offset of the property name declaring it, so a caller can anchor what it reports at where the declaration is written.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Defs

func Defs(obj *hujson.Object) iter.Seq[Def]

Defs yields the container definitions obj declares, in the order the reference implementation resolves them: the Compose declaration, then the Dockerfile build, then the image. Each is read as it is reached, so a caller that stops at the first reads no further than it.

Only one form is valid at a time, so the order matters only for a configuration declaring several. A caller resolving the container the configuration produces takes the first; one reading everything the configuration names takes them all.

Types

type BuildDef

type BuildDef struct {
	// Dockerfile is the Dockerfile's path, relative to the devcontainer.json.
	Dockerfile string
	// DockerfileKeyOffset is the byte offset of the property naming the Dockerfile, whichever of the
	// two names it.
	DockerfileKeyOffset int
	// Args are the arguments passed to the build, nil when it declares none.
	Args map[string]string
	// Target is the stage the build stops at, empty when it declares none.
	Target string
}

BuildDef is the Dockerfile build a devcontainer.json declares: the Dockerfile it builds and the options shaping what that build produces. They are read together because the options say nothing without the Dockerfile they shape.

type ComposeDef

type ComposeDef struct {
	// Files are the Compose file paths, in the order declared, later ones overriding earlier ones.
	// It is empty when the declaration names no readable path.
	Files []string
	// FilesKeyOffset is the byte offset of the "dockerComposeFile" property name.
	FilesKeyOffset int
	// Service is the service the dev container runs in, empty when the configuration names none or
	// names it as something other than a string.
	Service string
}

ComposeDef is the Compose declaration of a devcontainer.json: the files it names and the service the dev container runs in. The two are read together because neither settles anything alone — a configuration that names files but no service says which Compose project it belongs to and not which container it is.

func (ComposeDef) Usable

func (c ComposeDef) Usable() bool

Usable reports whether the declaration settles a container: a service to attach to, and at least one file that may define it. A caller that resolves the container reads nothing for a declaration that does not, and must not fall back to another form on it.

type Def

type Def interface {
	// contains filtered or unexported methods
}

Def is one form a devcontainer.json declares its container in: *ImageDef, *BuildDef or *ComposeDef. A caller tells them apart with a type switch.

type ImageDef

type ImageDef struct {
	// Ref is the image reference as written.
	Ref string
	// KeyOffset is the byte offset of the "image" property name.
	KeyOffset int
}

ImageDef is an image the configuration pulls, as "image" names it.

Jump to

Keyboard shortcuts

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