From 89e7b8f22bec9b6f298eeca8ea7bbc9bc6b32c1d Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Thu, 22 Oct 2020 17:07:03 +0200 Subject: fix: /image/{name}/json returns RootFS layers Signed-off-by: Matej Vasek --- pkg/api/handlers/types.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go index 70466f01b..0851f48de 100644 --- a/pkg/api/handlers/types.go +++ b/pkg/api/handlers/types.go @@ -271,6 +271,13 @@ func ImageDataToImageInspect(ctx context.Context, l *libpodImage.Image) (*ImageI if err != nil { return nil, err } + + rootfs := docker.RootFS{} + rootfs.Type = info.RootFS.Type + rootfs.Layers = make([]string, 0, len(info.RootFS.Layers)) + for _, layer := range info.RootFS.Layers { + rootfs.Layers = append(rootfs.Layers, string(layer)) + } dockerImageInspect := docker.ImageInspect{ Architecture: l.Architecture, Author: l.Author, @@ -286,7 +293,7 @@ func ImageDataToImageInspect(ctx context.Context, l *libpodImage.Image) (*ImageI Parent: l.Parent, RepoDigests: info.RepoDigests, RepoTags: info.RepoTags, - RootFS: docker.RootFS{}, + RootFS: rootfs, Size: info.Size, Variant: "", VirtualSize: info.VirtualSize, -- cgit v1.2.3-54-g00ecf From 5098048f82118d3371ac4bdc2497cc5f22957914 Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Thu, 22 Oct 2020 18:25:57 +0200 Subject: src: add nil checks Signed-off-by: Matej Vasek --- pkg/api/handlers/types.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'pkg') diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go index 0851f48de..b0a177e65 100644 --- a/pkg/api/handlers/types.go +++ b/pkg/api/handlers/types.go @@ -273,10 +273,12 @@ func ImageDataToImageInspect(ctx context.Context, l *libpodImage.Image) (*ImageI } rootfs := docker.RootFS{} - rootfs.Type = info.RootFS.Type - rootfs.Layers = make([]string, 0, len(info.RootFS.Layers)) - for _, layer := range info.RootFS.Layers { - rootfs.Layers = append(rootfs.Layers, string(layer)) + if info.RootFS != nil && info.RootFS.Layers != nil { + rootfs.Type = info.RootFS.Type + rootfs.Layers = make([]string, 0, len(info.RootFS.Layers)) + for _, layer := range info.RootFS.Layers { + rootfs.Layers = append(rootfs.Layers, string(layer)) + } } dockerImageInspect := docker.ImageInspect{ Architecture: l.Architecture, -- cgit v1.2.3-54-g00ecf From a997b59e44d9b2648da2236220779f655b2f14e9 Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Thu, 22 Oct 2020 20:02:21 +0200 Subject: src: nil check Signed-off-by: Matej Vasek --- pkg/api/handlers/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go index b0a177e65..6bb5f5101 100644 --- a/pkg/api/handlers/types.go +++ b/pkg/api/handlers/types.go @@ -273,7 +273,7 @@ func ImageDataToImageInspect(ctx context.Context, l *libpodImage.Image) (*ImageI } rootfs := docker.RootFS{} - if info.RootFS != nil && info.RootFS.Layers != nil { + if info.RootFS != nil { rootfs.Type = info.RootFS.Type rootfs.Layers = make([]string, 0, len(info.RootFS.Layers)) for _, layer := range info.RootFS.Layers { -- cgit v1.2.3-54-g00ecf