mirror of
https://github.com/containers/skopeo.git
synced 2025-08-11 11:22:05 +00:00
inspect --raw: skip the NewImage() step
Skip the NewImage() step if we're just inspecting the raw manifest, so that if the tag or digest being inspected resolves to a manifest list, the local arch/OS combination doesn't need to be found in it to avoid an error. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
parent
1e2d6f619b
commit
43b014c82a
@ -8,6 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/image/docker"
|
"github.com/containers/image/docker"
|
||||||
|
"github.com/containers/image/image"
|
||||||
"github.com/containers/image/manifest"
|
"github.com/containers/image/manifest"
|
||||||
"github.com/containers/image/transports"
|
"github.com/containers/image/transports"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
@ -86,21 +87,40 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
img, err := parseImage(ctx, opts.image, imageName)
|
sys, err := opts.image.newSystemContext()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
src, err := parseImageSource(ctx, opts.image, imageName)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error parsing image name %q: %v", imageName, err)
|
||||||
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := img.Close(); err != nil {
|
if err := src.Close(); err != nil {
|
||||||
retErr = errors.Wrapf(retErr, fmt.Sprintf("(could not close image: %v) ", err))
|
retErr = errors.Wrapf(retErr, fmt.Sprintf("(could not close image: %v) ", err))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
rawManifest, _, err := img.Manifest(ctx)
|
rawManifest, _, err := src.GetManifest(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("Error retrieving manifest for image: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opts.raw && !opts.config {
|
||||||
|
_, err := stdout.Write(rawManifest)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error writing manifest to standard output: %v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
img, err := image.FromUnparsedImage(ctx, sys, image.UnparsedInstance(src, nil))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error parsing manifest for image: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
if opts.config && opts.raw {
|
if opts.config && opts.raw {
|
||||||
configBlob, err := img.ConfigBlob(ctx)
|
configBlob, err := img.ConfigBlob(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -111,12 +131,6 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
|
|||||||
return fmt.Errorf("Error writing configuration blob to standard output: %v", err)
|
return fmt.Errorf("Error writing configuration blob to standard output: %v", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
} else if opts.raw {
|
|
||||||
_, err := stdout.Write(rawManifest)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Error writing manifest to standard output: %v", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
} else if opts.config {
|
} else if opts.config {
|
||||||
config, err := img.OCIConfig(ctx)
|
config, err := img.OCIConfig(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -128,6 +142,7 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
imgInspect, err := img.Inspect(ctx)
|
imgInspect, err := img.Inspect(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user