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:
parent
340e56ecd0
commit
b1bc82726f
8 changed files with 164 additions and 158 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue