New 'dummy' driver uses plain directories and regular copy
This commit is contained in:
parent
0a9df6bc1a
commit
81674fbbdf
3 changed files with 86 additions and 0 deletions
|
@ -28,6 +28,7 @@ var (
|
||||||
priority = []string{
|
priority = []string{
|
||||||
"aufs",
|
"aufs",
|
||||||
"devicemapper",
|
"devicemapper",
|
||||||
|
"dummy",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
84
graphdriver/dummy/driver.go
Normal file
84
graphdriver/dummy/driver.go
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
package dummy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/dotcloud/docker/archive"
|
||||||
|
"github.com/dotcloud/docker/graphdriver"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
graphdriver.Register("dummy", Init)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Init(home string) (graphdriver.Driver, error) {
|
||||||
|
d := &Driver{
|
||||||
|
home: home,
|
||||||
|
}
|
||||||
|
return d, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type Driver struct {
|
||||||
|
home string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Driver) Cleanup() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Driver) Create(id string, parent string) error {
|
||||||
|
dir := d.dir(id)
|
||||||
|
if err := os.MkdirAll(path.Dir(dir), 0700); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := os.Mkdir(dir, 0700); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if parent == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
parentDir, err := d.Get(parent)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("%s: %s", parent, err)
|
||||||
|
}
|
||||||
|
if err := archive.CopyWithTar(parentDir, dir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Driver) dir(id string) string {
|
||||||
|
return path.Join(d.home, "dir", path.Base(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (d *Driver) Remove(id string) error {
|
||||||
|
if _, err := os.Stat(d.dir(id)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return os.RemoveAll(d.dir(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Driver) Get(id string) (string, error) {
|
||||||
|
dir := d.dir(id)
|
||||||
|
if st, err := os.Stat(dir); err != nil {
|
||||||
|
return "", err
|
||||||
|
} else if !st.IsDir() {
|
||||||
|
return "", fmt.Errorf("%s: not a directory", dir)
|
||||||
|
}
|
||||||
|
return dir, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Driver) Diff(id string) (archive.Archive, error) {
|
||||||
|
return nil, fmt.Errorf("Not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Driver) DiffSize(id string) (int64, error) {
|
||||||
|
return -1, fmt.Errorf("Not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Driver) Changes(id string) ([]archive.Change, error) {
|
||||||
|
return nil, fmt.Errorf("Not implemented")
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
_ "github.com/dotcloud/docker/devmapper"
|
_ "github.com/dotcloud/docker/devmapper"
|
||||||
"github.com/dotcloud/docker/gograph"
|
"github.com/dotcloud/docker/gograph"
|
||||||
"github.com/dotcloud/docker/graphdriver"
|
"github.com/dotcloud/docker/graphdriver"
|
||||||
|
_ "github.com/dotcloud/docker/graphdriver/dummy"
|
||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
Loading…
Add table
Reference in a new issue