Skip to content

Commit

Permalink
fix: support fetching manifest in oci image layout (oras-project#766)
Browse files Browse the repository at this point in the history
Resolves oras-project#764

Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah authored and Terry Howe committed Feb 2, 2023
1 parent a8761cd commit b00239f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/oras/manifest/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package manifest
import (
"encoding/json"
"errors"
"fmt"
"os"

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
Expand Down Expand Up @@ -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 == "-" {
Expand Down

0 comments on commit b00239f

Please sign in to comment.