Add snapshot plugin type

Update existing snapshot drivers to register as plugins.
Load snapshot driver at containerd startup.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2017-03-07 14:55:36 -08:00
parent f06db40baf
commit a4247e2aa9
6 changed files with 91 additions and 15 deletions

View file

@ -10,17 +10,27 @@ import (
"sync"
"github.com/docker/containerd"
"github.com/docker/containerd/plugin"
"github.com/docker/containerd/snapshot"
digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
)
func init() {
plugin.Register("snapshot-overlay", &plugin.Registration{
Type: plugin.SnapshotPlugin,
Init: func(ic *plugin.InitContext) (interface{}, error) {
return NewSnapshotter(filepath.Join(ic.Root, "snapshot", "overlay"))
},
})
}
type Snapshotter struct {
root string
links *cache
}
func NewSnapshotter(root string) (*Snapshotter, error) {
func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
if err := os.MkdirAll(root, 0700); err != nil {
return nil, err
}