Merge pull request #108 from verdverm/mount-path

support path option in script/component mounts
This commit is contained in:
Andrea Luzzardi 2021-02-09 12:51:14 -08:00 committed by GitHub
commit 7cbce4eec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,7 @@ func (mnt *Mount) LLB(ctx context.Context, s Solver) (llb.RunOption, error) {
llb.CacheMountShared, llb.CacheMountShared,
)), nil )), nil
} }
// Compute source component or script, discarding fs writes & output value // Compute source component or script, discarding fs writes & output value
from, err := newExecutable(mnt.v.Lookup("from")) from, err := newExecutable(mnt.v.Lookup("from"))
if err != nil { if err != nil {
@ -50,5 +51,17 @@ func (mnt *Mount) LLB(ctx context.Context, s Solver) (llb.RunOption, error) {
if err != nil { if err != nil {
return nil, err 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
} }