mirror of
https://github.com/containers/podman
synced 2024-10-19 08:44:11 +00:00
More docker compat API fixes
Fixes wrong VirtualSize, ParentId, Architecture, Author, Os and OsVersion value Signed-off-by: Milivoje Legenovic <m.legenovic@gmail.com>
This commit is contained in:
parent
ec0411aecd
commit
15d36f120c
|
@ -1222,6 +1222,11 @@ func (i *Image) inspect(ctx context.Context, calculateSize bool) (*inspect.Image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent, err := i.ParentID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
repoTags, err := i.RepoTags()
|
repoTags, err := i.RepoTags()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1248,6 +1253,7 @@ func (i *Image) inspect(ctx context.Context, calculateSize bool) (*inspect.Image
|
||||||
|
|
||||||
data := &inspect.ImageData{
|
data := &inspect.ImageData{
|
||||||
ID: i.ID(),
|
ID: i.ID(),
|
||||||
|
Parent: parent,
|
||||||
RepoTags: repoTags,
|
RepoTags: repoTags,
|
||||||
RepoDigests: repoDigests,
|
RepoDigests: repoDigests,
|
||||||
Comment: comment,
|
Comment: comment,
|
||||||
|
@ -1258,10 +1264,12 @@ func (i *Image) inspect(ctx context.Context, calculateSize bool) (*inspect.Image
|
||||||
Config: &ociv1Img.Config,
|
Config: &ociv1Img.Config,
|
||||||
Version: info.DockerVersion,
|
Version: info.DockerVersion,
|
||||||
Size: size,
|
Size: size,
|
||||||
VirtualSize: size,
|
// This is good enough for now, but has to be
|
||||||
Annotations: annotations,
|
// replaced later with correct calculation logic
|
||||||
Digest: i.Digest(),
|
VirtualSize: size,
|
||||||
Labels: info.Labels,
|
Annotations: annotations,
|
||||||
|
Digest: i.Digest(),
|
||||||
|
Labels: info.Labels,
|
||||||
RootFS: &inspect.RootFS{
|
RootFS: &inspect.RootFS{
|
||||||
Type: ociv1Img.RootFS.Type,
|
Type: ociv1Img.RootFS.Type,
|
||||||
Layers: ociv1Img.RootFS.DiffIDs,
|
Layers: ociv1Img.RootFS.DiffIDs,
|
||||||
|
@ -1505,6 +1513,15 @@ func (i *Image) GetParent(ctx context.Context) (*Image, error) {
|
||||||
return tree.parent(ctx, i)
|
return tree.parent(ctx, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ParentID returns the image ID of the parent. Return empty string if a parent is not found.
|
||||||
|
func (i *Image) ParentID(ctx context.Context) (string, error) {
|
||||||
|
parent, err := i.GetParent(ctx)
|
||||||
|
if err == nil && parent != nil {
|
||||||
|
return parent.ID(), nil
|
||||||
|
}
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
// GetChildren returns a list of the imageIDs that depend on the image
|
// GetChildren returns a list of the imageIDs that depend on the image
|
||||||
func (i *Image) GetChildren(ctx context.Context) ([]string, error) {
|
func (i *Image) GetChildren(ctx context.Context) ([]string, error) {
|
||||||
children, err := i.getChildren(ctx, true)
|
children, err := i.getChildren(ctx, true)
|
||||||
|
|
|
@ -178,55 +178,34 @@ type ExecStartConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ImageToImageSummary(l *libpodImage.Image) (*entities.ImageSummary, error) {
|
func ImageToImageSummary(l *libpodImage.Image) (*entities.ImageSummary, error) {
|
||||||
|
imageData, err := l.Inspect(context.TODO())
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "failed to obtain summary for image %s", l.ID())
|
||||||
|
}
|
||||||
|
|
||||||
containers, err := l.Containers()
|
containers, err := l.Containers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to obtain Containers for image %s", l.ID())
|
return nil, errors.Wrapf(err, "failed to obtain Containers for image %s", l.ID())
|
||||||
}
|
}
|
||||||
containerCount := len(containers)
|
containerCount := len(containers)
|
||||||
|
|
||||||
// FIXME: GetParent() panics
|
|
||||||
// parent, err := l.GetParent(context.TODO())
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, errors.Wrapf(err, "failed to obtain ParentID for image %s", l.ID())
|
|
||||||
// }
|
|
||||||
|
|
||||||
labels, err := l.Labels(context.TODO())
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "failed to obtain Labels for image %s", l.ID())
|
|
||||||
}
|
|
||||||
|
|
||||||
size, err := l.Size(context.TODO())
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "failed to obtain Size for image %s", l.ID())
|
|
||||||
}
|
|
||||||
|
|
||||||
repoTags, err := l.RepoTags()
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "failed to obtain RepoTags for image %s", l.ID())
|
|
||||||
}
|
|
||||||
|
|
||||||
digests := make([]string, len(l.Digests()))
|
|
||||||
for i, d := range l.Digests() {
|
|
||||||
digests[i] = string(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
is := entities.ImageSummary{
|
is := entities.ImageSummary{
|
||||||
ID: l.ID(),
|
ID: l.ID(),
|
||||||
ParentId: l.Parent,
|
ParentId: imageData.Parent,
|
||||||
RepoTags: repoTags,
|
RepoTags: imageData.RepoTags,
|
||||||
RepoDigests: digests,
|
RepoDigests: imageData.RepoDigests,
|
||||||
Created: l.Created().Unix(),
|
Created: l.Created().Unix(),
|
||||||
Size: int64(*size),
|
Size: imageData.Size,
|
||||||
SharedSize: 0,
|
SharedSize: 0,
|
||||||
VirtualSize: l.VirtualSize,
|
VirtualSize: imageData.VirtualSize,
|
||||||
Labels: labels,
|
Labels: imageData.Labels,
|
||||||
Containers: containerCount,
|
Containers: containerCount,
|
||||||
ReadOnly: l.IsReadOnly(),
|
ReadOnly: l.IsReadOnly(),
|
||||||
Dangling: l.Dangling(),
|
Dangling: l.Dangling(),
|
||||||
Names: l.Names(),
|
Names: l.Names(),
|
||||||
Digest: string(l.Digest()),
|
Digest: string(imageData.Digest),
|
||||||
ConfigDigest: string(l.ConfigDigest),
|
ConfigDigest: string(l.ConfigDigest),
|
||||||
History: l.NamesHistory(),
|
History: imageData.NamesHistory,
|
||||||
}
|
}
|
||||||
return &is, nil
|
return &is, nil
|
||||||
}
|
}
|
||||||
|
@ -283,8 +262,8 @@ func ImageDataToImageInspect(ctx context.Context, l *libpodImage.Image) (*ImageI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dockerImageInspect := docker.ImageInspect{
|
dockerImageInspect := docker.ImageInspect{
|
||||||
Architecture: l.Architecture,
|
Architecture: info.Architecture,
|
||||||
Author: l.Author,
|
Author: info.Author,
|
||||||
Comment: info.Comment,
|
Comment: info.Comment,
|
||||||
Config: &config,
|
Config: &config,
|
||||||
Created: l.Created().Format(time.RFC3339Nano),
|
Created: l.Created().Format(time.RFC3339Nano),
|
||||||
|
@ -292,9 +271,9 @@ func ImageDataToImageInspect(ctx context.Context, l *libpodImage.Image) (*ImageI
|
||||||
GraphDriver: docker.GraphDriverData{},
|
GraphDriver: docker.GraphDriverData{},
|
||||||
ID: fmt.Sprintf("sha256:%s", l.ID()),
|
ID: fmt.Sprintf("sha256:%s", l.ID()),
|
||||||
Metadata: docker.ImageMetadata{},
|
Metadata: docker.ImageMetadata{},
|
||||||
Os: l.Os,
|
Os: info.Os,
|
||||||
OsVersion: l.Version,
|
OsVersion: info.Version,
|
||||||
Parent: l.Parent,
|
Parent: info.Parent,
|
||||||
RepoDigests: info.RepoDigests,
|
RepoDigests: info.RepoDigests,
|
||||||
RepoTags: info.RepoTags,
|
RepoTags: info.RepoTags,
|
||||||
RootFS: rootfs,
|
RootFS: rootfs,
|
||||||
|
|
|
@ -38,10 +38,8 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions)
|
||||||
RepoDigests: digests,
|
RepoDigests: digests,
|
||||||
History: img.NamesHistory(),
|
History: img.NamesHistory(),
|
||||||
Names: img.Names(),
|
Names: img.Names(),
|
||||||
ParentId: img.Parent,
|
|
||||||
ReadOnly: img.IsReadOnly(),
|
ReadOnly: img.IsReadOnly(),
|
||||||
SharedSize: 0,
|
SharedSize: 0,
|
||||||
VirtualSize: img.VirtualSize,
|
|
||||||
RepoTags: img.Names(), // may include tags and digests
|
RepoTags: img.Names(), // may include tags and digests
|
||||||
}
|
}
|
||||||
e.Labels, err = img.Labels(ctx)
|
e.Labels, err = img.Labels(ctx)
|
||||||
|
@ -60,6 +58,15 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions)
|
||||||
return nil, errors.Wrapf(err, "error retrieving size of image %q: you may need to remove the image to resolve the error", img.ID())
|
return nil, errors.Wrapf(err, "error retrieving size of image %q: you may need to remove the image to resolve the error", img.ID())
|
||||||
}
|
}
|
||||||
e.Size = int64(*sz)
|
e.Size = int64(*sz)
|
||||||
|
// This is good enough for now, but has to be
|
||||||
|
// replaced later with correct calculation logic
|
||||||
|
e.VirtualSize = int64(*sz)
|
||||||
|
|
||||||
|
parent, err := img.ParentID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "error retrieving parent of image %q: you may need to remove the image to resolve the error", img.ID())
|
||||||
|
}
|
||||||
|
e.ParentId = parent
|
||||||
|
|
||||||
summaries = append(summaries, &e)
|
summaries = append(summaries, &e)
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ RUN printenv http_proxy`
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
// Verify that OS and Arch are being set
|
// Verify that OS and Arch are being set
|
||||||
inspect := podmanTest.PodmanNoCache([]string{"image", "inspect", "--format", "{{ index .Config.Labels }}", "test"})
|
inspect := podmanTest.Podman([]string{"image", "inspect", "--format", "{{ index .Config.Labels }}", "test"})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
data := inspect.OutputToString()
|
data := inspect.OutputToString()
|
||||||
Expect(data).To(ContainSubstring(buildah.Version))
|
Expect(data).To(ContainSubstring(buildah.Version))
|
||||||
|
|
Loading…
Reference in a new issue