From ff42748bc567745198b33baa697338dd697fb621 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 4 Nov 2013 01:54:51 +0000 Subject: [PATCH] Rename graph backends to 'drivers' which is probably more self-explanatory --- aufs/aufs.go | 20 +++++++++---------- graph.go | 10 +++++----- graph_test.go | 6 +++--- .../backend.go => graphdriver/driver.go | 4 ++-- runtime.go | 12 +++++------ 5 files changed, 26 insertions(+), 26 deletions(-) rename graphbackend/backend.go => graphdriver/driver.go (87%) diff --git a/aufs/aufs.go b/aufs/aufs.go index 766091cf04..528a77f59f 100644 --- a/aufs/aufs.go +++ b/aufs/aufs.go @@ -2,23 +2,23 @@ package aufs import ( "fmt" - "github.com/dotcloud/docker/graphbackend" + "github.com/dotcloud/docker/graphdriver" "log" "os" "os/exec" "path" ) -type AufsBackend struct { +type AufsDriver struct { } -// Return a new AUFS backend -// An error is returned if AUFS is not supported -func NewBackend() (*AufsBackend, error) { - return &AufsBackend{}, nil +// New returns a new AUFS driver. +// An error is returned if AUFS is not supported. +func New() (*AufsDriver, error) { + return &AufsDriver{}, nil } -func (a *AufsBackend) Mount(img graphbackend.Image, root string) error { +func (a *AufsDriver) Mount(img graphdriver.Image, root string) error { layers, err := img.Layers() if err != nil { return err @@ -40,7 +40,7 @@ func (a *AufsBackend) Mount(img graphbackend.Image, root string) error { return nil } -func (a *AufsBackend) Unmount(root string) error { +func (a *AufsDriver) Unmount(root string) error { target := path.Join(root, "rootfs") if _, err := os.Stat(target); err != nil { if os.IsNotExist(err) { @@ -51,11 +51,11 @@ func (a *AufsBackend) Unmount(root string) error { return Unmount(target) } -func (a *AufsBackend) Mounted(root string) (bool, error) { +func (a *AufsDriver) Mounted(root string) (bool, error) { return Mounted(path.Join(root, "rootfs")) } -func (a *AufsBackend) aufsMount(ro []string, rw, target string) error { +func (a *AufsDriver) aufsMount(ro []string, rw, target string) error { rwBranch := fmt.Sprintf("%v=rw", rw) roBranches := "" for _, layer := range ro { diff --git a/graph.go b/graph.go index 266bef5a57..e3ed1fc377 100644 --- a/graph.go +++ b/graph.go @@ -2,7 +2,7 @@ package docker import ( "fmt" - "github.com/dotcloud/docker/graphbackend" + "github.com/dotcloud/docker/graphdriver" "github.com/dotcloud/docker/utils" "io" "io/ioutil" @@ -17,12 +17,12 @@ import ( type Graph struct { Root string idIndex *utils.TruncIndex - backend graphbackend.GraphBackend + driver graphdriver.Driver } // NewGraph instantiates a new graph at the given root path in the filesystem. // `root` will be created if it doesn't exist. -func NewGraph(root string, backend graphbackend.GraphBackend) (*Graph, error) { +func NewGraph(root string, driver graphdriver.Driver) (*Graph, error) { abspath, err := filepath.Abs(root) if err != nil { return nil, err @@ -34,7 +34,7 @@ func NewGraph(root string, backend graphbackend.GraphBackend) (*Graph, error) { graph := &Graph{ Root: abspath, idIndex: utils.NewTruncIndex(), - backend: backend, + driver: driver, } if err := graph.restore(); err != nil { return nil, err @@ -241,7 +241,7 @@ func (graph *Graph) getDockerInitLayer() (string, error) { func (graph *Graph) tmp() (*Graph, error) { // Changed to _tmp from :tmp:, because it messed with ":" separators in aufs branch syntax... - return NewGraph(path.Join(graph.Root, "_tmp"), graph.backend) + return NewGraph(path.Join(graph.Root, "_tmp"), graph.driver) } // Check if given error is "not empty". diff --git a/graph_test.go b/graph_test.go index cc4c6614f6..7c13deab1a 100644 --- a/graph_test.go +++ b/graph_test.go @@ -145,12 +145,12 @@ func TestMount(t *testing.T) { if err := os.MkdirAll(rw, 0700); err != nil { t.Fatal(err) } - if err := graph.backend.Mount(image, tmp); err != nil { + if err := graph.driver.Mount(image, tmp); err != nil { t.Fatal(err) } // FIXME: test for mount contents defer func() { - if err := graph.backend.Unmount(tmp); err != nil { + if err := graph.driver.Unmount(tmp); err != nil { t.Error(err) } }() @@ -295,7 +295,7 @@ func tempGraph(t *testing.T) *Graph { if err != nil { t.Fatal(err) } - backend, err := aufs.NewBackend() + backend, err := aufs.New() if err != nil { t.Fatal(err) } diff --git a/graphbackend/backend.go b/graphdriver/driver.go similarity index 87% rename from graphbackend/backend.go rename to graphdriver/driver.go index 33360ad5cb..5570865e84 100644 --- a/graphbackend/backend.go +++ b/graphdriver/driver.go @@ -1,10 +1,10 @@ -package graphbackend +package graphdriver type Image interface { Layers() ([]string, error) } -type GraphBackend interface { +type Driver interface { // Create(img *Image) error // Delete(img *Image) error Mount(img Image, root string) error diff --git a/runtime.go b/runtime.go index e2ee188391..78154b15c9 100644 --- a/runtime.go +++ b/runtime.go @@ -582,16 +582,16 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) { if err := os.MkdirAll(runtimeRepo, 0700); err != nil && !os.IsExist(err) { return nil, err } - backend, err := aufs.NewBackend() + driver, err := aufs.New() if err != nil { return nil, err } - g, err := NewGraph(path.Join(config.GraphPath, "graph"), backend) + g, err := NewGraph(path.Join(config.GraphPath, "graph"), driver) if err != nil { return nil, err } - volumes, err := NewGraph(path.Join(config.GraphPath, "volumes"), backend) + volumes, err := NewGraph(path.Join(config.GraphPath, "volumes"), driver) if err != nil { return nil, err } @@ -659,15 +659,15 @@ func (runtime *Runtime) Mount(container *Container) error { if err != nil { return err } - return runtime.graph.backend.Mount(img, container.root) + return runtime.graph.driver.Mount(img, container.root) } func (runtime *Runtime) Unmount(container *Container) error { - return runtime.graph.backend.Unmount(container.root) + return runtime.graph.driver.Unmount(container.root) } func (runtime *Runtime) Mounted(container *Container) (bool, error) { - return runtime.graph.backend.Mounted(container.root) + return runtime.graph.driver.Mounted(container.root) } func (runtime *Runtime) Changes(container *Container) ([]Change, error) {