Browse code

graphdriver interface name change, typo fix

Signed-off-by: Josh Hawn <josh.hawn@docker.com>

Josh Hawn authored on 2014/09/17 04:13:50
Showing 5 changed files
... ...
@@ -48,7 +48,7 @@ func Init(home string, options []string) (graphdriver.Driver, error) {
48 48
 		home: home,
49 49
 	}
50 50
 
51
-	return graphdriver.NewGenericDriverWrapper(driver), nil
51
+	return graphdriver.NaiveDiffDriver(driver), nil
52 52
 }
53 53
 
54 54
 type Driver struct {
... ...
@@ -43,7 +43,7 @@ func Init(home string, options []string) (graphdriver.Driver, error) {
43 43
 		home:      home,
44 44
 	}
45 45
 
46
-	return graphdriver.NewGenericDriverWrapper(d), nil
46
+	return graphdriver.NaiveDiffDriver(d), nil
47 47
 }
48 48
 
49 49
 func (d *Driver) String() string {
... ...
@@ -19,17 +19,20 @@ const (
19 19
 
20 20
 type InitFunc func(root string, options []string) (Driver, error)
21 21
 
22
-// GenericDriver defines the basic capabilities of a driver.
23
-type GenericDriver interface {
22
+// ProtoDriver defines the basic capabilities of a driver.
23
+// This interface exists solely to be a minimum set of methods
24
+// for client code which choose not to implement the entire Driver
25
+// interface and use the NaiveDiffDriver wrapper constructor.
26
+//
27
+// Use of ProtoDriver directly by client code is not recommended.
28
+type ProtoDriver interface {
24 29
 	// String returns a string representation of this driver.
25 30
 	String() string
26
-
27 31
 	// Create creates a new, empty, filesystem layer with the
28 32
 	// specified id and parent. Parent may be "".
29 33
 	Create(id, parent string) error
30
-	// Remove attepmts to remove the filesystem layer with this id.
34
+	// Remove attempts to remove the filesystem layer with this id.
31 35
 	Remove(id string) error
32
-
33 36
 	// Get returns the mountpoint for the layered filesystem referred
34 37
 	// to by this id. You can optionally specify a mountLabel or "".
35 38
 	// Returns the absolute path to the mounted layered filesystem.
... ...
@@ -40,20 +43,18 @@ type GenericDriver interface {
40 40
 	// Exists returns whether a filesystem layer with the specified
41 41
 	// ID exists on this driver.
42 42
 	Exists(id string) bool
43
-
44 43
 	// Status returns a set of key-value pairs which give low
45 44
 	// level diagnostic status about this driver.
46 45
 	Status() [][2]string
47
-
48 46
 	// Cleanup performs necessary tasks to release resources
49 47
 	// held by the driver, e.g., unmounting all layered filesystems
50 48
 	// known to this driver.
51 49
 	Cleanup() error
52 50
 }
53 51
 
52
+// Driver is the interface for layered/snapshot file system drivers.
54 53
 type Driver interface {
55
-	GenericDriver
56
-
54
+	ProtoDriver
57 55
 	// Diff produces an archive of the changes between the specified
58 56
 	// layer and its parent layer which may be "".
59 57
 	Diff(id, parent string) (archive.Archive, error)
... ...
@@ -10,27 +10,30 @@ import (
10 10
 	"github.com/docker/docker/utils"
11 11
 )
12 12
 
13
-// GenericDriverWrapper takes a generic Driver and adds the
14
-// capability of the following methods which it doesn't
15
-// support on its own:
13
+// naiveDiffDriver takes a ProtoDriver and adds the
14
+// capability of the Diffing methods which it may or may not
15
+// support on its own. See the comment on the exported
16
+// NaiveDiffDriver function below.
17
+// Notably, the AUFS driver doesn't need to be wrapped like this.
18
+type naiveDiffDriver struct {
19
+	ProtoDriver
20
+}
21
+
22
+// NaiveDiffDriver returns a fully functional driver that wraps the
23
+// given ProtoDriver and adds the capability of the following methods which
24
+// it may or may not support on its own:
16 25
 //     Diff(id, parent string) (archive.Archive, error)
17 26
 //     Changes(id, parent string) ([]archive.Change, error)
18 27
 //     ApplyDiff(id, parent string, diff archive.ArchiveReader) (bytes int64, err error)
19 28
 //     DiffSize(id, parent string) (bytes int64, err error)
20
-// Notably, the AUFS driver doesn't need to be wrapped like this.
21
-type GenericDriverWrapper struct {
22
-	GenericDriver
23
-}
24
-
25
-// NewGenericDriverWrapper returns a fully functional driver that wraps the given GenericDriver.
26
-func NewGenericDriverWrapper(driver GenericDriver) Driver {
27
-	return &GenericDriverWrapper{GenericDriver: driver}
29
+func NaiveDiffDriver(driver ProtoDriver) Driver {
30
+	return &naiveDiffDriver{ProtoDriver: driver}
28 31
 }
29 32
 
30 33
 // Diff produces an archive of the changes between the specified
31 34
 // layer and its parent layer which may be "".
32
-func (gdw *GenericDriverWrapper) Diff(id, parent string) (arch archive.Archive, err error) {
33
-	driver := gdw.GenericDriver
35
+func (gdw *naiveDiffDriver) Diff(id, parent string) (arch archive.Archive, err error) {
36
+	driver := gdw.ProtoDriver
34 37
 
35 38
 	layerFs, err := driver.Get(id, "")
36 39
 	if err != nil {
... ...
@@ -80,8 +83,8 @@ func (gdw *GenericDriverWrapper) Diff(id, parent string) (arch archive.Archive,
80 80
 
81 81
 // Changes produces a list of changes between the specified layer
82 82
 // and its parent layer. If parent is "", then all changes will be ADD changes.
83
-func (gdw *GenericDriverWrapper) Changes(id, parent string) ([]archive.Change, error) {
84
-	driver := gdw.GenericDriver
83
+func (gdw *naiveDiffDriver) Changes(id, parent string) ([]archive.Change, error) {
84
+	driver := gdw.ProtoDriver
85 85
 
86 86
 	layerFs, err := driver.Get(id, "")
87 87
 	if err != nil {
... ...
@@ -105,8 +108,8 @@ func (gdw *GenericDriverWrapper) Changes(id, parent string) ([]archive.Change, e
105 105
 // ApplyDiff extracts the changeset from the given diff into the
106 106
 // layer with the specified id and parent, returning the size of the
107 107
 // new layer in bytes.
108
-func (gdw *GenericDriverWrapper) ApplyDiff(id, parent string, diff archive.ArchiveReader) (bytes int64, err error) {
109
-	driver := gdw.GenericDriver
108
+func (gdw *naiveDiffDriver) ApplyDiff(id, parent string, diff archive.ArchiveReader) (bytes int64, err error) {
109
+	driver := gdw.ProtoDriver
110 110
 
111 111
 	// Mount the root filesystem so we can apply the diff/layer.
112 112
 	layerFs, err := driver.Get(id, "")
... ...
@@ -144,8 +147,8 @@ func (gdw *GenericDriverWrapper) ApplyDiff(id, parent string, diff archive.Archi
144 144
 // DiffSize calculates the changes between the specified layer
145 145
 // and its parent and returns the size in bytes of the changes
146 146
 // relative to its base filesystem directory.
147
-func (gdw *GenericDriverWrapper) DiffSize(id, parent string) (bytes int64, err error) {
148
-	driver := gdw.GenericDriver
147
+func (gdw *naiveDiffDriver) DiffSize(id, parent string) (bytes int64, err error) {
148
+	driver := gdw.ProtoDriver
149 149
 
150 150
 	changes, err := gdw.Changes(id, parent)
151 151
 	if err != nil {
... ...
@@ -19,7 +19,7 @@ func Init(home string, options []string) (graphdriver.Driver, error) {
19 19
 	d := &Driver{
20 20
 		home: home,
21 21
 	}
22
-	return graphdriver.NewGenericDriverWrapper(d), nil
22
+	return graphdriver.NaiveDiffDriver(d), nil
23 23
 }
24 24
 
25 25
 type Driver struct {