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:
@@ -3,10 +3,10 @@ package diff
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
diffapi "github.com/containerd/containerd/api/services/diff"
|
||||
"github.com/containerd/containerd/api/types/descriptor"
|
||||
mounttypes "github.com/containerd/containerd/api/types/mount"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/rootfs"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
@@ -28,7 +28,7 @@ type remote struct {
|
||||
client diffapi.DiffClient
|
||||
}
|
||||
|
||||
func (r *remote) Apply(ctx context.Context, diff ocispec.Descriptor, mounts []containerd.Mount) (ocispec.Descriptor, error) {
|
||||
func (r *remote) Apply(ctx context.Context, diff ocispec.Descriptor, mounts []mount.Mount) (ocispec.Descriptor, error) {
|
||||
req := &diffapi.ApplyRequest{
|
||||
Diff: fromDescriptor(diff),
|
||||
Mounts: fromMounts(mounts),
|
||||
@@ -40,7 +40,7 @@ func (r *remote) Apply(ctx context.Context, diff ocispec.Descriptor, mounts []co
|
||||
return toDescriptor(resp.Applied), nil
|
||||
}
|
||||
|
||||
func (r *remote) DiffMounts(ctx context.Context, a, b []containerd.Mount, media, ref string) (ocispec.Descriptor, error) {
|
||||
func (r *remote) DiffMounts(ctx context.Context, a, b []mount.Mount, media, ref string) (ocispec.Descriptor, error) {
|
||||
req := &diffapi.DiffRequest{
|
||||
Left: fromMounts(a),
|
||||
Right: fromMounts(b),
|
||||
@@ -62,7 +62,7 @@ func fromDescriptor(d ocispec.Descriptor) *descriptor.Descriptor {
|
||||
}
|
||||
}
|
||||
|
||||
func fromMounts(mounts []containerd.Mount) []*mounttypes.Mount {
|
||||
func fromMounts(mounts []mount.Mount) []*mounttypes.Mount {
|
||||
apiMounts := make([]*mounttypes.Mount, len(mounts))
|
||||
for i, m := range mounts {
|
||||
apiMounts[i] = &mounttypes.Mount{
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
diffapi "github.com/containerd/containerd/api/services/diff"
|
||||
"github.com/containerd/containerd/api/types/descriptor"
|
||||
mounttypes "github.com/containerd/containerd/api/types/mount"
|
||||
"github.com/containerd/containerd/archive"
|
||||
"github.com/containerd/containerd/archive/compression"
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/snapshot"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
@@ -59,10 +59,10 @@ func (s *service) Apply(ctx context.Context, er *diffapi.ApplyRequest) (*diffapi
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
if err := containerd.MountAll(mounts, dir); err != nil {
|
||||
if err := mount.MountAll(mounts, dir); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to mount")
|
||||
}
|
||||
defer containerd.Unmount(dir, 0)
|
||||
defer mount.Unmount(dir, 0)
|
||||
|
||||
r, err := s.store.Reader(ctx, desc.Digest)
|
||||
if err != nil {
|
||||
@@ -118,15 +118,15 @@ func (s *service) Diff(ctx context.Context, dr *diffapi.DiffRequest) (*diffapi.D
|
||||
}
|
||||
defer os.RemoveAll(bDir)
|
||||
|
||||
if err := containerd.MountAll(aMounts, aDir); err != nil {
|
||||
if err := mount.MountAll(aMounts, aDir); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to mount")
|
||||
}
|
||||
defer containerd.Unmount(aDir, 0)
|
||||
defer mount.Unmount(aDir, 0)
|
||||
|
||||
if err := containerd.MountAll(bMounts, bDir); err != nil {
|
||||
if err := mount.MountAll(bMounts, bDir); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to mount")
|
||||
}
|
||||
defer containerd.Unmount(bDir, 0)
|
||||
defer mount.Unmount(bDir, 0)
|
||||
|
||||
cw, err := s.store.Writer(ctx, dr.Ref, 0, "")
|
||||
if err != nil {
|
||||
@@ -190,10 +190,10 @@ func toDescriptor(d *descriptor.Descriptor) ocispec.Descriptor {
|
||||
}
|
||||
}
|
||||
|
||||
func toMounts(apim []*mounttypes.Mount) []containerd.Mount {
|
||||
mounts := make([]containerd.Mount, len(apim))
|
||||
func toMounts(apim []*mounttypes.Mount) []mount.Mount {
|
||||
mounts := make([]mount.Mount, len(apim))
|
||||
for i, m := range apim {
|
||||
mounts[i] = containerd.Mount{
|
||||
mounts[i] = mount.Mount{
|
||||
Type: m.Type,
|
||||
Source: m.Source,
|
||||
Options: m.Options,
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
api "github.com/containerd/containerd/api/services/execution"
|
||||
"github.com/containerd/containerd/api/types/container"
|
||||
"github.com/containerd/containerd/api/types/descriptor"
|
||||
@@ -17,6 +16,7 @@ import (
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/images"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
protobuf "github.com/gogo/protobuf/types"
|
||||
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
||||
@@ -108,7 +108,7 @@ func (s *Service) Create(ctx context.Context, r *api.CreateRequest) (*api.Create
|
||||
Checkpoint: checkpointPath,
|
||||
}
|
||||
for _, m := range r.Rootfs {
|
||||
opts.Rootfs = append(opts.Rootfs, containerd.Mount{
|
||||
opts.Rootfs = append(opts.Rootfs, mount.Mount{
|
||||
Type: m.Type,
|
||||
Source: m.Source,
|
||||
Options: m.Options,
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
snapshotapi "github.com/containerd/containerd/api/services/snapshot"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/snapshot"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -42,7 +42,7 @@ func (r *remoteSnapshotter) Usage(ctx context.Context, key string) (snapshot.Usa
|
||||
return toUsage(resp), nil
|
||||
}
|
||||
|
||||
func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]containerd.Mount, error) {
|
||||
func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, error) {
|
||||
resp, err := r.client.Mounts(ctx, &snapshotapi.MountsRequest{Key: key})
|
||||
if err != nil {
|
||||
return nil, rewriteGRPCError(err)
|
||||
@@ -50,7 +50,7 @@ func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]container
|
||||
return toMounts(resp), nil
|
||||
}
|
||||
|
||||
func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string) ([]containerd.Mount, error) {
|
||||
func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string) ([]mount.Mount, error) {
|
||||
resp, err := r.client.Prepare(ctx, &snapshotapi.PrepareRequest{Key: key, Parent: parent})
|
||||
if err != nil {
|
||||
return nil, rewriteGRPCError(err)
|
||||
@@ -58,7 +58,7 @@ func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string) ([]
|
||||
return toMounts(resp), nil
|
||||
}
|
||||
|
||||
func (r *remoteSnapshotter) View(ctx context.Context, key, parent string) ([]containerd.Mount, error) {
|
||||
func (r *remoteSnapshotter) View(ctx context.Context, key, parent string) ([]mount.Mount, error) {
|
||||
resp, err := r.client.View(ctx, &snapshotapi.PrepareRequest{Key: key, Parent: parent})
|
||||
if err != nil {
|
||||
return nil, rewriteGRPCError(err)
|
||||
@@ -145,10 +145,10 @@ func toUsage(resp *snapshotapi.UsageResponse) snapshot.Usage {
|
||||
}
|
||||
}
|
||||
|
||||
func toMounts(resp *snapshotapi.MountsResponse) []containerd.Mount {
|
||||
mounts := make([]containerd.Mount, len(resp.Mounts))
|
||||
func toMounts(resp *snapshotapi.MountsResponse) []mount.Mount {
|
||||
mounts := make([]mount.Mount, len(resp.Mounts))
|
||||
for i, m := range resp.Mounts {
|
||||
mounts[i] = containerd.Mount{
|
||||
mounts[i] = mount.Mount{
|
||||
Type: m.Type,
|
||||
Source: m.Source,
|
||||
Options: m.Options,
|
||||
|
||||
@@ -3,10 +3,10 @@ package snapshot
|
||||
import (
|
||||
gocontext "context"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
snapshotapi "github.com/containerd/containerd/api/services/snapshot"
|
||||
mounttypes "github.com/containerd/containerd/api/types/mount"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/snapshot"
|
||||
protoempty "github.com/golang/protobuf/ptypes/empty"
|
||||
@@ -189,7 +189,7 @@ func fromUsage(usage snapshot.Usage) *snapshotapi.UsageResponse {
|
||||
}
|
||||
}
|
||||
|
||||
func fromMounts(mounts []containerd.Mount) *snapshotapi.MountsResponse {
|
||||
func fromMounts(mounts []mount.Mount) *snapshotapi.MountsResponse {
|
||||
resp := &snapshotapi.MountsResponse{
|
||||
Mounts: make([]*mounttypes.Mount, len(mounts)),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user