Merge pull request #4506 from dmcgowan/refactor-overlay-plugin
Separate overlay implementation from plugin
This commit is contained in:
commit
efa0e80913
@ -23,5 +23,5 @@ import (
|
|||||||
_ "github.com/containerd/containerd/runtime/v2"
|
_ "github.com/containerd/containerd/runtime/v2"
|
||||||
_ "github.com/containerd/containerd/runtime/v2/runc/options"
|
_ "github.com/containerd/containerd/runtime/v2/runc/options"
|
||||||
_ "github.com/containerd/containerd/snapshots/native"
|
_ "github.com/containerd/containerd/snapshots/native"
|
||||||
_ "github.com/containerd/containerd/snapshots/overlay"
|
_ "github.com/containerd/containerd/snapshots/overlay/plugin"
|
||||||
)
|
)
|
||||||
|
@ -29,38 +29,12 @@ import (
|
|||||||
|
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/mount"
|
"github.com/containerd/containerd/mount"
|
||||||
"github.com/containerd/containerd/platforms"
|
|
||||||
"github.com/containerd/containerd/plugin"
|
|
||||||
"github.com/containerd/containerd/snapshots"
|
"github.com/containerd/containerd/snapshots"
|
||||||
"github.com/containerd/containerd/snapshots/storage"
|
"github.com/containerd/containerd/snapshots/storage"
|
||||||
"github.com/containerd/continuity/fs"
|
"github.com/containerd/continuity/fs"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
plugin.Register(&plugin.Registration{
|
|
||||||
Type: plugin.SnapshotPlugin,
|
|
||||||
ID: "overlayfs",
|
|
||||||
Config: &Config{},
|
|
||||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
|
||||||
ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
|
|
||||||
|
|
||||||
config, ok := ic.Config.(*Config)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("invalid overlay configuration")
|
|
||||||
}
|
|
||||||
|
|
||||||
root := ic.Root
|
|
||||||
if config.RootPath != "" {
|
|
||||||
root = config.RootPath
|
|
||||||
}
|
|
||||||
|
|
||||||
ic.Meta.Exports["root"] = root
|
|
||||||
return NewSnapshotter(root, AsynchronousRemove)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// SnapshotterConfig is used to configure the overlay snapshotter instance
|
// SnapshotterConfig is used to configure the overlay snapshotter instance
|
||||||
type SnapshotterConfig struct {
|
type SnapshotterConfig struct {
|
||||||
asyncRemove bool
|
asyncRemove bool
|
||||||
|
@ -18,8 +18,40 @@
|
|||||||
|
|
||||||
package overlay
|
package overlay
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/platforms"
|
||||||
|
"github.com/containerd/containerd/plugin"
|
||||||
|
"github.com/containerd/containerd/snapshots/overlay"
|
||||||
|
)
|
||||||
|
|
||||||
// Config represents configuration for the overlay plugin.
|
// Config represents configuration for the overlay plugin.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Root directory for the plugin
|
// Root directory for the plugin
|
||||||
RootPath string `toml:"root_path"`
|
RootPath string `toml:"root_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
plugin.Register(&plugin.Registration{
|
||||||
|
Type: plugin.SnapshotPlugin,
|
||||||
|
ID: "overlayfs",
|
||||||
|
Config: &Config{},
|
||||||
|
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||||
|
ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
|
||||||
|
|
||||||
|
config, ok := ic.Config.(*Config)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("invalid overlay configuration")
|
||||||
|
}
|
||||||
|
|
||||||
|
root := ic.Root
|
||||||
|
if config.RootPath != "" {
|
||||||
|
root = config.RootPath
|
||||||
|
}
|
||||||
|
|
||||||
|
ic.Meta.Exports["root"] = root
|
||||||
|
return overlay.NewSnapshotter(root, overlay.AsynchronousRemove)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user