Pārlūkot izejas kodu

Name sure drivers are confined into their own dir

Michael Crosby 11 gadi atpakaļ
vecāks
revīzija
08a276986c
3 mainītis faili ar 11 papildinājumiem un 11 dzēšanām
  1. 3 4
      aufs/aufs.go
  2. 6 6
      aufs/aufs_test.go
  3. 2 1
      graphdriver/driver.go

+ 3 - 4
aufs/aufs.go

@@ -57,8 +57,7 @@ func Init(root string) (graphdriver.Driver, error) {
 	// Create the root aufs driver dir and return
 	// if it already exists
 	// If not populate the dir structure
-	aufsPath := path.Join(root, "aufs")
-	if err := os.MkdirAll(aufsPath, 0755); err != nil {
+	if err := os.MkdirAll(root, 0755); err != nil {
 		if os.IsExist(err) {
 			return &AufsDriver{root}, nil
 		}
@@ -66,7 +65,7 @@ func Init(root string) (graphdriver.Driver, error) {
 	}
 
 	for _, p := range paths {
-		if err := os.MkdirAll(path.Join(aufsPath, p), 0755); err != nil {
+		if err := os.MkdirAll(path.Join(root, p), 0755); err != nil {
 			return nil, err
 		}
 	}
@@ -93,7 +92,7 @@ func supportsAufs() error {
 }
 
 func (a *AufsDriver) rootPath() string {
-	return path.Join(a.root, "aufs")
+	return a.root
 }
 
 func (a *AufsDriver) String() string {

+ 6 - 6
aufs/aufs_test.go

@@ -8,7 +8,7 @@ import (
 )
 
 var (
-	tmp = path.Join(os.TempDir(), "aufs-tests")
+	tmp = path.Join(os.TempDir(), "aufs-tests", "aufs")
 )
 
 func newDriver(t *testing.T) *AufsDriver {
@@ -58,7 +58,7 @@ func TestCreateDirStructure(t *testing.T) {
 	}
 
 	for _, p := range paths {
-		if _, err := os.Stat(path.Join(tmp, "aufs", p)); err != nil {
+		if _, err := os.Stat(path.Join(tmp, p)); err != nil {
 			t.Fatal(err)
 		}
 	}
@@ -103,7 +103,7 @@ func TestCreateNewDirStructure(t *testing.T) {
 	}
 
 	for _, p := range paths {
-		if _, err := os.Stat(path.Join(tmp, "aufs", p, "1")); err != nil {
+		if _, err := os.Stat(path.Join(tmp, p, "1")); err != nil {
 			t.Fatal(err)
 		}
 	}
@@ -128,7 +128,7 @@ func TestRemoveImage(t *testing.T) {
 	}
 
 	for _, p := range paths {
-		if _, err := os.Stat(path.Join(tmp, "aufs", p, "1")); err == nil {
+		if _, err := os.Stat(path.Join(tmp, p, "1")); err == nil {
 			t.Fatalf("Error should not be nil because dirs with id 1 should be delted: %s", p)
 		}
 	}
@@ -146,7 +146,7 @@ func TestGetWithoutParent(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	expected := path.Join(tmp, "aufs", "diff", "1")
+	expected := path.Join(tmp, "diff", "1")
 	if diffPath != expected {
 		t.Fatalf("Expected path %s got %s", expected, diffPath)
 	}
@@ -244,7 +244,7 @@ func TestMountWithParent(t *testing.T) {
 		t.Fatal("mntPath should not be empty string")
 	}
 
-	expected := path.Join(tmp, "aufs", "mnt", "2")
+	expected := path.Join(tmp, "mnt", "2")
 	if mntPath != expected {
 		t.Fatalf("Expected %s got %s", expected, mntPath)
 	}

+ 2 - 1
graphdriver/driver.go

@@ -5,6 +5,7 @@ import (
 	"github.com/dotcloud/docker/archive"
 	"github.com/dotcloud/docker/utils"
 	"os"
+	"path"
 )
 
 type InitFunc func(root string) (Driver, error)
@@ -48,7 +49,7 @@ func Register(name string, initFunc InitFunc) error {
 
 func getDriver(name, home string) (Driver, error) {
 	if initFunc, exists := drivers[name]; exists {
-		return initFunc(home)
+		return initFunc(path.Join(home, name))
 	}
 	return nil, fmt.Errorf("No such driver: %s", name)
 }