full diff: https://github.com/moby/buildkit/compare/v0.8.3...v0.8.3-3-g244e8cde
- Transform relative mountpoints for exec mounts in the executor
- Add test for handling relative mountpoints
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 61b04b3a02f509dc8580ec3d7824df57336ff3e3)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -33,7 +33,7 @@ github.com/imdario/mergo 1afb36080aec31e0d1528973ebe6 |
| 33 | 33 |
golang.org/x/sync cd5d95a43a6e21273425c7ae415d3df9ea832eeb |
| 34 | 34 |
|
| 35 | 35 |
# buildkit |
| 36 |
-github.com/moby/buildkit 81c2cbd8a418918d62b71e347a00034189eea455 # v0.8.3 |
|
| 36 |
+github.com/moby/buildkit 244e8cde639f71a05a1a2e0670bd88e0206ce55c # v0.8.3-3-g244e8cde |
|
| 37 | 37 |
github.com/tonistiigi/fsutil 0834f99b7b85462efb69b4f571a4fa3ca7da5ac9 |
| 38 | 38 |
github.com/tonistiigi/units 6950e57a87eaf136bbe44ef2ec8e75b9e3569de2 |
| 39 | 39 |
github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746 |
| ... | ... |
@@ -3,6 +3,7 @@ package gateway |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"fmt" |
| 6 |
+ "path/filepath" |
|
| 6 | 7 |
"runtime" |
| 7 | 8 |
"sort" |
| 8 | 9 |
"strings" |
| ... | ... |
@@ -75,7 +76,7 @@ func NewContainer(ctx context.Context, w worker.Worker, sm *session.Manager, g s |
| 75 | 75 |
|
| 76 | 76 |
name := fmt.Sprintf("container %s", req.ContainerID)
|
| 77 | 77 |
mm := mounts.NewMountManager(name, w.CacheManager(), sm, w.MetadataStore()) |
| 78 |
- p, err := PrepareMounts(ctx, mm, w.CacheManager(), g, mnts, refs, func(m *opspb.Mount, ref cache.ImmutableRef) (cache.MutableRef, error) {
|
|
| 78 |
+ p, err := PrepareMounts(ctx, mm, w.CacheManager(), g, "", mnts, refs, func(m *opspb.Mount, ref cache.ImmutableRef) (cache.MutableRef, error) {
|
|
| 79 | 79 |
cm := w.CacheManager() |
| 80 | 80 |
if m.Input != opspb.Empty {
|
| 81 | 81 |
cm = refs[m.Input].Worker.CacheManager() |
| ... | ... |
@@ -132,7 +133,7 @@ type MountMutableRef struct {
|
| 132 | 132 |
|
| 133 | 133 |
type MakeMutable func(m *opspb.Mount, ref cache.ImmutableRef) (cache.MutableRef, error) |
| 134 | 134 |
|
| 135 |
-func PrepareMounts(ctx context.Context, mm *mounts.MountManager, cm cache.Manager, g session.Group, mnts []*opspb.Mount, refs []*worker.WorkerRef, makeMutable MakeMutable) (p PreparedMounts, err error) {
|
|
| 135 |
+func PrepareMounts(ctx context.Context, mm *mounts.MountManager, cm cache.Manager, g session.Group, cwd string, mnts []*opspb.Mount, refs []*worker.WorkerRef, makeMutable MakeMutable) (p PreparedMounts, err error) {
|
|
| 136 | 136 |
// loop over all mounts, fill in mounts, root and outputs |
| 137 | 137 |
for i, m := range mnts {
|
| 138 | 138 |
var ( |
| ... | ... |
@@ -254,7 +255,11 @@ func PrepareMounts(ctx context.Context, mm *mounts.MountManager, cm cache.Manage |
| 254 | 254 |
p.Root = mountWithSession(root, g) |
| 255 | 255 |
} else {
|
| 256 | 256 |
mws := mountWithSession(mountable, g) |
| 257 |
- mws.Dest = m.Dest |
|
| 257 |
+ dest := m.Dest |
|
| 258 |
+ if !filepath.IsAbs(filepath.Clean(dest)) {
|
|
| 259 |
+ dest = filepath.Join("/", cwd, dest)
|
|
| 260 |
+ } |
|
| 261 |
+ mws.Dest = dest |
|
| 258 | 262 |
mws.Readonly = m.Readonly |
| 259 | 263 |
mws.Selector = m.Selector |
| 260 | 264 |
p.Mounts = append(p.Mounts, mws) |
| ... | ... |
@@ -240,7 +240,7 @@ func (e *execOp) Exec(ctx context.Context, g session.Group, inputs []solver.Resu |
| 240 | 240 |
} |
| 241 | 241 |
} |
| 242 | 242 |
|
| 243 |
- p, err := gateway.PrepareMounts(ctx, e.mm, e.cm, g, e.op.Mounts, refs, func(m *pb.Mount, ref cache.ImmutableRef) (cache.MutableRef, error) {
|
|
| 243 |
+ p, err := gateway.PrepareMounts(ctx, e.mm, e.cm, g, e.op.Meta.Cwd, e.op.Mounts, refs, func(m *pb.Mount, ref cache.ImmutableRef) (cache.MutableRef, error) {
|
|
| 244 | 244 |
desc := fmt.Sprintf("mount %s from exec %s", m.Dest, strings.Join(e.op.Meta.Args, " "))
|
| 245 | 245 |
return e.cm.New(ctx, ref, g, cache.WithDescription(desc)) |
| 246 | 246 |
}) |