client: move diff client to containerd package
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
This commit is contained in:
parent
8d23e5ef9c
commit
aefaeeacb0
@ -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
|
||||
|
@ -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 {
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user