Rename prepare to unpack and init to prepare

Unpack and prepare better map to the actions done by rootfs.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2017-03-14 23:34:32 -07:00
parent 340e56ecd0
commit b1bc82726f
No known key found for this signature in database
GPG key ID: F58C5D0A4405ACDB
8 changed files with 164 additions and 158 deletions

View file

@ -10,28 +10,28 @@ import (
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
func NewPreparerFromClient(client rootfsapi.RootFSClient) rootfs.Preparer {
return remotePreparer{
func NewUnpackerFromClient(client rootfsapi.RootFSClient) rootfs.Unpacker {
return remoteUnpacker{
client: client,
}
}
type remotePreparer struct {
type remoteUnpacker struct {
client rootfsapi.RootFSClient
}
func (rp remotePreparer) Prepare(ctx context.Context, layers []ocispec.Descriptor) (digest.Digest, error) {
pr := rootfsapi.PrepareRequest{
func (rp remoteUnpacker) Unpack(ctx context.Context, layers []ocispec.Descriptor) (digest.Digest, error) {
pr := rootfsapi.UnpackRequest{
Layers: make([]*containerd_v1_types.Descriptor, len(layers)),
}
for i, l := range layers {
pr.Layers[i] = &containerd_v1_types.Descriptor{
MediaType: l.MediaType,
Digest: l.Digest,
MediaSize: l.Size,
Size_: l.Size,
}
}
resp, err := rp.client.Prepare(ctx, &pr)
resp, err := rp.client.Unpack(ctx, &pr)
if err != nil {
return "", nil
}