zfs: seperate implementation pkg from plugin pkg and revendor

Signed-off-by: Siddharth Yadav <sedflix@gmail.com>
This commit is contained in:
Siddharth Yadav
2020-09-06 19:55:21 +05:30
parent fabebe5d55
commit 96f4ce4a5c
6 changed files with 88 additions and 36 deletions

View File

@@ -20,16 +20,13 @@ package zfs
import (
"context"
"path/filepath"
"github.com/containerd/containerd/log"
"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/storage"
zfs "github.com/mistifyio/go-zfs"
"github.com/pkg/errors"
"path/filepath"
)
const (
@@ -39,17 +36,6 @@ const (
snapshotSuffix = "snapshot"
)
func init() {
plugin.Register(&plugin.Registration{
Type: plugin.SnapshotPlugin,
ID: "zfs",
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
ic.Meta.Exports["root"] = ic.Root
return NewSnapshotter(ic.Root)
},
})
}
type snapshotter struct {
dataset *zfs.Dataset
@@ -66,7 +52,7 @@ func NewSnapshotter(root string) (snapshots.Snapshotter, error) {
return nil, err
}
if m.FSType != "zfs" {
return nil, errors.Wrapf(plugin.ErrSkipPlugin, "path %s must be a zfs filesystem to be used with the zfs snapshotter", root)
return nil, errors.Errorf("path %s must be a zfs filesystem to be used with the zfs snapshotter", root)
}
dataset, err := zfs.GetDataset(m.Source)
if err != nil {