devmapper: register plugin

Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
This commit is contained in:
Maksym Pavlenko 2019-02-14 14:52:42 -08:00
parent cec72efc2a
commit 2218275ec9
No known key found for this signature in database
GPG Key ID: BDA48CBFE7A0FC14
2 changed files with 31 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import (
_ "github.com/containerd/containerd/runtime/v1/linux"
_ "github.com/containerd/containerd/runtime/v2"
_ "github.com/containerd/containerd/runtime/v2/runc/options"
_ "github.com/containerd/containerd/snapshots/devmapper"
_ "github.com/containerd/containerd/snapshots/native"
_ "github.com/containerd/containerd/snapshots/overlay"
_ "github.com/containerd/zfs"

View File

@ -27,14 +27,44 @@ import (
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshots/devmapper/dmsetup"
"github.com/containerd/containerd/snapshots/storage"
"github.com/hashicorp/go-multierror"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
func init() {
plugin.Register(&plugin.Registration{
Type: plugin.SnapshotPlugin,
ID: "devmapper",
Config: &Config{
PoolName: "containerd-pool",
BaseImageSize: "128Mb",
},
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
ic.Meta.Platforms = append(ic.Meta.Platforms, ocispec.Platform{
OS: "linux",
Architecture: "amd64",
})
config, ok := ic.Config.(*Config)
if !ok {
return nil, errors.New("invalid devmapper configuration")
}
if config.RootPath == "" {
config.RootPath = ic.Root
}
return NewSnapshotter(ic.Context, config)
},
})
}
const (
metadataFileName = "metadata.db"
fsTypeExt4 = "ext4"