Documentation ¶
Index ¶
- Variables
- func New(opts ...Option) (err error)
- type InputFilesOption
- func WithEnsureUnderPWD(doensure bool) InputFilesOption
- func WithEnsureWritable(doensure bool) InputFilesOption
- func WithFilenames(paths []string) InputFilesOption
- func WithPWD(pwd string) InputFilesOption
- func WithSelectionFailureBuilder(f func(fn string, err error) error) InputFilesOption
- func WithTraverseDirectories(dotraverse bool) InputFilesOption
- func WithUseCurrentDirWhenNoPathsGiven() InputFilesOption
- type Option
- func WithBuildArg(arg string) Option
- func WithContext(ctx context.Context) Option
- func WithDirectoryA(dirA string) Option
- func WithDirectoryB(dirB string) Option
- func WithDockerfile(dockerfiler func(map[interface{}]interface{}) []byte) Option
- func WithEnviron(environ []string) Option
- func WithExecutable(exe string) Option
- func WithInputFile(relativePath string, data []byte) Option
- func WithInputFiles(opts ...InputFilesOption) Option
- func WithOutputFileFunc(f OutputFileFunc) Option
- func WithStderr(stderr io.Writer) Option
- func WithStdout(stdout io.Writer) Option
- func WithStdoutFile(stdoutf string) Option
- type OutputFileFunc
Constants ¶
This section is empty.
Variables ¶
var ErrDockerBuildFailure = errors.New("docker build failed with status 1")
ErrDockerBuildFailure is returned when docker build failed
var ErrEmptyDirA = errors.New("empty dir a")
ErrEmptyDirA is returned when WithDirectoryA("") was called.
var ErrEmptyDirB = errors.New("empty dir b")
ErrEmptyDirB is returned when WithDirectoryB("") was called.
var ErrEmptyPWDForInputFiles = errors.New("given empty $PWD")
ErrEmptyPWDForInputFiles is returned when calling WithInputFiles missing WithPWD(pwd) and pwd != "".
var ErrEmptyStdoutFile = errors.New("empty stdout file")
ErrEmptyStdoutFile is returned when WithStdoutFile("") was called.
var ErrNilContext = errors.New("context is nil")
ErrNilContext is returned when a nil context with given as option
var ErrNoDocker = errors.New("No docker client found: curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh")
ErrNoDocker is returned when no usable Docker client can be found
var ErrNoDockerfile = errors.New("missing Dockerfile")
ErrNoDockerfile is returned when WithDockerfile() wasn't called.
var ErrOutputFileFuncSet = errors.New("cannot reset OutputFileFunc")
ErrOutputFileFuncSet is returned on multiple calls to WithOutputFileFunc(f) where f != nil
Functions ¶
Types ¶
type InputFilesOption ¶
type InputFilesOption func(*inputfilesoptions)
InputFilesOption represents the various arguments WithInputFiles takes.
func WithEnsureUnderPWD ¶
func WithEnsureUnderPWD(doensure bool) InputFilesOption
WithEnsureUnderPWD makes sure selected paths all are under $PWD
func WithEnsureWritable ¶
func WithEnsureWritable(doensure bool) InputFilesOption
WithEnsureWritable makes sure selected files are all writable
func WithFilenames ¶
func WithFilenames(paths []string) InputFilesOption
WithFilenames sets which filenames to use. Each call resets the previous setting.
func WithPWD ¶
func WithPWD(pwd string) InputFilesOption
WithPWD sets the current working directory.
func WithSelectionFailureBuilder ¶
func WithSelectionFailureBuilder(f func(fn string, err error) error) InputFilesOption
WithSelectionFailureBuilder can be used to wrap errors that correspond to filename selection failures.
func WithTraverseDirectories ¶
func WithTraverseDirectories(dotraverse bool) InputFilesOption
WithTraverseDirectories activates directory traversal if given true. Does nothing is WithUseCurrentDirWhenNoPathsGiven() was called.
func WithUseCurrentDirWhenNoPathsGiven ¶
func WithUseCurrentDirWhenNoPathsGiven() InputFilesOption
WithUseCurrentDirWhenNoPathsGiven will use $PWD if WithFilenames(l) l == 0. Automatically activates WithTraverseDirectories(true).
type Option ¶
type Option func(*options) error
Option represents the various arguments a New takes
func WithBuildArg ¶
WithBuildArg have build run with given build argument in key=value format. Multiple calls append build args.
func WithContext ¶
WithContext have build run with cancellable context. Defaults to context.Background()
func WithDirectoryA ¶
WithDirectoryA have build run with given "a" directory. Defaults to "a".
func WithDirectoryB ¶
WithDirectoryB have build run with given "b" directory. Defaults to "b".
func WithDockerfile ¶
WithDockerfile have build run with given Dockerfile.
func WithEnviron ¶
WithEnviron have build run with environment variables coming from environ. Note this is the env outside Docker. Defaults to os.Environ()
func WithExecutable ¶
WithExecutable have build run with given Docker executable path. Defaults to being resolved with exec.Lookpath("docker").
func WithInputFile ¶
WithInputFile have build run with given input file copied in. Multiple calls add input files.
func WithInputFiles ¶
func WithInputFiles(opts ...InputFilesOption) Option
WithInputFiles have build run with given input files copied in.
func WithOutputFileFunc ¶
func WithOutputFileFunc(f OutputFileFunc) Option
WithOutputFileFunc is executed per file outputed by the build.
func WithStderr ¶
WithStderr have build run with STDERR written to given io.Writer. Defaults to os.Stderr
func WithStdout ¶
WithStdout have build run with STDOUT written to given io.Writer. Defaults to os.Stdout
func WithStdoutFile ¶
WithStdoutFile have build run with given stdout file. Defaults to "stdout".
type OutputFileFunc ¶
OutputFileFunc represents an effectful function set using WithOutputFileFunc.
var OverwriteFileContents OutputFileFunc = func(filename string, r io.Reader) error { f, err := os.OpenFile(filename, os.O_RDWR, 0) if err != nil { return err } if err := f.Truncate(0); err != nil { return err } if _, err := f.Seek(0, 0); err != nil { return err } if _, err := io.Copy(f, r); err != nil { return err } if err := f.Close(); err != nil { return err } return nil }
OverwriteFileContents replaces the contents of a file with the data from the given reader. File attributes are not changed except modtime.