From 8de7a47b8d3bbc68b5f7452c0ba3693faa5c8757 Mon Sep 17 00:00:00 2001 From: Tony Worm Date: Mon, 8 Feb 2021 17:16:02 -0500 Subject: [PATCH] support path option in script/component mounts Signed-off-by: Tony Worm --- dagger/mount.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dagger/mount.go b/dagger/mount.go index 790d5ed1..5c2c552a 100644 --- a/dagger/mount.go +++ b/dagger/mount.go @@ -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 }