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
|
||||
}
|
||||
|
|
|
@ -43,13 +43,13 @@ func (s *Service) Register(gs *grpc.Server) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) Prepare(ctx context.Context, pr *rootfsapi.PrepareRequest) (*rootfsapi.PrepareResponse, error) {
|
||||
func (s *Service) Unpack(ctx context.Context, pr *rootfsapi.UnpackRequest) (*rootfsapi.UnpackResponse, error) {
|
||||
layers := make([]ocispec.Descriptor, len(pr.Layers))
|
||||
for i, l := range pr.Layers {
|
||||
layers[i] = ocispec.Descriptor{
|
||||
MediaType: l.MediaType,
|
||||
Digest: l.Digest,
|
||||
Size: l.MediaSize,
|
||||
Size: l.Size_,
|
||||
}
|
||||
}
|
||||
log.G(ctx).Infof("Preparing %#v", layers)
|
||||
|
@ -59,12 +59,12 @@ func (s *Service) Prepare(ctx context.Context, pr *rootfsapi.PrepareRequest) (*r
|
|||
return nil, err
|
||||
}
|
||||
log.G(ctx).Infof("ChainID %#v", chainID)
|
||||
return &rootfsapi.PrepareResponse{
|
||||
return &rootfsapi.UnpackResponse{
|
||||
ChainID: chainID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) InitMounts(ctx context.Context, ir *rootfsapi.InitMountsRequest) (*rootfsapi.MountResponse, error) {
|
||||
func (s *Service) Prepare(ctx context.Context, ir *rootfsapi.PrepareRequest) (*rootfsapi.MountResponse, error) {
|
||||
mounts, err := rootfs.InitRootFS(ctx, ir.Name, ir.ChainID, ir.Readonly, s.snapshotter, mounter{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue