Add WithReadonlyTempMount to create readonly temporary mounts
This is necessary so we can mount snapshots more than once with overlayfs, otherwise mounts enter an unknown state. related: https://github.com/moby/buildkit/pull/1100 Signed-off-by: Laura Brehm <laurabrehm@hey.com> Co-authored-by: Zou Nengren <zouyee1989@gmail.com>
This commit is contained in:
@@ -67,6 +67,13 @@ func WithTempMount(ctx context.Context, mounts []Mount, f func(root string) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
// WithReadonlyTempMount mounts the provided mounts to a temp dir as readonly,
|
||||
// and pass the temp dir to f. The mounts are valid during the call to the f.
|
||||
// Finally we will unmount and remove the temp dir regardless of the result of f.
|
||||
func WithReadonlyTempMount(ctx context.Context, mounts []Mount, f func(root string) error) (err error) {
|
||||
return WithTempMount(ctx, readonlyMounts(mounts), f)
|
||||
}
|
||||
|
||||
func getTempDir() string {
|
||||
if xdg := os.Getenv("XDG_RUNTIME_DIR"); xdg != "" {
|
||||
return xdg
|
||||
|
||||
Reference in New Issue
Block a user