2018-04-13 21:13:48 +00:00
|
|
|
package worker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/moby/buildkit/cache"
|
2018-05-11 05:58:41 +00:00
|
|
|
"github.com/moby/buildkit/solver"
|
2018-04-13 21:13:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewWorkerRefResult(ref cache.ImmutableRef, worker Worker) solver.Result {
|
|
|
|
return &workerRefResult{&WorkerRef{ImmutableRef: ref, Worker: worker}}
|
|
|
|
}
|
|
|
|
|
|
|
|
type WorkerRef struct {
|
|
|
|
ImmutableRef cache.ImmutableRef
|
|
|
|
Worker Worker
|
|
|
|
}
|
|
|
|
|
|
|
|
func (wr *WorkerRef) ID() string {
|
2018-05-22 21:49:21 +00:00
|
|
|
refID := ""
|
|
|
|
if wr.ImmutableRef != nil {
|
|
|
|
refID = wr.ImmutableRef.ID()
|
|
|
|
}
|
|
|
|
return wr.Worker.ID() + "::" + refID
|
2018-04-13 21:13:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type workerRefResult struct {
|
|
|
|
*WorkerRef
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *workerRefResult) Release(ctx context.Context) error {
|
2018-05-22 21:49:21 +00:00
|
|
|
if r.ImmutableRef == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2018-04-13 21:13:48 +00:00
|
|
|
return r.ImmutableRef.Release(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *workerRefResult) Sys() interface{} {
|
|
|
|
return r.WorkerRef
|
|
|
|
}
|