parser

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2014 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildCmd

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

BuildCmd is a wrapper for the os/exec call for `docker build`

func (*BuildCmd) Message

func (b *BuildCmd) Message() string

Message returns the shell command that gets run for docker build commands

func (*BuildCmd) Run

func (b *BuildCmd) Run() (string, error)

Run is the command that actually calls docker build shell command. Determine the image ID for the resulting image and return that as well.

func (*BuildCmd) WithOpts

func (b *BuildCmd) WithOpts(opts *DockerCmdOpts) DockerCmd

WithOpts sets options required for the BuildCmd

type CommandSequence

type CommandSequence struct {
	Commands []*SubSequence
}

A CommandSequence is an intermediate data type in the parsing process. Once a Builderfile is parsed into an InstructionSet, it is further parsed into a CommandSequence, which is essential an array of strings where each string is a command to be run.

type DockerCmd

type DockerCmd interface {
	// Run() runs the underlying command. The string return value is expected
	// to be the ID of the image being operated on
	Run() (string, error)

	// Message() returns a string representation of the command if it were to
	// be run on the command line
	Message() string

	// WithOpts sets the options for the command. It is expected to return the
	// same DockerCmd in a state in which the Run() function can be called
	// immediately after without error (i.e.`dockerCmdInstance.WithOpts(opts).Run()`)
	WithOpts(opts *DockerCmdOpts) DockerCmd
}

DockerCmd is an interface that wraps the various docker command types.

type DockerCmdOpts

type DockerCmdOpts struct {
	DockerClient dockerclient.DockerClient
	Image        string
	Workdir      string
	Stdout       io.Writer
	Stderr       io.Writer
	SkipPush     bool
	ImageUUID    string
	Reporter     *comm.Reporter
}

DockerCmdOpts is an options struct for the options required by the various structs that implement the DockerCmd interface

type InstructionSet

type InstructionSet struct {
	DockerBuildOpts []string
	DockerTagOpts   []string
	Containers      []unitconfig.ContainerSection
}

An InstructionSet is an intermediate datatype - once a Builderfile is parsed and the TOML is validated, the parser parses the data into an InstructionSet. The primary purpose of this step is to merge any global container options into the sections for the individual containers.

type NewParserOptions

type NewParserOptions struct {
	ContextDir string
	Log        comm.LogChan
	Event      comm.EventChan
}

NewParserOptions encapsulates all of the options necessary when creating a new parser

type NilClientError added in v0.2.0

type NilClientError struct{}

NilClientError is the error returned by any Run() command if the underlying docker client is nil

func (NilClientError) Error added in v0.2.0

func (err NilClientError) Error() string

type Parser

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

Parser is a struct that contains a Builderfile and knows how to parse it both as raw text and to convert toml to a Builderfile struct. It also knows how to tell if the Builderfile is valid (openable) or nat.

func NewParser

func NewParser(opts NewParserOptions) *Parser

NewParser returns an initialized Parser. Not currently necessary, as no default values are assigned to a new Parser, but useful to have in case we need to change this.

func (*Parser) Parse

func (parser *Parser) Parse(file *unitconfig.UnitConfig) *CommandSequence

Parse - does the parsing!

type PushCmd

type PushCmd struct {
	PushFunc     func(opts docker.PushImageOptions, auth docker.AuthConfiguration) error
	Image        string
	Tag          string
	Registry     string
	AuthUn       string
	AuthPwd      string
	AuthEmail    string
	OutputStream io.Writer
	// contains filtered or unexported fields
}

PushCmd is a wrapper for the docker PushImage functionality

func (*PushCmd) Message

func (p *PushCmd) Message() string

Message returns the shell command that would be equivalent to the PushImage command

func (*PushCmd) Run

func (p *PushCmd) Run() (string, error)

Run is the command that actually calls PushImage to do the pushing

func (*PushCmd) WithOpts

func (p *PushCmd) WithOpts(opts *DockerCmdOpts) DockerCmd

WithOpts sets options required for the PushCmd

type SubSequence

type SubSequence struct {
	Metadata   *SubSequenceMetadata
	SubCommand []DockerCmd
}

A SubSequence is a logical grouping of commands such as a sequence of build, tag, and push commands. In addition, the subsequence metadata contains any important metadata about the container build such as the name of the Dockerfile and which files/dirs to exclude.

type SubSequenceMetadata

type SubSequenceMetadata struct {
	Name       string
	Dockerfile string
	UUID       string
	SkipPush   bool
}

SubSequenceMetadata contains any important metadata about the container build such as the name of the Dockerfile and which files/dirs to exclude.

type Tag

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

Tag is for tagging

func NewTag

func NewTag(value string) Tag

NewTag returns a Tag instance. See function implementation for details on what args to pass.

func (Tag) Evaluate

func (t Tag) Evaluate(top string) string

Evaluate evaluates any git-based tags

type TagCmd

type TagCmd struct {
	TagFunc func(name string, opts docker.TagImageOptions) error
	Image   string
	Force   bool
	Tag     string
	Repo    string
	// contains filtered or unexported fields
}

TagCmd is a wrapper for the docker TagImage functionality

func (*TagCmd) Message

func (t *TagCmd) Message() string

Message returns the shell command that would be equivalent to the TagImage command

func (*TagCmd) Run

func (t *TagCmd) Run() (string, error)

Run is the command that actually calls TagImage to do the tagging

func (*TagCmd) WithOpts

func (t *TagCmd) WithOpts(opts *DockerCmdOpts) DockerCmd

WithOpts sets options required for the TagCmd

Jump to

Keyboard shortcuts

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