Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manifest list inspect single image #8100

Merged
merged 1 commit into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions pkg/domain/infra/abi/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/opencontainers/go-digest"
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"

"github.com/pkg/errors"
)
Expand Down Expand Up @@ -90,18 +91,25 @@ func (ir *ImageEngine) ManifestInspect(ctx context.Context, name string) ([]byte
continue
}

if !manifest.MIMETypeIsMultiImage(manifestType) {
appendErr(errors.Errorf("manifest is of type %s (not a list type)", manifestType))
continue
}
result = manifestBytes
manType = manifestType
break
}
if len(result) == 0 && latestErr != nil {
return nil, latestErr
}
if manType != manifest.DockerV2ListMediaType {

switch manType {
case manifest.DockerV2Schema2MediaType:
logrus.Warnf("Warning! The manifest type %s is not a manifest list but a single image.", manType)
schema2Manifest, err := manifest.Schema2FromManifest(result)
if err != nil {
return nil, errors.Wrapf(err, "error parsing manifest blob %q as a %q", string(result), manType)
}
if result, err = schema2Manifest.Serialize(); err != nil {
return nil, err
}
default:
vrothberg marked this conversation as resolved.
Show resolved Hide resolved
listBlob, err := manifest.ListFromBlob(result, manType)
if err != nil {
return nil, errors.Wrapf(err, "error parsing manifest blob %q as a %q", string(result), manType)
Expand All @@ -113,10 +121,9 @@ func (ir *ImageEngine) ManifestInspect(ctx context.Context, name string) ([]byte
if result, err = list.Serialize(); err != nil {
return nil, err
}

}
err = json.Indent(&b, result, "", " ")
if err != nil {

if err = json.Indent(&b, result, "", " "); err != nil {
return nil, errors.Wrapf(err, "error rendering manifest %s for display", name)
}
return b.Bytes(), nil
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ var _ = Describe("Podman manifest", func() {
session = podmanTest.PodmanNoCache([]string{"manifest", "inspect", "quay.io/libpod/busybox"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

// inspect manifest of single image
session = podmanTest.PodmanNoCache([]string{"manifest", "inspect", "quay.io/libpod/busybox@sha256:6655df04a3df853b029a5fac8836035ac4fab117800c9a6c4b69341bb5306c3d"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
})

It("podman manifest add", func() {
Expand Down