devcontainer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImageFromDockerfile

func ImageFromDockerfile(dockerfileContent string) (name.Reference, error)

ImageFromDockerfile inspects the contents of a provided Dockerfile and returns the image that will be used to run the container.

func UserFromDockerfile

func UserFromDockerfile(dockerfileContent string) string

UserFromDockerfile inspects the contents of a provided Dockerfile and returns the user that will be used to run the container.

func UserFromImage

func UserFromImage(ref name.Reference) (string, error)

UserFromImage inspects the remote reference and returns the user that will be used to run the container.

Types

type BuildSpec

type BuildSpec struct {
	Dockerfile string            `json:"dockerfile"`
	Context    string            `json:"context"`
	Args       map[string]string `json:"args"`
	Target     string            `json:"target"`
	CacheFrom  string            `json:"cache_from"`
}

type Compiled

type Compiled struct {
	DockerfilePath    string
	DockerfileContent string
	BuildContext      string
	BuildArgs         []string

	User string
	Env  []string
}

Compiled is the result of compiling a devcontainer.json file.

type Spec

type Spec struct {
	Image      string            `json:"image"`
	Build      BuildSpec         `json:"build"`
	RemoteUser string            `json:"remoteUser"`
	RemoteEnv  map[string]string `json:"remoteEnv"`
	// Features is a map of feature names to feature configurations.
	Features map[string]map[string]any `json:"features"`

	// Deprecated but still frequently used...
	Dockerfile string `json:"dockerFile"`
	Context    string `json:"context"`
}

func Parse

func Parse(content []byte) (*Spec, error)

Parse parses a devcontainer.json file.

func (*Spec) Compile

func (s *Spec) Compile(fs billy.Filesystem, devcontainerDir, scratchDir, fallbackDockerfile string) (*Compiled, error)

Compile returns the build parameters for the workspace. devcontainerDir is the path to the directory where the devcontainer.json file is located. scratchDir is the path to the directory where the Dockerfile will be written to if one doesn't exist.

func (Spec) HasDockerfile added in v0.1.5

func (s Spec) HasDockerfile() bool

HasDockerfile returns true if the devcontainer.json specifies the path to a Dockerfile.

func (Spec) HasImage added in v0.1.5

func (s Spec) HasImage() bool

HasImage returns true if the devcontainer.json specifies an image.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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