Add namespaced snapshotter implementation

The namespaced snapshotter wraps an existing snapshotter and
enforces namespace.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2017-06-21 15:51:16 -07:00
parent 7ddf411ea8
commit 4ba4f3a1d5
6 changed files with 342 additions and 13 deletions

View File

@@ -10,7 +10,6 @@ import (
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/snapshot"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
@@ -23,35 +22,28 @@ func init() {
ID: "base-diff",
Requires: []plugin.PluginType{
plugin.ContentPlugin,
plugin.SnapshotPlugin,
},
Init: func(ic *plugin.InitContext) (interface{}, error) {
c, err := ic.Get(plugin.ContentPlugin)
if err != nil {
return nil, err
}
s, err := ic.Get(plugin.SnapshotPlugin)
if err != nil {
return nil, err
}
return newBaseDiff(c.(content.Store), s.(snapshot.Snapshotter))
return newBaseDiff(c.(content.Store))
},
})
}
type BaseDiff struct {
store content.Store
snapshotter snapshot.Snapshotter
store content.Store
}
var _ plugin.Differ = &BaseDiff{}
var emptyDesc = ocispec.Descriptor{}
func newBaseDiff(store content.Store, snapshotter snapshot.Snapshotter) (*BaseDiff, error) {
func newBaseDiff(store content.Store) (*BaseDiff, error) {
return &BaseDiff{
store: store,
snapshotter: snapshotter,
store: store,
}, nil
}