From 3d36225d5c295425b97c1cd06dc032b56b45fc8b Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Sun, 29 Jan 2023 11:24:04 +0800 Subject: [PATCH] fix: support fetching manifest in oci image layout (#766) Resolves #764 Signed-off-by: Billy Zha --- cmd/oras/manifest/fetch.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/oras/manifest/fetch.go b/cmd/oras/manifest/fetch.go index c37867394..135fa5b3f 100644 --- a/cmd/oras/manifest/fetch.go +++ b/cmd/oras/manifest/fetch.go @@ -18,6 +18,7 @@ package manifest import ( "encoding/json" "errors" + "fmt" "os" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -113,18 +114,18 @@ func fetchManifest(opts fetchOptions) (fetchErr error) { // fetch manifest descriptor only fetchOpts := oras.DefaultResolveOptions fetchOpts.TargetPlatform = opts.Platform.Platform - desc, err = oras.Resolve(ctx, src, opts.RawReference, fetchOpts) + desc, err = oras.Resolve(ctx, src, opts.Reference, fetchOpts) if err != nil { - return err + return fmt.Errorf("failed to find %q: %w", opts.RawReference, err) } } else { // fetch manifest content var content []byte fetchOpts := oras.DefaultFetchBytesOptions fetchOpts.TargetPlatform = opts.Platform.Platform - desc, content, err = oras.FetchBytes(ctx, src, opts.RawReference, fetchOpts) + desc, content, err = oras.FetchBytes(ctx, src, opts.Reference, fetchOpts) if err != nil { - return err + return fmt.Errorf("failed to fetch the content of %q: %w", opts.RawReference, err) } if opts.outputPath == "" || opts.outputPath == "-" {