From bd423bf84d2ddef9680f54670a1e6ec2d7a18329 Mon Sep 17 00:00:00 2001 From: Danny Canter Date: Wed, 11 Oct 2023 21:49:27 -0700 Subject: [PATCH] Snapshotters: Export the root path Some of the snapshotters that allow you to change their root location were already doing this, this just makes all of them follow the same pattern. Signed-off-by: Danny Canter (cherry picked from commit 32caaee) Signed-off-by: Kern Walster --- plugin/plugin.go | 4 ++++ snapshots/blockfile/plugin/plugin.go | 1 + snapshots/btrfs/plugin/plugin.go | 2 +- snapshots/devmapper/plugin/plugin.go | 1 + snapshots/native/plugin/plugin.go | 1 + snapshots/overlay/plugin/plugin.go | 2 +- 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugin/plugin.go b/plugin/plugin.go index f1be877fcb29..7c854fdc3f99 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -104,6 +104,10 @@ const ( DeprecationsPlugin = "deprecations" ) +const ( + SnapshotterRootDir = "root" +) + // Registration contains information for registering a plugin type Registration struct { // Type of the plugin diff --git a/snapshots/blockfile/plugin/plugin.go b/snapshots/blockfile/plugin/plugin.go index 8381537cf9a0..a9de3a61596b 100644 --- a/snapshots/blockfile/plugin/plugin.go +++ b/snapshots/blockfile/plugin/plugin.go @@ -67,6 +67,7 @@ func init() { opts = append(opts, blockfile.WithMountOptions(config.MountOptions)) } + ic.Meta.Exports[plugin.SnapshotterRootDir] = root return blockfile.NewSnapshotter(root, opts...) }, }) diff --git a/snapshots/btrfs/plugin/plugin.go b/snapshots/btrfs/plugin/plugin.go index f6635846cc51..4cc9a0d1c297 100644 --- a/snapshots/btrfs/plugin/plugin.go +++ b/snapshots/btrfs/plugin/plugin.go @@ -52,7 +52,7 @@ func init() { root = config.RootPath } - ic.Meta.Exports = map[string]string{"root": root} + ic.Meta.Exports[plugin.SnapshotterRootDir] = root return btrfs.NewSnapshotter(root) }, }) diff --git a/snapshots/devmapper/plugin/plugin.go b/snapshots/devmapper/plugin/plugin.go index dec4b37f84d5..5b246602b0a6 100644 --- a/snapshots/devmapper/plugin/plugin.go +++ b/snapshots/devmapper/plugin/plugin.go @@ -47,6 +47,7 @@ func init() { config.RootPath = ic.Root } + ic.Meta.Exports[plugin.SnapshotterRootDir] = config.RootPath return devmapper.NewSnapshotter(ic.Context, config) }, }) diff --git a/snapshots/native/plugin/plugin.go b/snapshots/native/plugin/plugin.go index 8544f3ba00f0..c9461426a5aa 100644 --- a/snapshots/native/plugin/plugin.go +++ b/snapshots/native/plugin/plugin.go @@ -48,6 +48,7 @@ func init() { root = config.RootPath } + ic.Meta.Exports[plugin.SnapshotterRootDir] = root return native.NewSnapshotter(root) }, }) diff --git a/snapshots/overlay/plugin/plugin.go b/snapshots/overlay/plugin/plugin.go index 6c6dce75da82..2b97a672433c 100644 --- a/snapshots/overlay/plugin/plugin.go +++ b/snapshots/overlay/plugin/plugin.go @@ -67,7 +67,7 @@ func init() { oOpts = append(oOpts, overlay.WithMountOptions(config.MountOptions)) } - ic.Meta.Exports["root"] = root + ic.Meta.Exports[plugin.SnapshotterRootDir] = root return overlay.NewSnapshotter(root, oOpts...) }, })