Encode os.version and os.features with OCI spec keys - #923
Open
rishabhsai wants to merge 1 commit into
Open
rishabhsai wants to merge 1 commit into
rishabhsai wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PlatformdeclaresosVersionandosFeatures, but itsCodingKeysonly listsos,architectureandvariant, so both fields are dropped on decode and never encoded.Imagedeclares the same two fields with noCodingKeysat all, so it decodes nothing for them and writes them out asosVersionandosFeatures. The OCI image spec names these keysos.versionandos.features: specs-go/v1/descriptor.go tagsOSVersionwithjson:"os.version,omitempty"andOSFeatureswithjson:"os.features,omitempty", and config.go embedsPlatforminImage, so the config uses the same two keys. Any image that sets them loses that metadata the moment it is parsed. ImageStore+Import.swift:246 builds aPlatformfromconfig.osFeaturesand always gets nil, and an index re-encoded on export or push comes back missingos.version, which is what containerd and docker match manifests on.This adds the two spec keys to
Platform.CodingKeyswith the matching encode and decode calls, givesImagean explicitCodingKeys, and leaves the Swift property names, equality and hashing unchanged. Two round-trip tests in OCIImageTests decode JSON containingos.versionandos.featuresforPlatformandImage, assert the values, then re-encode and assert the spec key names appear. Reverting the two source files makes both fail on the decoded values being nil; with the fix in placeswift test --filter OCITestspasses all 127 tests.One compatibility note:
Imagehad noCodingKeysbefore, so JSON written by earlier versions of this package withosVersionorosFeaturesset will now read those two fields as nil, which is what the spec-keyed fields already read as before this change. No such JSON is produced in this repo's tests, and registries and containerd only ever emit the spec keys.