Skip to content

Commit 804f3e0

Browse files
committed
seperate implementation pkg from plugin pkg
Signed-off-by: Siddharth Yadav <[email protected]>
1 parent fdbd943 commit 804f3e0

2 files changed

Lines changed: 37 additions & 14 deletions

File tree

plugin/plugin.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright The containerd Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package plugin
14+
15+
import (
16+
"github.com/containerd/containerd/platforms"
17+
"github.com/containerd/containerd/plugin"
18+
"github.com/containerd/zfs"
19+
"github.com/pkg/errors"
20+
)
21+
22+
func init() {
23+
plugin.Register(&plugin.Registration{
24+
Type: plugin.SnapshotPlugin,
25+
ID: "zfs",
26+
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
27+
ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
28+
ic.Meta.Exports["root"] = ic.Root
29+
snapshotter, err := zfs.NewSnapshotter(ic.Root)
30+
if err != nil {
31+
return nil, errors.Wrap(plugin.ErrSkipPlugin, err.Error())
32+
}
33+
return snapshotter, nil
34+
},
35+
})
36+
}

zfs.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import (
2424

2525
"github.com/containerd/containerd/log"
2626
"github.com/containerd/containerd/mount"
27-
"github.com/containerd/containerd/platforms"
28-
"github.com/containerd/containerd/plugin"
2927
"github.com/containerd/containerd/snapshots"
3028
"github.com/containerd/containerd/snapshots/storage"
3129
zfs "github.com/mistifyio/go-zfs"
@@ -39,17 +37,6 @@ const (
3937
snapshotSuffix = "snapshot"
4038
)
4139

42-
func init() {
43-
plugin.Register(&plugin.Registration{
44-
Type: plugin.SnapshotPlugin,
45-
ID: "zfs",
46-
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
47-
ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
48-
ic.Meta.Exports["root"] = ic.Root
49-
return NewSnapshotter(ic.Root)
50-
},
51-
})
52-
}
5340

5441
type snapshotter struct {
5542
dataset *zfs.Dataset
@@ -66,7 +53,7 @@ func NewSnapshotter(root string) (snapshots.Snapshotter, error) {
6653
return nil, err
6754
}
6855
if m.FSType != "zfs" {
69-
return nil, errors.Wrapf(plugin.ErrSkipPlugin, "path %s must be a zfs filesystem to be used with the zfs snapshotter", root)
56+
return nil, errors.Wrapf(err, "path %s must be a zfs filesystem to be used with the zfs snapshotter")
7057
}
7158
dataset, err := zfs.GetDataset(m.Source)
7259
if err != nil {

0 commit comments

Comments
 (0)