mirror of https://github.com/docker/docs.git
Rename graph backends to 'drivers' which is probably more self-explanatory
This commit is contained in:
parent
699a1074fb
commit
ff42748bc5
20
aufs/aufs.go
20
aufs/aufs.go
|
@ -2,23 +2,23 @@ package aufs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/graphbackend"
|
"github.com/dotcloud/docker/graphdriver"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AufsBackend struct {
|
type AufsDriver struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a new AUFS backend
|
// New returns a new AUFS driver.
|
||||||
// An error is returned if AUFS is not supported
|
// An error is returned if AUFS is not supported.
|
||||||
func NewBackend() (*AufsBackend, error) {
|
func New() (*AufsDriver, error) {
|
||||||
return &AufsBackend{}, nil
|
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()
|
layers, err := img.Layers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -40,7 +40,7 @@ func (a *AufsBackend) Mount(img graphbackend.Image, root string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsBackend) Unmount(root string) error {
|
func (a *AufsDriver) Unmount(root string) error {
|
||||||
target := path.Join(root, "rootfs")
|
target := path.Join(root, "rootfs")
|
||||||
if _, err := os.Stat(target); err != nil {
|
if _, err := os.Stat(target); err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
@ -51,11 +51,11 @@ func (a *AufsBackend) Unmount(root string) error {
|
||||||
return Unmount(target)
|
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"))
|
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)
|
rwBranch := fmt.Sprintf("%v=rw", rw)
|
||||||
roBranches := ""
|
roBranches := ""
|
||||||
for _, layer := range ro {
|
for _, layer := range ro {
|
||||||
|
|
10
graph.go
10
graph.go
|
@ -2,7 +2,7 @@ package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/graphbackend"
|
"github.com/dotcloud/docker/graphdriver"
|
||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -17,12 +17,12 @@ import (
|
||||||
type Graph struct {
|
type Graph struct {
|
||||||
Root string
|
Root string
|
||||||
idIndex *utils.TruncIndex
|
idIndex *utils.TruncIndex
|
||||||
backend graphbackend.GraphBackend
|
driver graphdriver.Driver
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGraph instantiates a new graph at the given root path in the filesystem.
|
// NewGraph instantiates a new graph at the given root path in the filesystem.
|
||||||
// `root` will be created if it doesn't exist.
|
// `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)
|
abspath, err := filepath.Abs(root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -34,7 +34,7 @@ func NewGraph(root string, backend graphbackend.GraphBackend) (*Graph, error) {
|
||||||
graph := &Graph{
|
graph := &Graph{
|
||||||
Root: abspath,
|
Root: abspath,
|
||||||
idIndex: utils.NewTruncIndex(),
|
idIndex: utils.NewTruncIndex(),
|
||||||
backend: backend,
|
driver: driver,
|
||||||
}
|
}
|
||||||
if err := graph.restore(); err != nil {
|
if err := graph.restore(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -241,7 +241,7 @@ func (graph *Graph) getDockerInitLayer() (string, error) {
|
||||||
|
|
||||||
func (graph *Graph) tmp() (*Graph, error) {
|
func (graph *Graph) tmp() (*Graph, error) {
|
||||||
// Changed to _tmp from :tmp:, because it messed with ":" separators in aufs branch syntax...
|
// 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".
|
// Check if given error is "not empty".
|
||||||
|
|
|
@ -145,12 +145,12 @@ func TestMount(t *testing.T) {
|
||||||
if err := os.MkdirAll(rw, 0700); err != nil {
|
if err := os.MkdirAll(rw, 0700); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := graph.backend.Mount(image, tmp); err != nil {
|
if err := graph.driver.Mount(image, tmp); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// FIXME: test for mount contents
|
// FIXME: test for mount contents
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := graph.backend.Unmount(tmp); err != nil {
|
if err := graph.driver.Unmount(tmp); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -295,7 +295,7 @@ func tempGraph(t *testing.T) *Graph {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
backend, err := aufs.NewBackend()
|
backend, err := aufs.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package graphbackend
|
package graphdriver
|
||||||
|
|
||||||
type Image interface {
|
type Image interface {
|
||||||
Layers() ([]string, error)
|
Layers() ([]string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type GraphBackend interface {
|
type Driver interface {
|
||||||
// Create(img *Image) error
|
// Create(img *Image) error
|
||||||
// Delete(img *Image) error
|
// Delete(img *Image) error
|
||||||
Mount(img Image, root string) 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) {
|
if err := os.MkdirAll(runtimeRepo, 0700); err != nil && !os.IsExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
backend, err := aufs.NewBackend()
|
driver, err := aufs.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
g, err := NewGraph(path.Join(config.GraphPath, "graph"), backend)
|
g, err := NewGraph(path.Join(config.GraphPath, "graph"), driver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
volumes, err := NewGraph(path.Join(config.GraphPath, "volumes"), backend)
|
volumes, err := NewGraph(path.Join(config.GraphPath, "volumes"), driver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -659,15 +659,15 @@ func (runtime *Runtime) Mount(container *Container) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
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) {
|
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) {
|
func (runtime *Runtime) Changes(container *Container) ([]Change, error) {
|
||||||
|
|
Loading…
Reference in New Issue