Skip to content

Commit 402339e

Browse files
authored
Add a com.apple.containerization.index.indirect annotation to distinguish synthesized index (#198)
In general I believe it's clever to synthesize an index for single-platform image manifest, but we still need a way to distinguish it. Add a dedicated annotation is the slightest change I've come up with, and it's also OCI compliant. With this change come in, we can work around apple/container#212 and imitate the behavior of other runtime with `container`. Note that since `cctl` is meant to be a dedicated tool for inspecting the Containerization framework itself, I didn't apply the indirection for it, and it will be as-is with the genuine storage.
1 parent 41d41e4 commit 402339e

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

Sources/Containerization/Image/ImageStore/ImageStore+Import.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ extension ImageStore {
211211
let platform = supportedPlatforms.first!
212212
var root = root
213213
root.platform = platform
214-
let index = ContainerizationOCI.Index(schemaVersion: 2, manifests: [root])
214+
let index = ContainerizationOCI.Index(
215+
schemaVersion: 2, manifests: [root],
216+
annotations: [
217+
// indicate that this is a synthesized index which is not directly user facing
218+
AnnotationKeys.containerizationIndexIndirect: "true"
219+
])
215220
return index
216221
default:
217222
throw ContainerizationError(.internalError, message: "Failed to create index for descriptor \(root.digest), media type \(root.mediaType)")

Sources/ContainerizationOCI/AnnotationKeys.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/// AnnotationKeys contains a subset of "dictionary keys" for commonly used annotations in an OCI Image Descriptor
1818
/// https://github.com/opencontainers/image-spec/blob/main/annotations.md
1919
public struct AnnotationKeys: Codable, Sendable {
20+
public static let containerizationIndexIndirect = "com.apple.containerization.index.indirect"
2021
public static let containerizationImageName = "com.apple.containerization.image.name"
2122
public static let containerdImageName = "io.containerd.image.name"
2223
public static let openContainersImageName = "org.opencontainers.image.ref.name"

0 commit comments

Comments
 (0)