Move Mount into mount pkg

This moves both the Mount type and mountinfo into a single mount
package.

This also opens up the root of the repo to hold the containerd client
implementation.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-05-22 16:35:12 -07:00
parent b07504c713
commit d7af92e00c
32 changed files with 104 additions and 108 deletions

View File

@@ -10,9 +10,9 @@ import (
"path/filepath"
"strings"
"github.com/containerd/containerd"
"github.com/containerd/containerd/fs"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/snapshot"
"github.com/containerd/containerd/snapshot/storage"
@@ -120,11 +120,11 @@ func (o *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, er
return usage, nil
}
func (o *snapshotter) Prepare(ctx context.Context, key, parent string) ([]containerd.Mount, error) {
func (o *snapshotter) Prepare(ctx context.Context, key, parent string) ([]mount.Mount, error) {
return o.createActive(ctx, key, parent, false)
}
func (o *snapshotter) View(ctx context.Context, key, parent string) ([]containerd.Mount, error) {
func (o *snapshotter) View(ctx context.Context, key, parent string) ([]mount.Mount, error) {
return o.createActive(ctx, key, parent, true)
}
@@ -132,7 +132,7 @@ func (o *snapshotter) View(ctx context.Context, key, parent string) ([]container
// called on an read-write or readonly transaction.
//
// This can be used to recover mounts after calling View or Prepare.
func (o *snapshotter) Mounts(ctx context.Context, key string) ([]containerd.Mount, error) {
func (o *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, error) {
ctx, t, err := o.ms.TransactionContext(ctx, false)
if err != nil {
return nil, err
@@ -229,7 +229,7 @@ func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapsho
return storage.WalkInfo(ctx, fn)
}
func (o *snapshotter) createActive(ctx context.Context, key, parent string, readonly bool) ([]containerd.Mount, error) {
func (o *snapshotter) createActive(ctx context.Context, key, parent string, readonly bool) ([]mount.Mount, error) {
var (
path string
snapshotDir = filepath.Join(o.root, "snapshots")
@@ -292,7 +292,7 @@ func (o *snapshotter) createActive(ctx context.Context, key, parent string, read
return o.mounts(active), nil
}
func (o *snapshotter) mounts(active storage.Active) []containerd.Mount {
func (o *snapshotter) mounts(active storage.Active) []mount.Mount {
if len(active.ParentIDs) == 0 {
// if we only have one layer/no parents then just return a bind mount as overlay
// will not work
@@ -301,7 +301,7 @@ func (o *snapshotter) mounts(active storage.Active) []containerd.Mount {
roFlag = "ro"
}
return []containerd.Mount{
return []mount.Mount{
{
Source: o.upperPath(active.ID),
Type: "bind",
@@ -320,7 +320,7 @@ func (o *snapshotter) mounts(active storage.Active) []containerd.Mount {
fmt.Sprintf("upperdir=%s", o.upperPath(active.ID)),
)
} else if len(active.ParentIDs) == 1 {
return []containerd.Mount{
return []mount.Mount{
{
Source: o.upperPath(active.ParentIDs[0]),
Type: "bind",
@@ -338,7 +338,7 @@ func (o *snapshotter) mounts(active storage.Active) []containerd.Mount {
}
options = append(options, fmt.Sprintf("lowerdir=%s", strings.Join(parentPaths, ":")))
return []containerd.Mount{
return []mount.Mount{
{
Type: "overlay",
Source: "overlay",

View File

@@ -11,7 +11,7 @@ import (
"syscall"
"testing"
"github.com/containerd/containerd"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/snapshot"
"github.com/containerd/containerd/snapshot/storage"
"github.com/containerd/containerd/snapshot/testsuite"
@@ -221,7 +221,7 @@ func TestOverlayOverlayRead(t *testing.T) {
t.Error(err)
return
}
if err := containerd.MountAll(mounts, dest); err != nil {
if err := mount.MountAll(mounts, dest); err != nil {
t.Error(err)
return
}