mirror of https://github.com/docker/docs.git
Merge pull request #52 from crosbymichael/rename-aufs-driver
Rename AufsDriver to Driver to be consistent
This commit is contained in:
commit
43b709ab36
|
@ -37,7 +37,7 @@ func init() {
|
||||||
graphdriver.Register("aufs", Init)
|
graphdriver.Register("aufs", Init)
|
||||||
}
|
}
|
||||||
|
|
||||||
type AufsDriver struct {
|
type Driver struct {
|
||||||
root string
|
root string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ func Init(root string) (graphdriver.Driver, error) {
|
||||||
// If not populate the dir structure
|
// If not populate the dir structure
|
||||||
if err := os.MkdirAll(root, 0755); err != nil {
|
if err := os.MkdirAll(root, 0755); err != nil {
|
||||||
if os.IsExist(err) {
|
if os.IsExist(err) {
|
||||||
return &AufsDriver{root}, nil
|
return &Driver{root}, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ func Init(root string) (graphdriver.Driver, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &AufsDriver{root}, nil
|
return &Driver{root}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a nil error if the kernel supports aufs
|
// Return a nil error if the kernel supports aufs
|
||||||
|
@ -95,21 +95,21 @@ func supportsAufs() error {
|
||||||
return fmt.Errorf("AUFS was not found in /proc/filesystems")
|
return fmt.Errorf("AUFS was not found in /proc/filesystems")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a AufsDriver) rootPath() string {
|
func (a Driver) rootPath() string {
|
||||||
return a.root
|
return a.root
|
||||||
}
|
}
|
||||||
|
|
||||||
func (AufsDriver) String() string {
|
func (Driver) String() string {
|
||||||
return "aufs"
|
return "aufs"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (AufsDriver) Status() [][2]string {
|
func (Driver) Status() [][2]string {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exists returns true if the given id is registered with
|
// Exists returns true if the given id is registered with
|
||||||
// this driver
|
// this driver
|
||||||
func (a AufsDriver) Exists(id string) bool {
|
func (a Driver) Exists(id string) bool {
|
||||||
if _, err := os.Lstat(path.Join(a.rootPath(), "layers", id)); err != nil {
|
if _, err := os.Lstat(path.Join(a.rootPath(), "layers", id)); err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ func (a AufsDriver) Exists(id string) bool {
|
||||||
|
|
||||||
// Three folders are created for each id
|
// Three folders are created for each id
|
||||||
// mnt, layers, and diff
|
// mnt, layers, and diff
|
||||||
func (a *AufsDriver) Create(id, parent string) error {
|
func (a *Driver) Create(id, parent string) error {
|
||||||
if err := a.createDirsFor(id); err != nil {
|
if err := a.createDirsFor(id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ func (a *AufsDriver) Create(id, parent string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsDriver) createDirsFor(id string) error {
|
func (a *Driver) createDirsFor(id string) error {
|
||||||
paths := []string{
|
paths := []string{
|
||||||
"mnt",
|
"mnt",
|
||||||
"diff",
|
"diff",
|
||||||
|
@ -162,7 +162,7 @@ func (a *AufsDriver) createDirsFor(id string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmount and remove the dir information
|
// Unmount and remove the dir information
|
||||||
func (a *AufsDriver) Remove(id string) error {
|
func (a *Driver) Remove(id string) error {
|
||||||
// Make sure the dir is umounted first
|
// Make sure the dir is umounted first
|
||||||
if err := a.unmount(id); err != nil {
|
if err := a.unmount(id); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -194,7 +194,7 @@ func (a *AufsDriver) Remove(id string) error {
|
||||||
|
|
||||||
// Return the rootfs path for the id
|
// Return the rootfs path for the id
|
||||||
// This will mount the dir at it's given path
|
// This will mount the dir at it's given path
|
||||||
func (a *AufsDriver) Get(id string) (string, error) {
|
func (a *Driver) Get(id string) (string, error) {
|
||||||
ids, err := getParentIds(a.rootPath(), id)
|
ids, err := getParentIds(a.rootPath(), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
|
@ -216,23 +216,23 @@ func (a *AufsDriver) Get(id string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an archive of the contents for the id
|
// Returns an archive of the contents for the id
|
||||||
func (a *AufsDriver) Diff(id string) (archive.Archive, error) {
|
func (a *Driver) Diff(id string) (archive.Archive, error) {
|
||||||
return archive.TarFilter(path.Join(a.rootPath(), "diff", id), &archive.TarOptions{
|
return archive.TarFilter(path.Join(a.rootPath(), "diff", id), &archive.TarOptions{
|
||||||
Recursive: true,
|
Recursive: true,
|
||||||
Compression: archive.Uncompressed,
|
Compression: archive.Uncompressed,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsDriver) ApplyDiff(id string, diff archive.Archive) error {
|
func (a *Driver) ApplyDiff(id string, diff archive.Archive) error {
|
||||||
return archive.Untar(diff, path.Join(a.rootPath(), "diff", id), nil)
|
return archive.Untar(diff, path.Join(a.rootPath(), "diff", id), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the size of the contents for the id
|
// Returns the size of the contents for the id
|
||||||
func (a *AufsDriver) DiffSize(id string) (int64, error) {
|
func (a *Driver) DiffSize(id string) (int64, error) {
|
||||||
return utils.TreeSize(path.Join(a.rootPath(), "diff", id))
|
return utils.TreeSize(path.Join(a.rootPath(), "diff", id))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsDriver) Changes(id string) ([]archive.Change, error) {
|
func (a *Driver) Changes(id string) ([]archive.Change, error) {
|
||||||
layers, err := a.getParentLayerPaths(id)
|
layers, err := a.getParentLayerPaths(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -240,7 +240,7 @@ func (a *AufsDriver) Changes(id string) ([]archive.Change, error) {
|
||||||
return archive.Changes(layers, path.Join(a.rootPath(), "diff", id))
|
return archive.Changes(layers, path.Join(a.rootPath(), "diff", id))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsDriver) getParentLayerPaths(id string) ([]string, error) {
|
func (a *Driver) getParentLayerPaths(id string) ([]string, error) {
|
||||||
parentIds, err := getParentIds(a.rootPath(), id)
|
parentIds, err := getParentIds(a.rootPath(), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -257,7 +257,7 @@ func (a *AufsDriver) getParentLayerPaths(id string) ([]string, error) {
|
||||||
return layers, nil
|
return layers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsDriver) mount(id string) error {
|
func (a *Driver) mount(id string) error {
|
||||||
// If the id is mounted or we get an error return
|
// If the id is mounted or we get an error return
|
||||||
if mounted, err := a.mounted(id); err != nil || mounted {
|
if mounted, err := a.mounted(id); err != nil || mounted {
|
||||||
return err
|
return err
|
||||||
|
@ -279,7 +279,7 @@ func (a *AufsDriver) mount(id string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsDriver) unmount(id string) error {
|
func (a *Driver) unmount(id string) error {
|
||||||
if mounted, err := a.mounted(id); err != nil || !mounted {
|
if mounted, err := a.mounted(id); err != nil || !mounted {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -287,13 +287,13 @@ func (a *AufsDriver) unmount(id string) error {
|
||||||
return Unmount(target)
|
return Unmount(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsDriver) mounted(id string) (bool, error) {
|
func (a *Driver) mounted(id string) (bool, error) {
|
||||||
target := path.Join(a.rootPath(), "mnt", id)
|
target := path.Join(a.rootPath(), "mnt", id)
|
||||||
return Mounted(target)
|
return Mounted(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// During cleanup aufs needs to unmount all mountpoints
|
// During cleanup aufs needs to unmount all mountpoints
|
||||||
func (a *AufsDriver) Cleanup() error {
|
func (a *Driver) Cleanup() error {
|
||||||
ids, err := loadIds(path.Join(a.rootPath(), "layers"))
|
ids, err := loadIds(path.Join(a.rootPath(), "layers"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -306,7 +306,7 @@ func (a *AufsDriver) Cleanup() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsDriver) aufsMount(ro []string, rw, target string) error {
|
func (a *Driver) 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 {
|
||||||
|
|
|
@ -11,7 +11,7 @@ var (
|
||||||
tmp = path.Join(os.TempDir(), "aufs-tests", "aufs")
|
tmp = path.Join(os.TempDir(), "aufs-tests", "aufs")
|
||||||
)
|
)
|
||||||
|
|
||||||
func newDriver(t *testing.T) *AufsDriver {
|
func newDriver(t *testing.T) *Driver {
|
||||||
if err := os.MkdirAll(tmp, 0755); err != nil {
|
if err := os.MkdirAll(tmp, 0755); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ func newDriver(t *testing.T) *AufsDriver {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
return d.(*AufsDriver)
|
return d.(*Driver)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewAufsDriver(t *testing.T) {
|
func TestNewDriver(t *testing.T) {
|
||||||
if err := os.MkdirAll(tmp, 0755); err != nil {
|
if err := os.MkdirAll(tmp, 0755); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ func pathExists(pth string) bool {
|
||||||
// For the migration we try to move the folder containing the layer files, if that
|
// For the migration we try to move the folder containing the layer files, if that
|
||||||
// fails because the data is currently mounted we will fallback to creating a
|
// fails because the data is currently mounted we will fallback to creating a
|
||||||
// symlink.
|
// symlink.
|
||||||
func (a *AufsDriver) Migrate(pth string, setupInit func(p string) error) error {
|
func (a *Driver) Migrate(pth string, setupInit func(p string) error) error {
|
||||||
if pathExists(path.Join(pth, "graph")) {
|
if pathExists(path.Join(pth, "graph")) {
|
||||||
if err := a.migrateImages(path.Join(pth, "graph")); err != nil {
|
if err := a.migrateImages(path.Join(pth, "graph")); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -46,7 +46,7 @@ func (a *AufsDriver) Migrate(pth string, setupInit func(p string) error) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsDriver) migrateContainers(pth string, setupInit func(p string) error) error {
|
func (a *Driver) migrateContainers(pth string, setupInit func(p string) error) error {
|
||||||
fis, err := ioutil.ReadDir(pth)
|
fis, err := ioutil.ReadDir(pth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -88,7 +88,7 @@ func (a *AufsDriver) migrateContainers(pth string, setupInit func(p string) erro
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsDriver) migrateImages(pth string) error {
|
func (a *Driver) migrateImages(pth string) error {
|
||||||
fis, err := ioutil.ReadDir(pth)
|
fis, err := ioutil.ReadDir(pth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -124,7 +124,7 @@ func (a *AufsDriver) migrateImages(pth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AufsDriver) migrateImage(m *metadata, pth string, migrated map[string]bool) error {
|
func (a *Driver) migrateImage(m *metadata, pth string, migrated map[string]bool) error {
|
||||||
if !migrated[m.ID] {
|
if !migrated[m.ID] {
|
||||||
if m.parent != nil {
|
if m.parent != nil {
|
||||||
a.migrateImage(m.parent, pth, migrated)
|
a.migrateImage(m.parent, pth, migrated)
|
||||||
|
|
|
@ -650,7 +650,7 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if ad, ok := driver.(*aufs.AufsDriver); ok {
|
if ad, ok := driver.(*aufs.Driver); ok {
|
||||||
if err := ad.Migrate(config.Root, setupInitLayer); err != nil {
|
if err := ad.Migrate(config.Root, setupInitLayer); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue