instructions

package
v0.9.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: Apache-2.0 Imports: 13 Imported by: 231

Documentation

Index

Constants

View Source
const (
	NetworkDefault = "default"
	NetworkNone    = "none"
	NetworkHost    = "host"
)
View Source
const MountSharingLocked = "locked"
View Source
const MountSharingPrivate = "private"
View Source
const MountSharingShared = "shared"
View Source
const MountTypeBind = "bind"
View Source
const MountTypeCache = "cache"
View Source
const MountTypeSSH = "ssh"
View Source
const MountTypeSecret = "secret"
View Source
const MountTypeTmpfs = "tmpfs"

Variables

This section is empty.

Functions

func GetNetwork added in v0.9.0

func GetNetwork(cmd *RunCommand) string

func HasStage

func HasStage(s []Stage, name string) (int, bool)

HasStage looks for the presence of a given stage name

func IsCurrentStage

func IsCurrentStage(s []Stage, name string) bool

IsCurrentStage check if the stage name is the current stage

func Parse

func Parse(ast *parser.Node) (stages []Stage, metaArgs []ArgCommand, err error)

Parse a Dockerfile into a collection of buildable stages. metaArgs is a collection of ARG instructions that occur before the first FROM.

func ParseInstruction

func ParseInstruction(node *parser.Node) (v interface{}, err error)

ParseInstruction converts an AST to a typed instruction (either a command or a build stage beginning when encountering a `FROM` statement)

Types

type AddCommand

type AddCommand struct {
	SourcesAndDest
	Chown string
	Chmod string
	// contains filtered or unexported fields
}

AddCommand : ADD foo /path

Add the file 'foo' to '/path'. Tarball and Remote URL (http, https) handling exist here. If you do not wish to have this automatic handling, use COPY.

func (*AddCommand) Expand

func (c *AddCommand) Expand(expander SingleWordExpander) error

Expand variables

func (*AddCommand) Location added in v0.8.0

func (c *AddCommand) Location() []parser.Range

Location of the command in source

func (*AddCommand) Name

func (c *AddCommand) Name() string

Name of the command

func (*AddCommand) String

func (c *AddCommand) String() string

type ArgCommand

type ArgCommand struct {
	Args []KeyValuePairOptional
	// contains filtered or unexported fields
}

ArgCommand : ARG name[=value]

Adds the variable foo to the trusted list of variables that can be passed to builder using the --build-arg flag for expansion/substitution or passing to 'run'. Dockerfile author may optionally set a default value of this variable.

func (*ArgCommand) Expand

func (c *ArgCommand) Expand(expander SingleWordExpander) error

Expand variables

func (*ArgCommand) Location added in v0.8.0

func (c *ArgCommand) Location() []parser.Range

Location of the command in source

func (*ArgCommand) Name

func (c *ArgCommand) Name() string

Name of the command

func (*ArgCommand) String

func (c *ArgCommand) String() string

type BFlags

type BFlags struct {
	Args []string // actual flags/args from cmd line

	Err error
	// contains filtered or unexported fields
}

BFlags contains all flags information for the builder

func NewBFlags

func NewBFlags() *BFlags

NewBFlags returns the new BFlags struct

func NewBFlagsWithArgs

func NewBFlagsWithArgs(args []string) *BFlags

NewBFlagsWithArgs returns the new BFlags struct with Args set to args

func (*BFlags) AddBool

func (bf *BFlags) AddBool(name string, def bool) *Flag

AddBool adds a bool flag to BFlags Note, any error will be generated when Parse() is called (see Parse).

func (*BFlags) AddString

func (bf *BFlags) AddString(name string, def string) *Flag

AddString adds a string flag to BFlags Note, any error will be generated when Parse() is called (see Parse).

func (*BFlags) AddStrings

func (bf *BFlags) AddStrings(name string) *Flag

AddStrings adds a string flag to BFlags that can match multiple values

func (*BFlags) Parse

func (bf *BFlags) Parse() error

Parse parses and checks if the BFlags is valid. Any error noticed during the AddXXX() funcs will be generated/returned here. We do this because an error during AddXXX() is more like a compile time error so it doesn't matter too much when we stop our processing as long as we do stop it, so this allows the code around AddXXX() to be just:

defFlag := AddString("description", "")

w/o needing to add an if-statement around each one.

func (*BFlags) Used added in v0.8.2

func (bf *BFlags) Used() []string

Used returns a slice of flag names that are set

type CmdCommand

type CmdCommand struct {
	ShellDependantCmdLine
	// contains filtered or unexported fields
}

CmdCommand : CMD foo

Set the default command to run in the container (which may be empty). Argument handling is the same as RUN.

func (*CmdCommand) Location added in v0.8.0

func (c *CmdCommand) Location() []parser.Range

Location of the command in source

func (*CmdCommand) Name

func (c *CmdCommand) Name() string

Name of the command

func (*CmdCommand) String

func (c *CmdCommand) String() string

type Command

type Command interface {
	Name() string
	Location() []parser.Range
}

Command is implemented by every command present in a dockerfile

func ParseCommand

func ParseCommand(node *parser.Node) (Command, error)

ParseCommand converts an AST to a typed Command

type CopyCommand

type CopyCommand struct {
	SourcesAndDest
	From  string
	Chown string
	Chmod string
	// contains filtered or unexported fields
}

CopyCommand : COPY foo /path

Same as 'ADD' but without the tar and remote url handling.

func (*CopyCommand) Expand

func (c *CopyCommand) Expand(expander SingleWordExpander) error

Expand variables

func (*CopyCommand) Location added in v0.8.0

func (c *CopyCommand) Location() []parser.Range

Location of the command in source

func (*CopyCommand) Name

func (c *CopyCommand) Name() string

Name of the command

func (*CopyCommand) String

func (c *CopyCommand) String() string

type EntrypointCommand

type EntrypointCommand struct {
	ShellDependantCmdLine
	// contains filtered or unexported fields
}

EntrypointCommand : ENTRYPOINT /usr/sbin/nginx

Set the entrypoint to /usr/sbin/nginx. Will accept the CMD as the arguments to /usr/sbin/nginx. Uses the default shell if not in JSON format.

Handles command processing similar to CMD and RUN, only req.runConfig.Entrypoint is initialized at newBuilder time instead of through argument parsing.

func (*EntrypointCommand) Location added in v0.8.0

func (c *EntrypointCommand) Location() []parser.Range

Location of the command in source

func (*EntrypointCommand) Name

func (c *EntrypointCommand) Name() string

Name of the command

func (*EntrypointCommand) String

func (c *EntrypointCommand) String() string

type EnvCommand

type EnvCommand struct {
	Env KeyValuePairs // kvp slice instead of map to preserve ordering
	// contains filtered or unexported fields
}

EnvCommand : ENV key1 value1 [keyN valueN...]

func (*EnvCommand) Expand

func (c *EnvCommand) Expand(expander SingleWordExpander) error

Expand variables

func (*EnvCommand) Location added in v0.8.0

func (c *EnvCommand) Location() []parser.Range

Location of the command in source

func (*EnvCommand) Name

func (c *EnvCommand) Name() string

Name of the command

func (*EnvCommand) String

func (c *EnvCommand) String() string

type ExposeCommand

type ExposeCommand struct {
	Ports []string
	// contains filtered or unexported fields
}

ExposeCommand : EXPOSE 6667/tcp 7000/tcp

Expose ports for links and port mappings. This all ends up in req.runConfig.ExposedPorts for runconfig.

func (*ExposeCommand) Location added in v0.8.0

func (c *ExposeCommand) Location() []parser.Range

Location of the command in source

func (*ExposeCommand) Name

func (c *ExposeCommand) Name() string

Name of the command

func (*ExposeCommand) String

func (c *ExposeCommand) String() string

type Flag

type Flag struct {
	Value        string
	StringValues []string
	// contains filtered or unexported fields
}

Flag contains all information for a flag

func (*Flag) IsTrue

func (fl *Flag) IsTrue() bool

IsTrue checks if a bool flag is true

func (*Flag) IsUsed

func (fl *Flag) IsUsed() bool

IsUsed checks if the flag is used

type FlagType

type FlagType int

FlagType is the type of the build flag

type HealthCheckCommand

type HealthCheckCommand struct {
	Health *container.HealthConfig
	// contains filtered or unexported fields
}

HealthCheckCommand : HEALTHCHECK foo

Set the default healthcheck command to run in the container (which may be empty). Argument handling is the same as RUN.

func (*HealthCheckCommand) Location added in v0.8.0

func (c *HealthCheckCommand) Location() []parser.Range

Location of the command in source

func (*HealthCheckCommand) Name

func (c *HealthCheckCommand) Name() string

Name of the command

func (*HealthCheckCommand) String

func (c *HealthCheckCommand) String() string

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
}

KeyValuePair represent an arbitrary named value (useful in slice instead of map[string] string to preserve ordering)

func (*KeyValuePair) String

func (kvp *KeyValuePair) String() string

type KeyValuePairOptional

type KeyValuePairOptional struct {
	Key     string
	Value   *string
	Comment string
}

KeyValuePairOptional is the same as KeyValuePair but Value is optional

func (*KeyValuePairOptional) ValueString

func (kvpo *KeyValuePairOptional) ValueString() string

type KeyValuePairs

type KeyValuePairs []KeyValuePair

KeyValuePairs is a slice of KeyValuePair

type LabelCommand

type LabelCommand struct {
	Labels KeyValuePairs // kvp slice instead of map to preserve ordering
	// contains filtered or unexported fields
}

LabelCommand : LABEL some json data describing the image

Sets the Label variable foo to bar,

func NewLabelCommand

func NewLabelCommand(k string, v string, NoExp bool) *LabelCommand

NewLabelCommand creates a new 'LABEL' command

func (*LabelCommand) Expand

func (c *LabelCommand) Expand(expander SingleWordExpander) error

Expand variables

func (*LabelCommand) Location added in v0.8.0

func (c *LabelCommand) Location() []parser.Range

Location of the command in source

func (*LabelCommand) Name

func (c *LabelCommand) Name() string

Name of the command

func (*LabelCommand) String

func (c *LabelCommand) String() string

type MaintainerCommand

type MaintainerCommand struct {
	Maintainer string
	// contains filtered or unexported fields
}

MaintainerCommand : MAINTAINER maintainer_name

func (*MaintainerCommand) Location added in v0.8.0

func (c *MaintainerCommand) Location() []parser.Range

Location of the command in source

func (*MaintainerCommand) Name

func (c *MaintainerCommand) Name() string

Name of the command

func (*MaintainerCommand) String

func (c *MaintainerCommand) String() string

type Mount added in v0.8.0

type Mount struct {
	Type         string
	From         string
	Source       string
	Target       string
	ReadOnly     bool
	CacheID      string
	CacheSharing string
	Required     bool
	Mode         *uint64
	UID          *uint64
	GID          *uint64
}

func GetMounts added in v0.8.0

func GetMounts(cmd *RunCommand) []*Mount

type OnbuildCommand

type OnbuildCommand struct {
	Expression string
	// contains filtered or unexported fields
}

OnbuildCommand : ONBUILD <some other command>

func (*OnbuildCommand) Location added in v0.8.0

func (c *OnbuildCommand) Location() []parser.Range

Location of the command in source

func (*OnbuildCommand) Name

func (c *OnbuildCommand) Name() string

Name of the command

func (*OnbuildCommand) String

func (c *OnbuildCommand) String() string

type PlatformSpecific

type PlatformSpecific interface {
	CheckPlatform(platform string) error
}

PlatformSpecific adds platform checks to a command

type RunCommand

type RunCommand struct {
	ShellDependantCmdLine
	FlagsUsed []string
	// contains filtered or unexported fields
}

RunCommand : RUN some command yo

run a command and commit the image. Args are automatically prepended with the current SHELL which defaults to 'sh -c' under linux or 'cmd /S /C' under Windows, in the event there is only one argument The difference in processing:

RUN echo hi # sh -c echo hi (Linux) RUN echo hi # cmd /S /C echo hi (Windows) RUN [ "echo", "hi" ] # echo hi

func (*RunCommand) Expand added in v0.9.0

func (c *RunCommand) Expand(expander SingleWordExpander) error

func (*RunCommand) Location added in v0.8.0

func (c *RunCommand) Location() []parser.Range

Location of the command in source

func (*RunCommand) Name

func (c *RunCommand) Name() string

Name of the command

func (*RunCommand) String

func (c *RunCommand) String() string

type ShellCommand

type ShellCommand struct {
	Shell strslice.StrSlice
	// contains filtered or unexported fields
}

ShellCommand : SHELL powershell -command

Set the non-default shell to use.

func (*ShellCommand) Location added in v0.8.0

func (c *ShellCommand) Location() []parser.Range

Location of the command in source

func (*ShellCommand) Name

func (c *ShellCommand) Name() string

Name of the command

func (*ShellCommand) String

func (c *ShellCommand) String() string

type ShellDependantCmdLine

type ShellDependantCmdLine struct {
	CmdLine      strslice.StrSlice
	Files        []ShellInlineFile
	PrependShell bool
}

ShellDependantCmdLine represents a cmdline optionally prepended with the shell

type ShellInlineFile added in v0.9.0

type ShellInlineFile struct {
	Name  string
	Data  string
	Chomp bool
}

ShellInlineFile represents an inline file created for a shell command

type SingleWordExpander

type SingleWordExpander func(word string) (string, error)

SingleWordExpander is a provider for variable expansion where 1 word => 1 output

type SourceContent added in v0.9.0

type SourceContent struct {
	Path   string
	Data   string
	Expand bool
}

SourceContent represents an anonymous file object

type SourcesAndDest

type SourcesAndDest struct {
	DestPath       string
	SourcePaths    []string
	SourceContents []SourceContent
}

SourcesAndDest represent a collection of sources and a destination

func (*SourcesAndDest) Expand added in v0.9.0

func (s *SourcesAndDest) Expand(expander SingleWordExpander) error

type Stage

type Stage struct {
	Name       string
	Commands   []Command
	BaseName   string
	SourceCode string
	Platform   string
	Location   []parser.Range
	Comment    string
}

Stage represents a single stage in a multi-stage build

func CurrentStage

func CurrentStage(s []Stage) (*Stage, error)

CurrentStage return the last stage in a slice

func (*Stage) AddCommand

func (s *Stage) AddCommand(cmd Command)

AddCommand to the stage

type StopSignalCommand

type StopSignalCommand struct {
	Signal string
	// contains filtered or unexported fields
}

StopSignalCommand : STOPSIGNAL signal

Set the signal that will be used to kill the container.

func (*StopSignalCommand) CheckPlatform

func (c *StopSignalCommand) CheckPlatform(platform string) error

CheckPlatform checks that the command is supported in the target platform

func (*StopSignalCommand) Expand

func (c *StopSignalCommand) Expand(expander SingleWordExpander) error

Expand variables

func (*StopSignalCommand) Location added in v0.8.0

func (c *StopSignalCommand) Location() []parser.Range

Location of the command in source

func (*StopSignalCommand) Name

func (c *StopSignalCommand) Name() string

Name of the command

func (*StopSignalCommand) String

func (c *StopSignalCommand) String() string

type SupportsSingleWordExpansion

type SupportsSingleWordExpansion interface {
	Expand(expander SingleWordExpander) error
}

SupportsSingleWordExpansion interface marks a command as supporting variable expansion

type UnknownInstruction

type UnknownInstruction struct {
	Line        int
	Instruction string
}

UnknownInstruction represents an error occurring when a command is unresolvable

func (*UnknownInstruction) Error

func (e *UnknownInstruction) Error() string

type UserCommand

type UserCommand struct {
	User string
	// contains filtered or unexported fields
}

UserCommand : USER foo

Set the user to 'foo' for future commands and when running the ENTRYPOINT/CMD at container run time.

func (*UserCommand) Expand

func (c *UserCommand) Expand(expander SingleWordExpander) error

Expand variables

func (*UserCommand) Location added in v0.8.0

func (c *UserCommand) Location() []parser.Range

Location of the command in source

func (*UserCommand) Name

func (c *UserCommand) Name() string

Name of the command

func (*UserCommand) String

func (c *UserCommand) String() string

type VolumeCommand

type VolumeCommand struct {
	Volumes []string
	// contains filtered or unexported fields
}

VolumeCommand : VOLUME /foo

Expose the volume /foo for use. Will also accept the JSON array form.

func (*VolumeCommand) Expand

func (c *VolumeCommand) Expand(expander SingleWordExpander) error

Expand variables

func (*VolumeCommand) Location added in v0.8.0

func (c *VolumeCommand) Location() []parser.Range

Location of the command in source

func (*VolumeCommand) Name

func (c *VolumeCommand) Name() string

Name of the command

func (*VolumeCommand) String

func (c *VolumeCommand) String() string

type WorkdirCommand

type WorkdirCommand struct {
	Path string
	// contains filtered or unexported fields
}

WorkdirCommand : WORKDIR /tmp

Set the working directory for future RUN/CMD/etc statements.

func (*WorkdirCommand) Expand

func (c *WorkdirCommand) Expand(expander SingleWordExpander) error

Expand variables

func (*WorkdirCommand) Location added in v0.8.0

func (c *WorkdirCommand) Location() []parser.Range

Location of the command in source

func (*WorkdirCommand) Name

func (c *WorkdirCommand) Name() string

Name of the command

func (*WorkdirCommand) String

func (c *WorkdirCommand) String() string

Jump to

Keyboard shortcuts

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