From 32caaee484239842e2c8152230d31d6c88994660 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 --- plugins/snapshots/blockfile/plugin/plugin.go | 1 + plugins/snapshots/btrfs/plugin/plugin.go | 2 +- plugins/snapshots/devmapper/plugin/plugin.go | 1 + plugins/snapshots/native/plugin/plugin.go | 1 + plugins/snapshots/overlay/plugin/plugin.go | 2 +- plugins/types.go | 4 ++++ 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/snapshots/blockfile/plugin/plugin.go b/plugins/snapshots/blockfile/plugin/plugin.go index 69ee9ca6fc69..e5e16a0d81f1 100644 --- a/plugins/snapshots/blockfile/plugin/plugin.go +++ b/plugins/snapshots/blockfile/plugin/plugin.go @@ -74,6 +74,7 @@ func init() { } opts = append(opts, blockfile.WithRecreateScratch(config.RecreateScratch)) + ic.Meta.Exports[plugins.SnapshotterRootDir] = root return blockfile.NewSnapshotter(root, opts...) }, }) diff --git a/plugins/snapshots/btrfs/plugin/plugin.go b/plugins/snapshots/btrfs/plugin/plugin.go index 3dfea38c5683..324abbfdb01b 100644 --- a/plugins/snapshots/btrfs/plugin/plugin.go +++ b/plugins/snapshots/btrfs/plugin/plugin.go @@ -54,7 +54,7 @@ func init() { root = config.RootPath } - ic.Meta.Exports = map[string]string{"root": root} + ic.Meta.Exports[plugins.SnapshotterRootDir] = root return btrfs.NewSnapshotter(root) }, }) diff --git a/plugins/snapshots/devmapper/plugin/plugin.go b/plugins/snapshots/devmapper/plugin/plugin.go index 143916c080a1..e3b530ae01d5 100644 --- a/plugins/snapshots/devmapper/plugin/plugin.go +++ b/plugins/snapshots/devmapper/plugin/plugin.go @@ -50,6 +50,7 @@ func init() { config.RootPath = ic.Properties[plugins.PropertyRootDir] } + ic.Meta.Exports[plugins.SnapshotterRootDir] = config.RootPath return devmapper.NewSnapshotter(ic.Context, config) }, }) diff --git a/plugins/snapshots/native/plugin/plugin.go b/plugins/snapshots/native/plugin/plugin.go index 816735912ca7..ece5c15f411e 100644 --- a/plugins/snapshots/native/plugin/plugin.go +++ b/plugins/snapshots/native/plugin/plugin.go @@ -50,6 +50,7 @@ func init() { root = config.RootPath } + ic.Meta.Exports[plugins.SnapshotterRootDir] = root return native.NewSnapshotter(root) }, }) diff --git a/plugins/snapshots/overlay/plugin/plugin.go b/plugins/snapshots/overlay/plugin/plugin.go index 6c10add9c256..0c9f157dd5fa 100644 --- a/plugins/snapshots/overlay/plugin/plugin.go +++ b/plugins/snapshots/overlay/plugin/plugin.go @@ -92,7 +92,7 @@ func init() { ic.Meta.Capabilities = append(ic.Meta.Capabilities, capaOnlyRemapIDs) } - ic.Meta.Exports["root"] = root + ic.Meta.Exports[plugins.SnapshotterRootDir] = root return overlay.NewSnapshotter(root, oOpts...) }, }) diff --git a/plugins/types.go b/plugins/types.go index d18ffbf2d42c..66f28ff23f13 100644 --- a/plugins/types.go +++ b/plugins/types.go @@ -93,3 +93,7 @@ const ( // PropertyTTRPCAddress is the ttrpc address used for client connections to containerd PropertyTTRPCAddress = "io.containerd.plugin.ttrpc.address" ) + +const ( + SnapshotterRootDir = "root" +)