Merge pull request #4533 from sedflix/aufs-seperate-plugin

feat(snapshot::aufs): config root_path
This commit is contained in:
Phil Estes 2020-09-18 10:18:31 -04:00 committed by GitHub
commit 1484593ee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 17 deletions

View File

@ -18,4 +18,4 @@
package main package main
import _ "github.com/containerd/aufs" import _ "github.com/containerd/aufs/plugin"

View File

@ -103,4 +103,4 @@ github.com/containerd/zfs 9abf673ca6ff9ab8d9bd776a4cef
github.com/mistifyio/go-zfs f784269be439d704d3dfa1906f45dd848fed2beb github.com/mistifyio/go-zfs f784269be439d704d3dfa1906f45dd848fed2beb
# aufs dependencies # aufs dependencies
github.com/containerd/aufs 371312c1e31c210a21e49bf3dfd3f31729ed9f2f github.com/containerd/aufs dab0cbea06f43329c07667afe1a70411ad555a86

View File

@ -1,7 +1,6 @@
# aufs snapshotter # aufs snapshotter
[![Build Status](https://travis-ci.org/containerd/aufs.svg?branch=master)](https://travis-ci.org/containerd/aufs) [![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) [![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/log"
"github.com/containerd/containerd/mount" "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"
"github.com/containerd/containerd/snapshots/storage" "github.com/containerd/containerd/snapshots/storage"
"github.com/containerd/continuity/fs" "github.com/containerd/continuity/fs"
"github.com/pkg/errors" "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 ( var (
dirperm sync.Once dirperm sync.Once
@ -65,7 +52,7 @@ type snapshotter struct {
// New creates a new snapshotter using aufs // New creates a new snapshotter using aufs
func New(root string) (snapshots.Snapshotter, error) { func New(root string) (snapshots.Snapshotter, error) {
if err := supported(); err != nil { if err := supported(); err != nil {
return nil, errors.Wrap(plugin.ErrSkipPlugin, err.Error()) return nil, err
} }
if err := os.MkdirAll(root, 0700); err != nil { if err := os.MkdirAll(root, 0700); err != nil {
return nil, err 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
},
})
}