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: improve oras manifest fetch --platform error message #330

Merged
merged 2 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ func TestCopy_WithTargetPlatformOptions(t *testing.T) {
}

_, err = oras.Copy(ctx, src, ref, dst, "", opts)
expected = fmt.Sprintf("mismatch MediaType %s: expect %s", docker.MediaTypeConfig, ocispec.MediaTypeImageConfig)
expected = fmt.Sprintf("fail to recognize media type %s: expect %s", docker.MediaTypeConfig, ocispec.MediaTypeImageConfig)
if err.Error() != expected {
t.Fatalf("Copy() error = %v, wantErr %v", err, expected)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func SelectManifest(ctx context.Context, src content.ReadOnlyStorage, root ocisp
// fields in config blob.
func getPlatformFromConfig(ctx context.Context, src content.ReadOnlyStorage, desc ocispec.Descriptor, targetConfigMediaType string) (*ocispec.Platform, error) {
if desc.MediaType != targetConfigMediaType {
return nil, fmt.Errorf("mismatch MediaType %s: expect %s", desc.MediaType, targetConfigMediaType)
return nil, fmt.Errorf("fail to recognize media type %s: expect %s", desc.MediaType, targetConfigMediaType)
lizMSFT marked this conversation as resolved.
Show resolved Hide resolved
}

rc, err := src.Fetch(ctx, desc)
Expand Down
2 changes: 1 addition & 1 deletion internal/platform/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func TestSelectManifest(t *testing.T) {
OS: os_1,
}
_, err = SelectManifest(ctx, storage, root, &targetPlatform)
expected = fmt.Sprintf("mismatch MediaType %s: expect %s", docker.MediaTypeConfig, ocispec.MediaTypeImageConfig)
expected = fmt.Sprintf("fail to recognize media type %s: expect %s", docker.MediaTypeConfig, ocispec.MediaTypeImageConfig)
if err.Error() != expected {
t.Fatalf("SelectManifest() error = %v, wantErr %v", err, expected)
}
Expand Down