2013-11-07 20:52:56 -05:00
|
|
|
package dummy
|
|
|
|
|
|
|
|
import (
|
2013-11-07 22:02:15 -05:00
|
|
|
"fmt"
|
2013-11-07 20:52:56 -05:00
|
|
|
"github.com/dotcloud/docker/archive"
|
|
|
|
"github.com/dotcloud/docker/graphdriver"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
graphdriver.Register("dummy", Init)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Init(home string) (graphdriver.Driver, error) {
|
|
|
|
d := &Driver{
|
2013-11-07 22:02:15 -05:00
|
|
|
home: home,
|
2013-11-07 20:52:56 -05:00
|
|
|
}
|
|
|
|
return d, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type Driver struct {
|
|
|
|
home string
|
|
|
|
}
|
|
|
|
|
2013-11-07 22:02:15 -05:00
|
|
|
func (d *Driver) String() string {
|
|
|
|
return "dummy"
|
|
|
|
}
|
|
|
|
|
2013-11-07 20:52:56 -05:00
|
|
|
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) DiffSize(id string) (int64, error) {
|
|
|
|
return -1, fmt.Errorf("Not implemented")
|
|
|
|
}
|
2013-11-11 15:09:26 -05:00
|
|
|
|
|
|
|
func (d *Driver) Diff(id string) (archive.Archive, error) {
|
|
|
|
return nil, fmt.Errorf("Not implemented)")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Driver) Changes(id string) ([]archive.Change, error) {
|
|
|
|
return nil, fmt.Errorf("asdlfj)")
|
|
|
|
}
|