graphdriver interface name change, typo fix

Signed-off-by: Josh Hawn <josh.hawn@docker.com>
This commit is contained in:
Josh Hawn 2014-09-16 12:13:50 -07:00
Родитель dee6b481fe
Коммит 09ad65ebd5
5 изменённых файлов: 35 добавлений и 31 удалений

Просмотреть файл

@ -48,7 +48,7 @@ func Init(home string, options []string) (graphdriver.Driver, error) {
home: home,
}
return graphdriver.NewGenericDriverWrapper(driver), nil
return graphdriver.NaiveDiffDriver(driver), nil
}
type Driver struct {

Просмотреть файл

@ -43,7 +43,7 @@ func Init(home string, options []string) (graphdriver.Driver, error) {
home: home,
}
return graphdriver.NewGenericDriverWrapper(d), nil
return graphdriver.NaiveDiffDriver(d), nil
}
func (d *Driver) String() string {

Просмотреть файл

@ -19,17 +19,20 @@ const (
type InitFunc func(root string, options []string) (Driver, error)
// GenericDriver defines the basic capabilities of a driver.
type GenericDriver interface {
// ProtoDriver defines the basic capabilities of a driver.
// This interface exists solely to be a minimum set of methods
// for client code which choose not to implement the entire Driver
// interface and use the NaiveDiffDriver wrapper constructor.
//
// Use of ProtoDriver directly by client code is not recommended.
type ProtoDriver interface {
// String returns a string representation of this driver.
String() string
// Create creates a new, empty, filesystem layer with the
// specified id and parent. Parent may be "".
Create(id, parent string) error
// Remove attepmts to remove the filesystem layer with this id.
// Remove attempts to remove the filesystem layer with this id.
Remove(id string) error
// Get returns the mountpoint for the layered filesystem referred
// to by this id. You can optionally specify a mountLabel or "".
// Returns the absolute path to the mounted layered filesystem.
@ -40,20 +43,18 @@ type GenericDriver interface {
// Exists returns whether a filesystem layer with the specified
// ID exists on this driver.
Exists(id string) bool
// Status returns a set of key-value pairs which give low
// level diagnostic status about this driver.
Status() [][2]string
// Cleanup performs necessary tasks to release resources
// held by the driver, e.g., unmounting all layered filesystems
// known to this driver.
Cleanup() error
}
// Driver is the interface for layered/snapshot file system drivers.
type Driver interface {
GenericDriver
ProtoDriver
// Diff produces an archive of the changes between the specified
// layer and its parent layer which may be "".
Diff(id, parent string) (archive.Archive, error)

Просмотреть файл

@ -10,27 +10,30 @@ import (
"github.com/docker/docker/utils"
)
// GenericDriverWrapper takes a generic Driver and adds the
// capability of the following methods which it doesn't
// support on its own:
// naiveDiffDriver takes a ProtoDriver and adds the
// capability of the Diffing methods which it may or may not
// support on its own. See the comment on the exported
// NaiveDiffDriver function below.
// Notably, the AUFS driver doesn't need to be wrapped like this.
type naiveDiffDriver struct {
ProtoDriver
}
// NaiveDiffDriver returns a fully functional driver that wraps the
// given ProtoDriver and adds the capability of the following methods which
// it may or may not support on its own:
// Diff(id, parent string) (archive.Archive, error)
// Changes(id, parent string) ([]archive.Change, error)
// ApplyDiff(id, parent string, diff archive.ArchiveReader) (bytes int64, err error)
// DiffSize(id, parent string) (bytes int64, err error)
// Notably, the AUFS driver doesn't need to be wrapped like this.
type GenericDriverWrapper struct {
GenericDriver
}
// NewGenericDriverWrapper returns a fully functional driver that wraps the given GenericDriver.
func NewGenericDriverWrapper(driver GenericDriver) Driver {
return &GenericDriverWrapper{GenericDriver: driver}
func NaiveDiffDriver(driver ProtoDriver) Driver {
return &naiveDiffDriver{ProtoDriver: driver}
}
// Diff produces an archive of the changes between the specified
// layer and its parent layer which may be "".
func (gdw *GenericDriverWrapper) Diff(id, parent string) (arch archive.Archive, err error) {
driver := gdw.GenericDriver
func (gdw *naiveDiffDriver) Diff(id, parent string) (arch archive.Archive, err error) {
driver := gdw.ProtoDriver
layerFs, err := driver.Get(id, "")
if err != nil {
@ -80,8 +83,8 @@ func (gdw *GenericDriverWrapper) Diff(id, parent string) (arch archive.Archive,
// Changes produces a list of changes between the specified layer
// and its parent layer. If parent is "", then all changes will be ADD changes.
func (gdw *GenericDriverWrapper) Changes(id, parent string) ([]archive.Change, error) {
driver := gdw.GenericDriver
func (gdw *naiveDiffDriver) Changes(id, parent string) ([]archive.Change, error) {
driver := gdw.ProtoDriver
layerFs, err := driver.Get(id, "")
if err != nil {
@ -105,8 +108,8 @@ func (gdw *GenericDriverWrapper) Changes(id, parent string) ([]archive.Change, e
// ApplyDiff extracts the changeset from the given diff into the
// layer with the specified id and parent, returning the size of the
// new layer in bytes.
func (gdw *GenericDriverWrapper) ApplyDiff(id, parent string, diff archive.ArchiveReader) (bytes int64, err error) {
driver := gdw.GenericDriver
func (gdw *naiveDiffDriver) ApplyDiff(id, parent string, diff archive.ArchiveReader) (bytes int64, err error) {
driver := gdw.ProtoDriver
// Mount the root filesystem so we can apply the diff/layer.
layerFs, err := driver.Get(id, "")
@ -144,8 +147,8 @@ func (gdw *GenericDriverWrapper) ApplyDiff(id, parent string, diff archive.Archi
// DiffSize calculates the changes between the specified layer
// and its parent and returns the size in bytes of the changes
// relative to its base filesystem directory.
func (gdw *GenericDriverWrapper) DiffSize(id, parent string) (bytes int64, err error) {
driver := gdw.GenericDriver
func (gdw *naiveDiffDriver) DiffSize(id, parent string) (bytes int64, err error) {
driver := gdw.ProtoDriver
changes, err := gdw.Changes(id, parent)
if err != nil {

Просмотреть файл

@ -19,7 +19,7 @@ func Init(home string, options []string) (graphdriver.Driver, error) {
d := &Driver{
home: home,
}
return graphdriver.NewGenericDriverWrapper(d), nil
return graphdriver.NaiveDiffDriver(d), nil
}
type Driver struct {