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/client"
|
|
|
|
"github.com/moby/buildkit/executor"
|
|
|
|
"github.com/moby/buildkit/exporter"
|
2018-04-13 21:13:48 +00:00
|
|
|
"github.com/moby/buildkit/frontend"
|
2018-07-25 06:18:21 +00:00
|
|
|
gw "github.com/moby/buildkit/frontend/gateway/client"
|
2019-02-23 12:56:04 +00:00
|
|
|
"github.com/moby/buildkit/session"
|
2018-05-11 05:58:41 +00:00
|
|
|
"github.com/moby/buildkit/solver"
|
2017-12-15 08:06:54 +00:00
|
|
|
digest "github.com/opencontainers/go-digest"
|
2018-06-22 02:06:12 +00:00
|
|
|
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
2017-06-01 22:24:23 +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
|
2018-06-22 02:06:12 +00:00
|
|
|
Platforms() []specs.Platform
|
2018-08-30 21:06:27 +00:00
|
|
|
GCPolicy() []client.PruneInfo
|
2018-09-14 20:35:41 +00:00
|
|
|
LoadRef(id string, hidden bool) (cache.ImmutableRef, error)
|
2018-04-13 21:13:48 +00:00
|
|
|
// ResolveOp resolves Vertex.Sys() to Op implementation.
|
2019-02-23 12:56:04 +00:00
|
|
|
ResolveOp(v solver.Vertex, s frontend.FrontendLLBBridge, sm *session.Manager) (solver.Op, error)
|
|
|
|
ResolveImageConfig(ctx context.Context, ref string, opt gw.ResolveImageConfigOpt, sm *session.Manager) (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)
|
2019-02-23 12:56:04 +00:00
|
|
|
Exporter(name string, sm *session.Manager) (exporter.Exporter, error)
|
2018-08-30 21:06:27 +00:00
|
|
|
Prune(ctx context.Context, ch chan client.UsageInfo, opt ...client.PruneInfo) error
|
2018-05-08 21:05:08 +00:00
|
|
|
GetRemote(ctx context.Context, ref cache.ImmutableRef, createIfNeeded bool) (*solver.Remote, error)
|
2018-04-13 21:13:48 +00:00
|
|
|
FromRemote(ctx context.Context, remote *solver.Remote) (cache.ImmutableRef, error)
|
2019-07-29 22:41:49 +00:00
|
|
|
PruneCacheMounts(ctx context.Context, ids []string) 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."
|
|
|
|
LabelExecutor = labelPrefix + "executor" // "oci" or "containerd"
|
2018-04-03 09:37:16 +00:00
|
|
|
LabelSnapshotter = labelPrefix + "snapshotter" // containerd snapshotter name ("overlay", "native", ...)
|
2017-12-19 09:34:34 +00:00
|
|
|
LabelHostname = labelPrefix + "hostname"
|
|
|
|
)
|