diff --git a/client.go b/client.go index de693f7f9..8301d61e8 100644 --- a/client.go +++ b/client.go @@ -34,7 +34,6 @@ import ( "github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/remotes/docker/schema1" contentservice "github.com/containerd/containerd/services/content" - diffservice "github.com/containerd/containerd/services/diff" "github.com/containerd/containerd/snapshot" "github.com/containerd/typeurl" ptypes "github.com/gogo/protobuf/types" @@ -453,7 +452,7 @@ func (c *Client) ImageService() images.Store { // DiffService returns the underlying Differ func (c *Client) DiffService() diff.Differ { - return diffservice.NewDiffServiceFromClient(diffapi.NewDiffClient(c.conn)) + return NewDiffServiceFromClient(diffapi.NewDiffClient(c.conn)) } // IntrospectionService returns the underlying Introspection Client diff --git a/services/diff/client.go b/diff.go similarity index 85% rename from services/diff/client.go rename to diff.go index d34848be2..4e47efafc 100644 --- a/services/diff/client.go +++ b/diff.go @@ -1,4 +1,4 @@ -package diff +package containerd import ( diffapi "github.com/containerd/containerd/api/services/diff/v1" @@ -12,16 +12,16 @@ import ( // NewDiffServiceFromClient returns a new diff service which communicates // over a GRPC connection. func NewDiffServiceFromClient(client diffapi.DiffClient) diff.Differ { - return &remote{ + return &diffRemote{ client: client, } } -type remote struct { +type diffRemote struct { client diffapi.DiffClient } -func (r *remote) Apply(ctx context.Context, diff ocispec.Descriptor, mounts []mount.Mount) (ocispec.Descriptor, error) { +func (r *diffRemote) Apply(ctx context.Context, diff ocispec.Descriptor, mounts []mount.Mount) (ocispec.Descriptor, error) { req := &diffapi.ApplyRequest{ Diff: fromDescriptor(diff), Mounts: fromMounts(mounts), @@ -33,7 +33,7 @@ func (r *remote) Apply(ctx context.Context, diff ocispec.Descriptor, mounts []mo return toDescriptor(resp.Applied), nil } -func (r *remote) DiffMounts(ctx context.Context, a, b []mount.Mount, opts ...diff.Opt) (ocispec.Descriptor, error) { +func (r *diffRemote) DiffMounts(ctx context.Context, a, b []mount.Mount, opts ...diff.Opt) (ocispec.Descriptor, error) { var config diff.Config for _, opt := range opts { if err := opt(&config); err != nil { diff --git a/services/diff/service.go b/services/diff/service.go index 81e44dcf6..f847693a4 100644 --- a/services/diff/service.go +++ b/services/diff/service.go @@ -140,3 +140,19 @@ func toMounts(apim []*types.Mount) []mount.Mount { } return mounts } + +func toDescriptor(d *types.Descriptor) ocispec.Descriptor { + return ocispec.Descriptor{ + MediaType: d.MediaType, + Digest: d.Digest, + Size: d.Size_, + } +} + +func fromDescriptor(d ocispec.Descriptor) *types.Descriptor { + return &types.Descriptor{ + MediaType: d.MediaType, + Digest: d.Digest, + Size_: d.Size, + } +}