parser

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2014 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildCmd added in v0.7.0

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

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

func (*BuildCmd) Message added in v0.7.0

func (b *BuildCmd) Message() string

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

func (*BuildCmd) Run added in v0.7.0

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 added in v0.7.0

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

WithOpts sets options required for the BuildCmd

type BuilderfileConvertError added in v0.7.1

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

BuilderfileConvertError is used for errors encountered while converting Bobfile versions

func (*BuilderfileConvertError) ExitCode added in v0.7.1

func (err *BuilderfileConvertError) ExitCode() int

ExitCode returns the exit code Bobfile conversion errors. It is the same value for all Bobfile conversion errors.

type BuilderfileDeprecatedStanzaError added in v0.7.2

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

BuilderfileDeprecatedStanzaError is used for errors resulting from a deprecated stanza in a Bobfile

func (*BuilderfileDeprecatedStanzaError) ExitCode added in v0.7.2

func (err *BuilderfileDeprecatedStanzaError) ExitCode() int

ExitCode returns the exit code Bobfile conversion errors. It is the same value for all Bobfile deprecated stanza errors

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 added in v0.7.0

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 added in v0.7.0

type DockerCmdOpts struct {
	DockerClient dclient.DockerClient
	Image        string
	Workdir      string
	Stdout       io.Writer
	Stderr       io.Writer
	SkipPush     bool
	ImageUUID    string
}

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

type Error added in v0.7.1

type Error interface {
	// Error returns the error message to satisfy the error interface
	Error() string

	// ExitCode returns the code that should be used when exiting as a result
	// of this error
	ExitCode() int
}

Error is an interface for any error types returned by the parser package / during the parsing process

type InstructionSet

type InstructionSet struct {
	DockerBuildOpts []string
	DockerTagOpts   []string
	Containers      []builderfile.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 OSPathError added in v0.7.1

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

OSPathError is used for any instance of os.PathError that is encountered during parsing

func (*OSPathError) ExitCode added in v0.7.1

func (err *OSPathError) ExitCode() int

ExitCode returns the exit code parser errors related to os.PathError. It is the same value for all OSPathError instances

type Parser

type Parser struct {
	*logrus.Logger
	// 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(filename string, l *logrus.Logger) *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) NextUUID

func (parser *Parser) NextUUID() (string, error)

NextUUID returns the next UUID generated by the parser's uuid generator. This will either be a random uuid (normal behavior) or the same uuid every time if the generator is "seeded" (used for tests)

func (*Parser) Parse

func (parser *Parser) Parse() (*CommandSequence, Error)

Parse further parses the Builderfile struct into an InstructionSet struct, merging the global container options into the individual container sections.

func (*Parser) RandomizeUUIDGenerator

func (parser *Parser) RandomizeUUIDGenerator()

RandomizeUUIDGenerator turns this parser's uuidGenerator into a random generator. All calls to NextUUID() will produce a random uuid after this function is called and until SeedUUIDGenerator() is called.

func (*Parser) SeedUUIDGenerator

func (parser *Parser) SeedUUIDGenerator()

SeedUUIDGenerator turns this parser's uuidGenerator into a seeded generator. All calls to NextUUID() will produce the same uuid after this function is called and until RandomizeUUIDGenerator() is called.

type PushCmd added in v0.7.0

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 added in v0.7.0

func (p *PushCmd) Message() string

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

func (*PushCmd) Run added in v0.7.0

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

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

func (*PushCmd) WithOpts added in v0.7.0

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
	Included   []string
	Excluded   []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 TOMLParseError added in v0.7.1

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

TOMLParseError is used for errors related to parsing a .toml file

func (*TOMLParseError) ExitCode added in v0.7.1

func (err *TOMLParseError) ExitCode() int

ExitCode returns the exit code for toml parsing errors. It is the same value for all toml parsing errors.

type TagCmd added in v0.7.0

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 added in v0.7.0

func (t *TagCmd) Message() string

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

func (*TagCmd) Run added in v0.7.0

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

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

func (*TagCmd) WithOpts added in v0.7.0

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

WithOpts sets options required for the TagCmd

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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