Documentation
¶
Overview ¶
Package dockerfile implements static analysis and linting of Dockerfiles. It is the first capability module (CAPABILITY_SPEC domain 3). The parser is intentionally small: it splits a Dockerfile into logical instructions, honoring comments and backslash line-continuations, and records line spans so findings can point at exact locations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dockerfile ¶
type Dockerfile struct {
Instructions []Instruction
Lines []string
}
Dockerfile is a parsed Dockerfile.
func Parse ¶
func Parse(content string) *Dockerfile
Parse turns Dockerfile text into a Dockerfile. It never errors; malformed input simply yields whatever instructions could be recognized.
func (*Dockerfile) From ¶
func (d *Dockerfile) From() []Instruction
From returns all FROM instructions.
func (*Dockerfile) Has ¶
func (d *Dockerfile) Has(cmd string) bool
Has reports whether any instruction with the given command exists.
type Instruction ¶
type Instruction struct {
Cmd string // upper-cased command, e.g. "FROM", "RUN"
Args string // everything after the command, continuations joined
StartLine int // 1-based first physical line
EndLine int // 1-based last physical line
Raw string // normalized "CMD args" text
}
Instruction is one logical Dockerfile instruction (a command plus its arguments), possibly spanning multiple physical lines.