2017-06-01 22:24:23 +00:00
|
|
|
package worker
|
|
|
|
|
|
|
|
import (
|
2018-01-16 22:30:10 +00:00
|
|
|
"context"
|
2017-12-15 08:06:54 +00:00
|
|
|
"io"
|
|
|
|
|
2017-06-22 20:15:46 +00:00
|
|
|
"github.com/moby/buildkit/cache"
|
2017-11-21 08:08:36 +00:00
|
|
|
"github.com/moby/buildkit/cache/instructioncache"
|
|
|
|
"github.com/moby/buildkit/client"
|
|
|
|
"github.com/moby/buildkit/executor"
|
|
|
|
"github.com/moby/buildkit/exporter"
|
2017-12-15 08:06:54 +00:00
|
|
|
"github.com/moby/buildkit/solver/types"
|
|
|
|
digest "github.com/opencontainers/go-digest"
|
2017-06-01 22:24:23 +00:00
|
|
|
)
|
|
|
|
|
2017-12-15 08:06:54 +00:00
|
|
|
type SubBuilder interface {
|
|
|
|
SubBuild(ctx context.Context, dgst digest.Digest, req types.SolveRequest) (types.Ref, error)
|
2017-07-11 02:07:47 +00:00
|
|
|
}
|
|
|
|
|
2017-12-15 08:06:54 +00:00
|
|
|
type Worker interface {
|
2017-12-19 09:34:34 +00:00
|
|
|
// ID needs to be unique in the cluster
|
|
|
|
ID() string
|
|
|
|
Labels() map[string]string
|
2017-12-15 08:06:54 +00:00
|
|
|
InstructionCache() instructioncache.InstructionCache
|
2017-12-19 04:20:30 +00:00
|
|
|
// ResolveOp resolves Vertex.Sys() to Op implementation. SubBuilder is needed for pb.Op_Build.
|
|
|
|
ResolveOp(v types.Vertex, s SubBuilder) (types.Op, error)
|
2017-12-15 08:06:54 +00:00
|
|
|
ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error)
|
2017-12-15 10:51:06 +00:00
|
|
|
// Exec is similar to executor.Exec but without []mount.Mount
|
2017-12-15 08:06:54 +00:00
|
|
|
Exec(ctx context.Context, meta executor.Meta, rootFS cache.ImmutableRef, stdin io.ReadCloser, stdout, stderr io.WriteCloser) error
|
|
|
|
DiskUsage(ctx context.Context, opt client.DiskUsageInfo) ([]*client.UsageInfo, error)
|
|
|
|
Exporter(name string) (exporter.Exporter, error)
|
2017-12-27 01:22:50 +00:00
|
|
|
Prune(ctx context.Context, ch chan client.UsageInfo) error
|
2017-06-01 22:24:23 +00:00
|
|
|
}
|
2017-12-19 09:34:34 +00:00
|
|
|
|
|
|
|
// Pre-defined label keys
|
|
|
|
const (
|
|
|
|
labelPrefix = "org.mobyproject.buildkit.worker."
|
|
|
|
LabelOS = labelPrefix + "os" // GOOS
|
|
|
|
LabelArch = labelPrefix + "arch" // GOARCH
|
|
|
|
LabelExecutor = labelPrefix + "executor" // "oci" or "containerd"
|
|
|
|
LabelSnapshotter = labelPrefix + "snapshotter" // containerd snapshotter name ("overlay", "naive", ...)
|
|
|
|
LabelHostname = labelPrefix + "hostname"
|
|
|
|
)
|