command

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2017 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const DockerfileAsset = "assets/Dockerfile"

DockerfileAsset defines a asset name for Dockerfile.

View Source
const EntrypointAsset = "assets/entrypoint"

EntrypointAsset defines a asset name for entrypoint.sh.

View Source
const SourceArchive = "source.tar.gz"

SourceArchive defines a name of source archive file.

Variables

View Source
var (
	// ErrUnknownPythonVersion is returned when the given python version is not
	// supported.
	ErrUnknownPythonVersion = fmt.Errorf("Given Python version is not supported")
)

Functions

func Archive

func Archive(ctx context.Context, dir string, filename string) (err error)

Archive makes a tar.gz file consists of files maintained a git repository.

func Asset added in v0.3.1

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir added in v0.3.1

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo added in v0.3.1

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames added in v0.3.1

func AssetNames() []string

AssetNames returns the names of the assets.

func Build

func Build(ctx context.Context, dir, tag, version string, noCache bool, output io.Writer) (err error)

Build builds a docker image from a directory. The built image named tag. The directory must have Dockerfile.

func Dockerfile added in v0.3.0

func Dockerfile(travis *Travis, opt *DockerfileOpt, archive string) (res []byte, err error)

Dockerfile creates a Dockerfile from an instance of Travis.

func Entrypoint

func Entrypoint(travis *Travis) (res []byte, err error)

Entrypoint creates an entrypoint.sh from an instance of Travis.

func MustAsset added in v0.3.1

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func PrepareBaseImage added in v0.5.0

func PrepareBaseImage(ctx context.Context, ref string, output io.Writer) (err error)

PrepareBaseImage pulls a docker images represented by the given ref if necessary; it also writes summarized lorring information to the given output.

func RestoreAsset added in v0.3.1

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets added in v0.3.1

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func Run

func Run(c *cli.Context) error

Run implements the action of this command.

func Start

func Start(ctx context.Context, tag, name string, env []string, output io.Writer) (err error)

Start runs a container to run tests with a given context. This function creates a container from the image of the given tag name, and the created container has the given name. If the given name is empty, the container will have a random temporary name and be deleted after after all steps end. env is a list of environment variables to be passed to the created container.

Types

type Display added in v0.5.0

type Display struct {
	MaxSection int
	Title      string
	Header     *Header
	// contains filtered or unexported fields
}

Display represents a display which consists of several sections.

func NewDisplay added in v0.5.0

func NewDisplay(ctx context.Context, title string, maxSection int) (display *Display, nctx context.Context, err error)

NewDisplay creates a new display.

func (*Display) AddSection added in v0.5.0

func (d *Display) AddSection(header string) *Section

AddSection adds a new section to this display.

func (*Display) Close added in v0.5.0

func (d *Display) Close() (err error)

Close closes this display.

func (*Display) DeleteSection added in v0.5.0

func (d *Display) DeleteSection(sec *Section)

DeleteSection deletes the given section from this display.

func (*Display) Layout added in v0.5.0

func (d *Display) Layout(g *gocui.Gui) error

Layout is called every time the GUI is redrawn, it must contain the base views and its initializations.

type DisplayUpdateFunc added in v0.5.0

type DisplayUpdateFunc func(handler DisplayUpdateHandler)

DisplayUpdateFunc is a function which a section calls to update the section body.

type DisplayUpdateHandler added in v0.5.0

type DisplayUpdateHandler func(view *gocui.View)

DisplayUpdateHandler defines a handler function to update section body.

type DockerfileOpt added in v0.2.0

type DockerfileOpt struct {
	// Customize FROM clause.
	BaseImage string
	// Git repository.
	Repository string
	// URL for an Apt proxy.
	AptProxy string
	// URL for a pypi proxy.
	PypiProxy string
	// URL for a HTTP proxy.
	HTTPProxy string
	// URL for a HTTPS proxy.
	HTTPSProxy string
	// Comma separated URL lists.
	NoProxy string
}

DockerfileOpt defines option variables used in Dockerfile templates.

type Env added in v0.4.0

type Env struct {
	Global []string `yaml:"global,omitempty"`
	Matrix []string `yaml:"matrix,omitempty"`
}

Env defines the full structure of a definition of environment variables.

func (*Env) UnmarshalYAML added in v0.4.2

func (e *Env) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

UnmarshalYAML defines a way to unmarshal variables of Env.

type ErrorSet added in v0.5.0

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

ErrorSet is a goroutine-safe set of errors. Each error in this set has a key and GetList function returns a list of errors according to the order of keys.

func NewErrorSet added in v0.5.0

func NewErrorSet() *ErrorSet

NewErrorSet creates a new ErrorSet.

func (*ErrorSet) Add added in v0.5.0

func (e *ErrorSet) Add(key string, err error)

Add a new error with a key string.

func (*ErrorSet) GetList added in v0.5.0

func (e *ErrorSet) GetList() []error

GetList returns a list of errors in this set; the list is sorted by the order of keys.

func (*ErrorSet) Size added in v0.5.0

func (e *ErrorSet) Size() int

Size returns the number of errors in this set.

type Header struct {
	Logger io.Writer
	// contains filtered or unexported fields
}

Header represents a header space in a display.

type ListOrString added in v0.4.2

type ListOrString []string

ListOrString defines an ambiguous type for YAML document, which can take a list of strings by default but also a single string literal.

func (*ListOrString) UnmarshalYAML added in v0.4.2

func (e *ListOrString) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

UnmarshalYAML defines a way to unmarshal variables of ListOrString.

type Matrix added in v0.3.0

type Matrix struct {
	Include []interface{} `yaml:"include,omitempty"`
	Exclude []interface{} `yaml:"exclude,omitempty"`
}

Matrix defines the structure of matrix element in .travis.yml.

type RunOpt added in v0.1.2

type RunOpt struct {
	// Same options as DockerfileOpt.
	*DockerfileOpt
	// Travis configuration file.
	Filename string
	// Container name.
	Name string
	// Runtime version to which only versions matching will be run.
	Version string
	// Image tag.
	Tag string
	// Max processors to be used.
	Processors int
	// If true, logging information to be stored to files.
	OutputLog bool
	// If true, not using cache during buidling a docker image.
	NoCache bool
	// If true, omit printing color codes.
	NoColor bool
	// Printed on the header.
	Title string
}

RunOpt defines a option parameter for run function.

type Section added in v0.5.0

type Section struct {
	Header string
	Body   []string
	// contains filtered or unexported fields
}

Section represents a section in a display. Each section has a header text and several strings as the body.

func (*Section) String added in v0.5.0

func (s *Section) String() string

String returns a string representing this section.

func (*Section) Writer added in v0.5.0

func (s *Section) Writer() io.WriteCloser

Writer returns io.WriteCloser to write messages into the section. Users have to close the returned writer.

type TestCase added in v0.5.2

type TestCase map[string]string

TestCase is a set of environment variables and represented as a map of which a key is a name of one environment variable and the associated value is the value of the variable.

func (TestCase) Copy added in v0.5.2

func (c TestCase) Copy() TestCase

Copy returns a hard copy of this test case.

func (TestCase) Match added in v0.5.2

func (c TestCase) Match(o TestCase) bool

Match returns true if and only if the given TestCase has same configuration as this test case.

func (TestCase) Merge added in v0.5.2

func (c TestCase) Merge(o TestCase) TestCase

Merge updates this TestCase so that it also has key and values defined in the given test case. If both test cases have a same key, the value associated with the key will be overwritten by the value in the given test case.

func (TestCase) Slice added in v0.5.2

func (c TestCase) Slice() (res []string)

Slice returns a slice of strings representing this test case.

type TestCaseSet added in v0.4.0

type TestCaseSet map[string][]TestCase

TestCaseSet defines a set of arguments for build matrix. The test case set is a map of which key is a version and the associated value is a list of test cases.

type Travis

type Travis struct {
	// Base language.
	Language string
	// List of addons.
	Addons struct {
		Apt struct {
			Packages []string
		} `yaml:"apt,omitempty"`
	} `yaml:"addons,omitempty"`

	// List of commands run before install steps.
	BeforeInstall ListOrString `yaml:"before_install,omitempty"`

	// List of commands used to install packages.
	Install ListOrString `yaml:"install,omitempty"`

	// List of commands run before main scripts.
	BeforeScript ListOrString `yaml:"before_script,omitempty"`

	// List of scripts.
	Script ListOrString `yaml:"script,omitempty"`

	// List of environment variables.
	Env Env `yaml:"env,omitempty"`

	// Configuration for matrix build.
	Matrix Matrix `yaml:"matrix,omitempty"`

	// List of python versions. (used only in python)
	Python []string `yaml:"python,omitempty"`

	// List of golang versions. (used only in go)
	Go []string `yaml:"go,omitempty"`
	// Go import path. (used only in go)
	GoImportPath string `yaml:"go_import_path,omitempty"`
	// Build args for go project. (used only in go)
	GoBuildArgs string `yaml:"gobuild_args,omitempty"`
}

Travis defines the structure of .travis.yml.

func NewTravis

func NewTravis(buf []byte) (res *Travis, err error)

NewTravis creates a Travis object from a byte array.

func NewTravisFromFile added in v0.4.2

func NewTravisFromFile(filename string) (res *Travis, err error)

NewTravisFromFile creates a Travis object from a file.

func (*Travis) ArgumentSet added in v0.3.0

func (t *Travis) ArgumentSet(logger io.Writer) (res TestCaseSet, err error)

ArgumentSet returns a set of arguments to run entrypoint based on a build matrix.

Jump to

Keyboard shortcuts

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