snapshot: fix terminology inconsistency

LayerManipulator, SnapshotManipulator -> SnapshotManager

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2017-01-17 08:42:27 +00:00
parent 7c975e37a9
commit 1f763301a6
9 changed files with 102 additions and 98 deletions

View file

@ -19,8 +19,8 @@ func NewBtrfs(device, root string) (*Btrfs, error) {
return &Btrfs{device: device, root: root}, nil
}
func (lm *Btrfs) Prepare(key, parent string) ([]containerd.Mount, error) {
active := filepath.Join(lm.root, "active")
func (b *Btrfs) Prepare(key, parent string) ([]containerd.Mount, error) {
active := filepath.Join(b.root, "active")
if err := os.MkdirAll(active, 0755); err != nil {
return nil, err
}
@ -49,7 +49,7 @@ func (lm *Btrfs) Prepare(key, parent string) ([]containerd.Mount, error) {
return []containerd.Mount{
{
Type: "btrfs",
Source: lm.device, // device?
Source: b.device, // device?
// NOTE(stevvooe): While it would be nice to use to uuids for
// mounts, they don't work reliably if the uuids are missing.
Options: []string{fmt.Sprintf("subvolid=%d", info.ID)},
@ -57,8 +57,8 @@ func (lm *Btrfs) Prepare(key, parent string) ([]containerd.Mount, error) {
}, nil
}
func (lm *Btrfs) Commit(name, key string) error {
dir := filepath.Join(lm.root, "active", hash(key))
func (b *Btrfs) Commit(name, key string) error {
dir := filepath.Join(b.root, "active", hash(key))
fmt.Println("commit to", name)
if err := btrfs.SubvolSnapshot(name, dir, true); err != nil {

View file

@ -28,11 +28,11 @@ func TestBtrfs(t *testing.T) {
defer os.RemoveAll(root)
target := filepath.Join(root, "test")
sm, err := NewBtrfs(device.deviceName, root)
b, err := NewBtrfs(device.deviceName, root)
if err != nil {
t.Fatal(err)
}
mounts, err := sm.Prepare(target, "")
mounts, err := b.Prepare(target, "")
if err != nil {
t.Fatal(err)
}
@ -68,7 +68,7 @@ func TestBtrfs(t *testing.T) {
t.Fatal(err)
}
if err := sm.Commit(filepath.Join(root, "snapshots/committed"), filepath.Join(root, "test")); err != nil {
if err := b.Commit(filepath.Join(root, "snapshots/committed"), filepath.Join(root, "test")); err != nil {
t.Fatal(err)
}
defer func() {
@ -80,7 +80,7 @@ func TestBtrfs(t *testing.T) {
}()
target = filepath.Join(root, "test2")
mounts, err = sm.Prepare(target, filepath.Join(root, "snapshots/committed"))
mounts, err = b.Prepare(target, filepath.Join(root, "snapshots/committed"))
if err != nil {
t.Fatal(err)
}
@ -99,7 +99,7 @@ func TestBtrfs(t *testing.T) {
t.Fatal(err)
}
if err := sm.Commit(filepath.Join(root, "snapshots/committed2"), target); err != nil {
if err := b.Commit(filepath.Join(root, "snapshots/committed2"), target); err != nil {
t.Fatal(err)
}
defer func() {