Documentation ¶
Overview ¶
Package dockerfile has utilities that complement Docker's official Dockerfile parser.
Index ¶
- func Env(m []KeyValue) (string, error)
- func FindAll(node *parser.Node, cmd string) []int
- func From(image string) (string, error)
- func InsertInstructions(node *parser.Node, pos int, instructions string) error
- func Label(m []KeyValue) (string, error)
- func LastBaseImage(node *parser.Node) string
- func LastExposedPorts(node *parser.Node) []string
- func Parse(r io.Reader) (*parser.Node, error)
- func ParseTreeToDockerfile(node *parser.Node) []byte
- type KeyValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Env ¶
Env builds an ENV Dockerfile instruction from the mapping m. Keys and values are serialized as JSON strings to ensure compatibility with the Dockerfile parser.
func FindAll ¶
FindAll returns the indices of all children of node such that node.Children[i].Value == cmd. Valid values for cmd are defined in the package github.com/docker/docker/builder/dockerfile/command.
func InsertInstructions ¶
InsertInstructions inserts instructions starting from the pos-th child of node, moving other children as necessary. The instructions should be valid Dockerfile instructions. InsertInstructions mutates node in-place, and the final state of node is equivalent to what parser.Parse would return if the original Dockerfile represented by node contained the instructions at the specified position pos. If the returned error is non-nil, node is guaranteed to be unchanged.
func Label ¶
Label builds a LABEL Dockerfile instruction from the mapping m. Keys and values are serialized as JSON strings to ensure compatibility with the Dockerfile parser.
func LastBaseImage ¶
LastBaseImage takes a Dockerfile root node and returns the base image declared in the last FROM instruction.
func LastExposedPorts ¶
LastExposedPorts takes a Dockerfile root node and returns a list of ports exposed in the last image built by the Dockerfile, i.e., only the EXPOSE instructions after the last FROM instruction are considered.
func ParseTreeToDockerfile ¶
ParseTreeToDockerfile takes a Dockerfile AST node, as generated by parser.Parse, and returns a new, equivalent, Dockerfile.