Documentation ¶
Overview ¶
Package parser implements a parser and parse tree dumper for Dockerfiles.
Index ¶
Constants ¶
const DefaultEscapeToken = '\\'
DefaultEscapeToken is the default escape token
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Directive ¶
type Directive struct {
// contains filtered or unexported fields
}
Directive is the structure used during a build run to hold the state of parsing directives.
func NewDefaultDirective ¶
func NewDefaultDirective() *Directive
NewDefaultDirective returns a new Directive with the default escapeToken token
type Node ¶
type Node struct { Value string // actual content Next *Node // the next item in the current sexp Children []*Node // the children of this sexp Attributes map[string]bool // special attributes for this node Original string // original line used before parsing Flags []string // only top Node should have this set StartLine int // the line in the original dockerfile where the node begins // contains filtered or unexported fields }
Node is a structure used to represent a parse tree.
In the node there are three fields, Value, Next, and Children. Value is the current token's string value. Next is always the next non-child token, and children contains all the children. Here's an example:
(value next (child child-next child-next-next) next-next)
This data structure is frankly pretty lousy for handling complex languages, but lucky for us the Dockerfile isn't very complicated. This structure works a little more effectively than a "proper" parse tree for our needs.
func NodeFromLabels ¶
NodeFromLabels returns a Node for the injected labels
type Result ¶
type Result struct { AST *Node EscapeToken rune // TODO @jhowardmsft - see https://github.com/moby/moby/issues/34617 // This next field will be removed in a future update for LCOW support. OS string Warnings []string }
Result is the result of parsing a Dockerfile
func Parse ¶
Parse reads lines from a Reader, parses the lines into an AST and returns the AST and escape token
func (*Result) PrintWarnings ¶
PrintWarnings to the writer