buildx

package
v0.0.0-...-84edc25 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDockerBuildFailure = errors.New("docker build failed with status 1")

ErrDockerBuildFailure is returned when docker build failed

View Source
var ErrEmptyDirA = errors.New("empty dir a")

ErrEmptyDirA is returned when WithDirectoryA("") was called.

View Source
var ErrEmptyDirB = errors.New("empty dir b")

ErrEmptyDirB is returned when WithDirectoryB("") was called.

View Source
var ErrEmptyPWDForInputFiles = errors.New("given empty $PWD")

ErrEmptyPWDForInputFiles is returned when calling WithInputFiles missing WithPWD(pwd) and pwd != "".

View Source
var ErrEmptyStdoutFile = errors.New("empty stdout file")

ErrEmptyStdoutFile is returned when WithStdoutFile("") was called.

View Source
var ErrNilContext = errors.New("context is nil")

ErrNilContext is returned when a nil context with given as option

View Source
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

View Source
var ErrNoDockerfile = errors.New("missing Dockerfile")

ErrNoDockerfile is returned when WithDockerfile() wasn't called.

View Source
var ErrOutputFileFuncSet = errors.New("cannot reset OutputFileFunc")

ErrOutputFileFuncSet is returned on multiple calls to WithOutputFileFunc(f) where f != nil

Functions

func New

func New(opts ...Option) (err error)

New calls `DOCKER_BUILDKIT=1 docker build ...` with given Dockerfile

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

func WithBuildArg(arg string) Option

WithBuildArg have build run with given build argument in key=value format. Multiple calls append build args.

func WithContext

func WithContext(ctx context.Context) Option

WithContext have build run with cancellable context. Defaults to context.Background()

func WithDirectoryA

func WithDirectoryA(dirA string) Option

WithDirectoryA have build run with given "a" directory. Defaults to "a".

func WithDirectoryB

func WithDirectoryB(dirB string) Option

WithDirectoryB have build run with given "b" directory. Defaults to "b".

func WithDockerfile

func WithDockerfile(dockerfiler func(map[interface{}]interface{}) []byte) Option

WithDockerfile have build run with given Dockerfile.

func WithEnviron

func WithEnviron(environ []string) Option

WithEnviron have build run with environment variables coming from environ. Note this is the env outside Docker. Defaults to os.Environ()

func WithExecutable

func WithExecutable(exe string) Option

WithExecutable have build run with given Docker executable path. Defaults to being resolved with exec.Lookpath("docker").

func WithInputFile

func WithInputFile(relativePath string, data []byte) Option

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

func WithStderr(stderr io.Writer) Option

WithStderr have build run with STDERR written to given io.Writer. Defaults to os.Stderr

func WithStdout

func WithStdout(stdout io.Writer) Option

WithStdout have build run with STDOUT written to given io.Writer. Defaults to os.Stdout

func WithStdoutFile

func WithStdoutFile(stdoutf string) Option

WithStdoutFile have build run with given stdout file. Defaults to "stdout".

type OutputFileFunc

type OutputFileFunc func(filename string, r io.Reader) error

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.

Jump to

Keyboard shortcuts

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