support path option in script/component mounts

Signed-off-by: Tony Worm <tony@hofstadter.io>
This commit is contained in:
Tony Worm 2021-02-08 17:16:02 -05:00
parent 622de21883
commit 8de7a47b8d

View File

@ -43,6 +43,7 @@ func (mnt *Mount) LLB(ctx context.Context, s Solver) (llb.RunOption, error) {
llb.CacheMountShared,
)), nil
}
// Compute source component or script, discarding fs writes & output value
from, err := newExecutable(mnt.v.Lookup("from"))
if err != nil {
@ -52,5 +53,17 @@ func (mnt *Mount) LLB(ctx context.Context, s Solver) (llb.RunOption, error) {
if err != nil {
return nil, err
}
return llb.AddMount(mnt.dest, fromFS.LLB()), nil
// possibly construct mount options for LLB from
var mo []llb.MountOption
// handle "path" option
if p := mnt.v.Lookup("path"); p.Exists() {
ps, err := p.String()
if err != nil {
return nil, err
}
mo = append(mo, llb.SourcePath(ps))
}
return llb.AddMount(mnt.dest, fromFS.LLB(), mo...), nil
}