sigstore / cosign

Code signing and transparency for containers and binaries
Apache License 2.0
4.4k stars 541 forks source link

Make config layers in ociremote mountable #3741

Closed jonjohnsonjr closed 3 months ago

jonjohnsonjr commented 3 months ago

The wrapping that oci.Signatures does hides the ConfigLayer() implementation in remote.Image that remote.Write relies on for determining if it can mount the config blob (vs having to re-upload it), so remote.Write is sending additional blob uploads, which incurs an additional roundtrip that we don't really need to do.

Explicitly implement ConfigLayer() in the wrappers by dispatching to the wrapped implementation fixes this.

Before this change, this check fails due to the wrapping:

https://github.com/google/go-containerregistry/blob/1b4e4078a545f2b6f96766a064b45ee77cdbefdd/pkg/v1/partial/with.go#L102-L104

Which means we get back this fallback implementation: https://github.com/google/go-containerregistry/blob/1b4e4078a545f2b6f96766a064b45ee77cdbefdd/pkg/v1/partial/with.go#L52-L88

Which means this check fails: https://github.com/google/go-containerregistry/blob/1b4e4078a545f2b6f96766a064b45ee77cdbefdd/pkg/v1/remote/write.go#L364

So we didn't attempt to mount.

https://go.dev/play/p/2kW3-XbdjmM

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 40.63%. Comparing base (2ef6022) to head (9432efd). Report is 132 commits behind head on main.

Files Patch % Lines
pkg/oci/remote/image.go 0.00% 2 Missing :warning:
pkg/oci/remote/signatures.go 0.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3741 +/- ## ========================================== + Coverage 40.10% 40.63% +0.52% ========================================== Files 155 158 +3 Lines 10044 10179 +135 ========================================== + Hits 4028 4136 +108 - Misses 5530 5543 +13 - Partials 486 500 +14 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.