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

fix: support fetching manifest in oci image layout #766

Merged
merged 2 commits into from
Jan 29, 2023
Merged
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
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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any tests that need to be updated or added that validate this functionality?

Copy link
Contributor Author

@qweeah qweeah Jan 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no test for now & indeed, E2E tests should be added to cover this.

OCI image layout support is a new feature and tests are not there yet. Let me open an issue for tracking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an issue #767, it should be done before 1.0.0 release.

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