mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Rename graph backends to 'drivers' which is probably more self-explanatory
This commit is contained in:
parent
699a1074fb
commit
ff42748bc5
5 changed files with 26 additions and 26 deletions
20
aufs/aufs.go
20
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 {
|
||||
|
|
10
graph.go
10
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".
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
12
runtime.go
12
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) {
|
||||
|
|
Loading…
Reference in a new issue