From e9f2bba1f20c60eb0aa124cc30fec783a8c9900c Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Sun, 30 Jul 2023 16:46:00 +0900 Subject: [PATCH] remotes: FetchByDigest: propagate media type from config to desc 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 --- cmd/ctr/commands/content/content.go | 3 ++- core/remotes/docker/fetcher.go | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/ctr/commands/content/content.go b/cmd/ctr/commands/content/content.go index a06c5a4b6560..33dbf4a8cb36 100644 --- a/cmd/ctr/commands/content/content.go +++ b/cmd/ctr/commands/content/content.go @@ -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 { diff --git a/core/remotes/docker/fetcher.go b/core/remotes/docker/fetcher.go index 998d5b91230a..1f1eb2496418 100644 --- a/core/remotes/docker/fetcher.go +++ b/core/remotes/docker/fetcher.go @@ -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 }