aufs: 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:44:02 +05:30
parent fabebe5d55
commit 2354e187c3
6 changed files with 85 additions and 17 deletions

View File

@@ -1,7 +1,6 @@
# aufs snapshotter
[![Build Status](https://travis-ci.org/containerd/aufs.svg?branch=master)](https://travis-ci.org/containerd/aufs)
[![codecov](https://codecov.io/gh/containerd/aufs/branch/master/graph/badge.svg)](https://codecov.io/gh/containerd/aufs)

View File

@@ -32,25 +32,12 @@ import (
"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"
"github.com/containerd/continuity/fs"
"github.com/pkg/errors"
)
func init() {
plugin.Register(&plugin.Registration{
Type: plugin.SnapshotPlugin,
ID: "aufs",
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
ic.Meta.Exports["root"] = ic.Root
return New(ic.Root)
},
})
}
var (
dirperm sync.Once
@@ -65,7 +52,7 @@ type snapshotter struct {
// New creates a new snapshotter using aufs
func New(root string) (snapshots.Snapshotter, error) {
if err := supported(); err != nil {
return nil, errors.Wrap(plugin.ErrSkipPlugin, err.Error())
return nil, err
}
if err := os.MkdirAll(root, 0700); err != nil {
return nil, err

22
vendor/github.com/containerd/aufs/go.mod generated vendored Normal file
View File

@@ -0,0 +1,22 @@
module github.com/containerd/aufs
go 1.13
require (
github.com/Microsoft/hcsshim v0.8.7 // indirect
github.com/containerd/containerd v1.3.1-0.20191213020239-082f7e3aed57
github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb
github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c // indirect
github.com/containerd/typeurl v0.0.0-20190911142611-5eb25027c9fd // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/google/go-cmp v0.3.1 // indirect
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/runc v1.0.0-rc9 // indirect
github.com/pkg/errors v0.8.1
go.etcd.io/bbolt v1.3.3 // indirect
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449
google.golang.org/grpc v1.25.1 // indirect
)

60
vendor/github.com/containerd/aufs/plugin/plugin.go generated vendored Normal file
View File

@@ -0,0 +1,60 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package plugin
import (
"github.com/containerd/aufs"
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin"
"github.com/pkg/errors"
)
// Config represents configuration for the zfs plugin
type Config struct {
// Root directory for the plugin
RootPath string `toml:"root_path"`
}
func init() {
plugin.Register(&plugin.Registration{
Type: plugin.SnapshotPlugin,
ID: "aufs",
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
// get config
config, ok := ic.Config.(*Config)
if !ok {
return nil, errors.New("invalid aufs configuration")
}
// use default ic.Root as root path if config doesn't have a valid root path
root := ic.Root
if len(config.RootPath) != 0 {
root = config.RootPath
}
ic.Meta.Exports["root"] = root
snapshotter, err := aufs.New(root)
if err != nil {
return nil, errors.Wrap(plugin.ErrSkipPlugin, err.Error())
}
return snapshotter, nil
},
})
}