From 5b64f7030df85216d611a9c6778ccfaeea5a7c66 Mon Sep 17 00:00:00 2001 From: Jess Valarezo Date: Thu, 16 Nov 2017 15:45:07 -0800 Subject: [PATCH] client: move snapshot client to containerd package Signed-off-by: Jess Valarezo --- client.go | 3 +-- services/snapshot/service.go | 21 ++++++++++++++++++++ services/snapshot/client.go => snapshot.go | 23 +++++++++++++++++++++- 3 files changed, 44 insertions(+), 3 deletions(-) rename services/snapshot/client.go => snapshot.go (91%) diff --git a/client.go b/client.go index eb5bd9a11..adcb7f864 100644 --- a/client.go +++ b/client.go @@ -37,7 +37,6 @@ import ( diffservice "github.com/containerd/containerd/services/diff" imagesservice "github.com/containerd/containerd/services/images" namespacesservice "github.com/containerd/containerd/services/namespaces" - snapshotservice "github.com/containerd/containerd/services/snapshot" "github.com/containerd/containerd/snapshot" "github.com/containerd/typeurl" ptypes "github.com/gogo/protobuf/types" @@ -441,7 +440,7 @@ func (c *Client) ContentStore() content.Store { // SnapshotService returns the underlying snapshotter for the provided snapshotter name func (c *Client) SnapshotService(snapshotterName string) snapshot.Snapshotter { - return snapshotservice.NewSnapshotterFromClient(snapshotapi.NewSnapshotsClient(c.conn), snapshotterName) + return NewSnapshotterFromClient(snapshotapi.NewSnapshotsClient(c.conn), snapshotterName) } // TaskService returns the underlying TasksClient diff --git a/services/snapshot/service.go b/services/snapshot/service.go index 656f8da35..05c7c80c4 100644 --- a/services/snapshot/service.go +++ b/services/snapshot/service.go @@ -293,3 +293,24 @@ func fromMounts(mounts []mount.Mount) []*types.Mount { } return out } + +func toInfo(info snapshotapi.Info) snapshot.Info { + return snapshot.Info{ + Name: info.Name, + Parent: info.Parent, + Kind: toKind(info.Kind), + Created: info.CreatedAt, + Updated: info.UpdatedAt, + Labels: info.Labels, + } +} + +func toKind(kind snapshotapi.Kind) snapshot.Kind { + if kind == snapshotapi.KindActive { + return snapshot.KindActive + } + if kind == snapshotapi.KindView { + return snapshot.KindView + } + return snapshot.KindCommitted +} diff --git a/services/snapshot/client.go b/snapshot.go similarity index 91% rename from services/snapshot/client.go rename to snapshot.go index 812b00ce0..e29d21ca3 100644 --- a/services/snapshot/client.go +++ b/snapshot.go @@ -1,4 +1,4 @@ -package snapshot +package containerd import ( "context" @@ -206,3 +206,24 @@ func toMounts(mm []*types.Mount) []mount.Mount { } return mounts } + +func fromKind(kind snapshot.Kind) snapshotapi.Kind { + if kind == snapshot.KindActive { + return snapshotapi.KindActive + } + if kind == snapshot.KindView { + return snapshotapi.KindView + } + return snapshotapi.KindCommitted +} + +func fromInfo(info snapshot.Info) snapshotapi.Info { + return snapshotapi.Info{ + Name: info.Name, + Parent: info.Parent, + Kind: fromKind(info.Kind), + CreatedAt: info.Created, + UpdatedAt: info.Updated, + Labels: info.Labels, + } +}