solver

package
Version: v0.0.0-...-b2cfeef Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LocalPathDescriptionKey is the key name in the metadata description map for the input path to a local fs.
	LocalPathDescriptionKey = "hlb.local.path"
)

Variables

This section is empty.

Functions

func BuildkitClient

func BuildkitClient(ctx context.Context, addr string) (*client.Client, error)

BuildkitClient returns a basic buildkit client.

func Solve

func Solve(ctx context.Context, c *client.Client, s *session.Session, pw progress.Writer, def *llb.Definition, opts ...SolveOption) error

func WithEvaluate

func WithEvaluate(info *SolveInfo) error

Types

type Console

type Console interface {
	io.ReadWriteCloser

	// Fd returns its file descriptor
	Fd() uintptr

	// Name returns its file name
	Name() string
}

Console is intended to match the `File` interface from package `github.com/containerd/console`.

type ContainerConfig

type ContainerConfig struct {
	Cmd    []string          `json:"Cmd"`
	Labels map[string]string `json:"Labels"`
}

ContainerConfig is the schema1-compatible configuration of the container that is committed into the image.

type ImageSpec

type ImageSpec struct {
	specs.Image

	ContainerConfig ContainerConfig `json:"container_config,omitempty"`
}

ImageSpec is HLB's wrapper for the OCI specs image, allowing for backward compatible features with Docker.

type LogOutput

type LogOutput int
const (
	LogOutputTTY LogOutput = iota
	LogOutputPlain
)

type MultiWriter

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

MultiWriter is similar to progress.MultiWriter, but deduplicates writes by vertex.

func NewMultiWriter

func NewMultiWriter(pw progress.Writer) *MultiWriter

func (*MultiWriter) WithPrefix

func (mw *MultiWriter) WithPrefix(pfx string, force bool) progress.Writer

type Params

type Params struct {
	Def         *llb.Definition
	SolveOpts   []SolveOption
	SessionOpts []llbutil.SessionOption
}

type Progress

type Progress interface {
	MultiWriter() *MultiWriter

	Write(pfx, name string, fn func(ctx context.Context) error)

	Release()

	Wait() error

	// Sync will ensure that all progress has been written.
	Sync() error
}

func NewProgress

func NewProgress(ctx context.Context, opts ...ProgressOption) (Progress, error)

NewProgress returns a Progress that presents all the progress on multiple solves to the terminal stdout.

Calling (*Progress).WithPrefix creates a progress writer for a callback function, giving each solve its independent progress writer (which is eventually closed by the solve).

When all work has been completed, calling (*Progress).Release will start the process for closing out the progress UI. Note that because of the refresh rate of the interactive UI, we need to also call (*Progress).Wait to ensure it has exited cleanly.

Example usage without error handling: “`go p, _ := NewProgress(ctx)

p.WithPrefix("work", func(ctx context.Context, pw progress.Writer) error {

defer p.Release()
return workFunc(ctx, pw)

})

return p.Wait() “`

If your work function also needs to dynamically spawn progress writers, then you can call (*Progress).Go to create a goroutine sharing the same errgroup. Then you can share the underlying multiwriter by calling (*Progress).MultiWriter().

“`go p, _ := progress.NewProgress(ctx)

p.Go(func(ctx context.Context) error {

defer p.Release()
return workFunc(ctx, p.MultiWriter())

})

return p.Wait() “`

type ProgressInfo

type ProgressInfo struct {
	Console   Console
	LogOutput LogOutput
}

type ProgressOption

type ProgressOption func(*ProgressInfo) error

func WithLogOutput

func WithLogOutput(con Console, logOutput LogOutput) ProgressOption

type Request

type Request interface {
	// Solve sends the request and its children to BuildKit. The request passes
	// down the progress.Writer for them to spawn their own progress writers
	// for each independent solve.
	Solve(ctx context.Context, cln *client.Client, mw *MultiWriter, opts ...SolveOption) error

	Tree(tree treeprint.Tree) error
}

Request is a node in the solve request tree produced by the compiler. The solve request tree has peer nodes that should be executed in parallel, and next nodes that should be executed sequentially. These can be intermingled to produce a complex build pipeline.

func NilRequest

func NilRequest() Request

func Parallel

func Parallel(candidates ...Request) Request

func Sequential

func Sequential(candidates ...Request) Request

func Single

func Single(params *Params) Request

Single returns a single solve request.

type SolveCallback

type SolveCallback func(ctx context.Context, resp *client.SolveResponse) error

type SolveInfo

type SolveInfo struct {
	Evaluate              bool
	ErrorHandler          func(context.Context, gateway.Client, error)
	OutputDockerRef       string
	OutputPushImage       string
	OutputLocal           string
	OutputLocalTarball    bool
	OutputLocalOCITarball bool
	Callbacks             []SolveCallback `json:"-"`
	ImageSpec             *ImageSpec
	Entitlements          []entitlements.Entitlement
}

type SolveOption

type SolveOption func(*SolveInfo) error

func WithCallback

func WithCallback(fn SolveCallback) SolveOption

func WithDownload

func WithDownload(dest string) SolveOption

func WithDownloadDockerTarball

func WithDownloadDockerTarball(ref string) SolveOption

func WithDownloadOCITarball

func WithDownloadOCITarball() SolveOption

func WithDownloadTarball

func WithDownloadTarball() SolveOption

func WithEntitlement

func WithEntitlement(e entitlements.Entitlement) SolveOption

func WithErrorHandler

func WithErrorHandler(errorHandler func(context.Context, gateway.Client, error)) SolveOption

func WithImageSpec

func WithImageSpec(spec *ImageSpec) SolveOption

func WithPushImage

func WithPushImage(ref string) SolveOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL