Skip to content

Commit

Permalink
Merge pull request #8100 from QiWang19/mirror-manifest
Browse files Browse the repository at this point in the history
manifest list inspect single image
  • Loading branch information
openshift-merge-robot authored Oct 30, 2020
2 parents e5227b9 + 57650aa commit b6ab2df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
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:
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

0 comments on commit b6ab2df

Please sign in to comment.