Skip to content

Commit

Permalink
remotes: FetchByDigest: propagate media type from config to desc
Browse files Browse the repository at this point in the history
A media type string passed via `WithMediaType()` was not propagated
to a descriptor returned by `FetchByDigest()`.

Follow-up to PR 8744

Signed-off-by: Akihiro Suda <[email protected]>
  • Loading branch information
AkihiroSuda committed Jan 18, 2024
1 parent 02e0fef commit e9f2bba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/ctr/commands/content/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,11 @@ var (
if err != nil {
return err
}
rc, _, err := fetcherByDigest.FetchByDigest(ctx, dgst, remotes.WithMediaType(context.String("media-type")))
rc, desc, err := fetcherByDigest.FetchByDigest(ctx, dgst, remotes.WithMediaType(context.String("media-type")))
if err != nil {
return err
}
log.G(ctx).Debugf("desc=%+v", desc)
_, err = io.Copy(os.Stdout, rc)
rc.Close()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions core/remotes/docker/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ func (r dockerFetcher) FetchByDigest(ctx context.Context, dgst digest.Digest, op
Digest: dgst,
Size: sz,
}
if config.Mediatype != "" {
desc.MediaType = config.Mediatype
}
return seeker, desc, nil
}

Expand Down

0 comments on commit e9f2bba

Please sign in to comment.