instructions

package
v17.11.0-ce-rc2+incomp... Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 IsUnknownInstruction

func IsUnknownInstruction(err error) bool

IsUnknownInstruction checks if the error is an UnknownInstruction or a parseError containing an UnknownInstruction

func Parse

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

Parse a docker file into a collection of buildable stages

func ParseInstruction

func ParseInstruction(node *parser.Node) (interface{}, 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
	// contains filtered or unexported fields
}

AddCommand : ADD foo /path

Add the file 'foo' to '/path'. Tarball and Remote URL (git, http) 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) Name

func (c *AddCommand) Name() string

Name of the command

func (*AddCommand) String

func (c *AddCommand) String() string

type ArgCommand

type ArgCommand struct {
	Key   string
	Value *string
	// 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) 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) 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.

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) 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
}

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
	// 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) 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) 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) 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) 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
	// 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) 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 insted of map[string] string to preserve ordering)

func (*KeyValuePair) String

func (kvp *KeyValuePair) String() 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 (*LabelCommand) Expand

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

Expand variables

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) Name

func (c *MaintainerCommand) Name() string

Name of the command

func (*MaintainerCommand) String

func (c *MaintainerCommand) String() string

type OnbuildCommand

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

OnbuildCommand : ONBUILD <some other command>

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
	// 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) 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) 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
	PrependShell bool
}

ShellDependantCmdLine represents a cmdline optionaly prepended with the shell

type SingleWordExpander

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

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

type SourcesAndDest

type SourcesAndDest []string

SourcesAndDest represent a list of source files and a destination

func (SourcesAndDest) Dest

func (s SourcesAndDest) Dest() string

Dest path of the operation

func (SourcesAndDest) Sources

func (s SourcesAndDest) Sources() []string

Sources list the source paths

type Stage

type Stage struct {
	Name       string
	Commands   []Command
	BaseName   string
	SourceCode 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) 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) 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) 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) 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