Skip to content

Commit efa0e80

Browse files
authored
Merge pull request #4506 from dmcgowan/refactor-overlay-plugin
Separate overlay implementation from plugin
2 parents 1a89feb + 70ffb12 commit efa0e80

3 files changed

Lines changed: 33 additions & 27 deletions

File tree

cmd/containerd/builtins_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ import (
2323
_ "github.com/containerd/containerd/runtime/v2"
2424
_ "github.com/containerd/containerd/runtime/v2/runc/options"
2525
_ "github.com/containerd/containerd/snapshots/native"
26-
_ "github.com/containerd/containerd/snapshots/overlay"
26+
_ "github.com/containerd/containerd/snapshots/overlay/plugin"
2727
)

snapshots/overlay/overlay.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,12 @@ import (
2929

3030
"github.com/containerd/containerd/log"
3131
"github.com/containerd/containerd/mount"
32-
"github.com/containerd/containerd/platforms"
33-
"github.com/containerd/containerd/plugin"
3432
"github.com/containerd/containerd/snapshots"
3533
"github.com/containerd/containerd/snapshots/storage"
3634
"github.com/containerd/continuity/fs"
3735
"github.com/pkg/errors"
3836
)
3937

40-
func init() {
41-
plugin.Register(&plugin.Registration{
42-
Type: plugin.SnapshotPlugin,
43-
ID: "overlayfs",
44-
Config: &Config{},
45-
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
46-
ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
47-
48-
config, ok := ic.Config.(*Config)
49-
if !ok {
50-
return nil, errors.New("invalid overlay configuration")
51-
}
52-
53-
root := ic.Root
54-
if config.RootPath != "" {
55-
root = config.RootPath
56-
}
57-
58-
ic.Meta.Exports["root"] = root
59-
return NewSnapshotter(root, AsynchronousRemove)
60-
},
61-
})
62-
}
63-
6438
// SnapshotterConfig is used to configure the overlay snapshotter instance
6539
type SnapshotterConfig struct {
6640
asyncRemove bool
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,40 @@
1818

1919
package overlay
2020

21+
import (
22+
"errors"
23+
24+
"github.com/containerd/containerd/platforms"
25+
"github.com/containerd/containerd/plugin"
26+
"github.com/containerd/containerd/snapshots/overlay"
27+
)
28+
2129
// Config represents configuration for the overlay plugin.
2230
type Config struct {
2331
// Root directory for the plugin
2432
RootPath string `toml:"root_path"`
2533
}
34+
35+
func init() {
36+
plugin.Register(&plugin.Registration{
37+
Type: plugin.SnapshotPlugin,
38+
ID: "overlayfs",
39+
Config: &Config{},
40+
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
41+
ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
42+
43+
config, ok := ic.Config.(*Config)
44+
if !ok {
45+
return nil, errors.New("invalid overlay configuration")
46+
}
47+
48+
root := ic.Root
49+
if config.RootPath != "" {
50+
root = config.RootPath
51+
}
52+
53+
ic.Meta.Exports["root"] = root
54+
return overlay.NewSnapshotter(root, overlay.AsynchronousRemove)
55+
},
56+
})
57+
}

0 commit comments

Comments
 (0)