dockerfile

package
v1.5.27 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

Package dockerfile implements a minimal dockerfile parser.

Index

Constants

View Source
const VarMeta = '$'

VarMeta is the metacharacter for variables. It's not configurable.

Variables

This section is empty.

Functions

func GetLabels

func GetLabels(_ context.Context, r io.Reader) (map[string]string, error)

GetLabels parses the Dockerfile in the provided Reader and returns all discovered labels as provided by the LABEL instruction, with variables resolved and expanded.

ARG and ENV instructions are understood. This will yield different results if a build argument is supplied at build time.

Types

type Unquote

type Unquote struct {
	// contains filtered or unexported fields
}

Unquote is a text transformer that undoes one level of quoting.

It does not enforce that the entire text passed to the Transform method is a valid quoted string; leading or trailing characters or multiple consecutive quoted strings are fine.

Any unrecognized escape pairs are passed through unchanged. Multicharacter escape sequences like "\xNN" or "\NNN" or "\uNNNN" are unsupported.

func NewUnquote

func NewUnquote() *Unquote

NewUnquote returns an Unquote ready to use with the escape metacharacter set to '\'.

func (*Unquote) Escape

func (u *Unquote) Escape(r rune)

Escape changes the escape metacharacter.

This is possible to do at any time, but may be inadvisable.

func (*Unquote) Reset

func (u *Unquote) Reset()

Reset implements transform.Transformer.

func (*Unquote) Transform

func (u *Unquote) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error)

Transform implements transform.Transformer.

type Vars

type Vars struct {
	// contains filtered or unexported fields
}

Vars is a text transformer that does variable expansion as described in the Dockerfile Reference document.

It supports POSIX sh-like expansions but not in the general forms, only the ":-" (expand if unset) and ":+" (expand if set) versions.

The transformation algorithm uses an escape metacharacter in front of the variable metacharacter to allow a literal metacharacter to be passed through. Any unrecognized escapes are passed through unmodified.

func NewVars

func NewVars() *Vars

NewVars returns a Vars with the metacharacter set to '\' and no variables defined.

func (*Vars) Clear

func (v *Vars) Clear()

Clear unsets all variables.

func (*Vars) Escape

func (v *Vars) Escape(r rune)

Escape changes the escape metacharacter.

This is possible to do at any time, but may be inadvisable.

func (*Vars) Reset

func (v *Vars) Reset()

Reset implements transform.Transformer.

This method does not reset calls to Set. Use Clear to reset stored variable expansions.

func (*Vars) Set

func (v *Vars) Set(key, val string)

Set sets the variable "key" to "val".

func (*Vars) Span

func (v *Vars) Span(src []byte, atEOF bool) (int, error)

Span implements transform.SpanningTransfomer.

Callers can use this to avoid copying.

func (*Vars) Transform

func (v *Vars) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error)

Transform implements transform.Transformer.

Jump to

Keyboard shortcuts

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