提交 c107ed4d 编写于 作者: H holyfei 提交者: yangfeiyu

load: set name:tag after the image is loaded

Fix #I1P0YU

Reason: set name:tag after the image is loaded
Signed-off-by: Nyangfeiyu <yangfeiyu2@huawei.com>
上级 0d56aee9
...@@ -18,6 +18,8 @@ package daemon ...@@ -18,6 +18,8 @@ package daemon
import ( import (
"context" "context"
"github.com/containers/image/v5/docker/tarfile"
"github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
constant "isula.org/isula-build" constant "isula.org/isula-build"
...@@ -34,6 +36,16 @@ func (b *Backend) Load(ctx context.Context, req *pb.LoadRequest) (*pb.LoadRespon ...@@ -34,6 +36,16 @@ func (b *Backend) Load(ctx context.Context, req *pb.LoadRequest) (*pb.LoadRespon
return &pb.LoadResponse{}, err return &pb.LoadResponse{}, err
} }
tarfileSource, err := tarfile.NewSourceFromFile(req.Path)
if err != nil {
return &pb.LoadResponse{}, errors.Wrapf(err, "failed to get the source of loading tar file")
}
topLevelImageManifest, err := tarfileSource.LoadTarManifest()
if err != nil || len(topLevelImageManifest) == 0 {
return &pb.LoadResponse{}, errors.Wrapf(err, "failed to get the top level image manifest")
}
_, si, err := image.ResolveFromImage(&image.PrepareImageOptions{ _, si, err := image.ResolveFromImage(&image.PrepareImageOptions{
Ctx: ctx, Ctx: ctx,
FromImage: "docker-archive:" + req.Path, FromImage: "docker-archive:" + req.Path,
...@@ -45,7 +57,7 @@ func (b *Backend) Load(ctx context.Context, req *pb.LoadRequest) (*pb.LoadRespon ...@@ -45,7 +57,7 @@ func (b *Backend) Load(ctx context.Context, req *pb.LoadRequest) (*pb.LoadRespon
return nil, err return nil, err
} }
if err := b.daemon.localStore.SetNames(si.ID, []string{"<none>:<none>"}); err != nil { if err := b.daemon.localStore.SetNames(si.ID, topLevelImageManifest[0].RepoTags); err != nil {
return nil, err return nil, err
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册