Skip to content

Commit

Permalink
fix: improve oras manifest fetch --platform error message
Browse files Browse the repository at this point in the history
Signed-off-by: Zoey Li <zoeyli@microsoft.com>
  • Loading branch information
lizMSFT committed Sep 22, 2022
1 parent 8ad5a24 commit cb89654
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
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)
}

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

0 comments on commit cb89654

Please sign in to comment.