Skip to content

flatten: preserve config and layer media types when flattening - #2438

Merged
Subserial merged 1 commit into
google:mainfrom
Subserial:image-type
Sep 2, 2026
Merged

Subserial merged 1 commit into
google:mainfrom
Subserial:image-type

Conversation

@Subserial

@Subserial Subserial commented Sep 2, 2026 •

Copy link
Copy Markdown

Fixes #2433

#2267 introduced preserving the manifest media type, but was overridden by the default image type of empty.Image. As a result, flattening an OCI image produced a mixed manifest, e.g.:

  • Manifest mediaType: application/vnd.oci.image.manifest.v1+json (OCI)
  • Config mediaType: application/vnd.docker.container.image.v1+json (Docker)
  • Layer mediaType: application/vnd.docker.image.rootfs.diff.tar.gzip (Docker)

Changes

  • Preserve layer media type and config media type for OCI manifests (via stream.WithMediaType)
  • Expand TestFlattenImagePreservesMediaType to assert that m.Config.MediaType and m.Layers[0].MediaType match the expected media type family.
  • Add TestFlattenIndexPreservesMediaType to verify that flattening an OCI index does not emit Docker artifact types on index descriptors and preserves child image media types.

Verification

go test -v ./...

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.17391% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.62%. Comparing base (79af990) to head (4702dbf).

Files with missing lines Patch % Lines
cmd/crane/cmd/flatten.go 52.17% 7 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2438      +/-   ##
==========================================
+ Coverage   59.48%   59.62%   +0.14%     
==========================================
  Files         167      167              
  Lines       11619    11637      +18     
==========================================
+ Hits         6911     6939      +28     
+ Misses       3836     3812      -24     
- Partials      872      886      +14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Subserial
Subserial merged commit 25c682e into google:main Sep 2, 2026
19 checks passed
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
crane 0.22.1

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed
* Reject non-canonical IP literals in all SSRF guards by @shaggyinsomniac in google/go-containerregistry#2426
* daemon: fix stale docker/docker reference in WithClient docs by @BobDu in google/go-containerregistry#2428
* build(deps): bump the go-deps group across 2 directories with 4 updates by @dependabot[bot] in google/go-containerregistry#2422
* authn: do not overwrite AuthConfig.Auth when username and password are empty by @nileshpatil6 in google/go-containerregistry#2420
* build(deps): bump the actions group across 1 directory with 8 updates by @dependabot[bot] in google/go-containerregistry#2423
* Support pulling images by sha512 digest by @BobDu in google/go-containerregistry#2427
* Allow empty label and annotation values in crane mutate by @theadsingh in google/go-containerregistry#2418
* fix(build): Use dependencies.gitSource in cloudbuild_v2.yaml by @tprussak in google/go-containerregistry#2434
* validate: support index attestation manifests and empty configs by @Subserial in google/go-containerregistry#2414
* name: improve error when parsing a reference with a URL scheme by @locker95 in google/go-containerregistry#2431
* fix(build): install binaries to /ko-app and add to PATH (#2424) by @tprussak in google/go-containerregistry#2436
* fix(release): honor declared Go toolchain by @rksharma-owg in google/go-containerregistry#2435
* remote: apply checkRedirectSSRF to writer-side HTTP clients by @locker95 in google/go-containerregistry#2432
* flatten: preserve config and layer media types when flattening by @Subserial in google/go-containerregistry#2438
* fix(mutate): make Time layer updates lazy by @amarkdotdev in google/go-containerregistry#2429
* build(deps): bump the go-deps group across 2 directories with 3 updates by @dependabot[bot] in google/go-containerregistry#2439
* remote: copy manifest annotations to referrers fallback tag descriptors by @codysoyland in google/go-containerregistry#2441

## New Contributors
* @shaggyinsomniac made their first contribution in google/go-containerregistry#2426
* @BobDu made their first contribution in google/go-containerregistry#2428
* @nileshpatil6 made their first contribution in google/go-containerregistry#2420
* @theadsingh made their first contribution in google/go-containerregistry#2418
* @locker95 made their first contribution in google/go-containerregistry#2431
* @rksharma-owg made their first contribution in google/go-containerregistry#2435
* @codysoyland made their first contribution in google/go-containerregistry#2441

**Full Changelog**: https://github.com/google/go-containerregistry/compare/v0.22.0...v0.22.1</pre>
  <p>View the full release notes at <a href="https://github.com/google/go-containerregistry/releases/tag/v0.22.1">https://github.com/google/go-containerregistry/releases/tag/v0.22.1</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!18250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crane: flatten creates an index image with mixed OCI and docker mediatypes

3 participants