Files
container/Sources
Mark Baseggio d7814e4421 Make Index.mediaType optional to comply with OCI spec (#368)
The `mediaType` field in the `Index` struct was defined as a required
field, but according to the [OCI Image Index
Specification](https://github.com/opencontainers/image-spec/blob/main/image-index.md),
this field is optional.

This caused failures when loading OCI archives where the `index.json`
omits the top-level `mediaType` field, which is valid per the spec.
Tools like skopeo can generate such archives.

## Error before fix
```
keyNotFound(CodingKeys(stringValue: "mediaType", intValue: nil))
```

## Changes
- Changed `Index.mediaType` from `String` to `String?`
- Updated initializer to accept optional `mediaType` parameter
- Added comment documenting that field is optional per OCI spec

## Testing
Verified that OCI archives without a top-level `mediaType` field in
`index.json` now load successfully.

Fixes https://github.com/apple/container/issues/330
2025-10-29 01:46:16 -07:00
..