mount cache support

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2021-02-05 15:08:44 -08:00
parent 89c7136f75
commit f336164699

View File

@ -2,7 +2,6 @@ package dagger
import (
"context"
"fmt"
"github.com/moby/buildkit/client/llb"
"github.com/pkg/errors"
@ -29,11 +28,20 @@ func (mnt *Mount) Validate(defs ...string) error {
func (mnt *Mount) LLB(ctx context.Context, s Solver) (llb.RunOption, error) {
if err := mnt.Validate("#MountTmp"); err == nil {
return llb.AddMount(mnt.dest, llb.Scratch(), llb.Tmpfs()), nil
return llb.AddMount(
mnt.dest,
llb.Scratch(),
llb.Tmpfs(),
), nil
}
if err := mnt.Validate("#MountCache"); err == nil {
// FIXME: cache mount
return nil, fmt.Errorf("FIXME: cache mount not yet implemented")
return llb.AddMount(
mnt.dest,
llb.Scratch(),
llb.AsPersistentCacheDir(
mnt.v.Path().String(),
llb.CacheMountShared,
)), nil
}
// Compute source component or script, discarding fs writes & output value
from, err := newExecutable(mnt.v.Lookup("from"))