Skip to content

Commit f0a9c59

Browse files
authored
feat: support Image Index with a subject (#548)
Resolves: #531 Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
1 parent babfc51 commit f0a9c59

File tree

7 files changed

+848
-46
lines changed

7 files changed

+848
-46
lines changed

content/graph.go

+17-2
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,33 @@ func Successors(ctx context.Context, fetcher Fetcher, node ocispec.Descriptor) (
7575
}
7676
nodes = append(nodes, manifest.Config)
7777
return append(nodes, manifest.Layers...), nil
78-
case docker.MediaTypeManifestList, ocispec.MediaTypeImageIndex:
78+
case docker.MediaTypeManifestList:
7979
content, err := FetchAll(ctx, fetcher, node)
8080
if err != nil {
8181
return nil, err
8282
}
8383

84-
// docker manifest list and oci index are equivalent for successors.
84+
// OCI manifest index schema can be used to marshal docker manifest list
8585
var index ocispec.Index
8686
if err := json.Unmarshal(content, &index); err != nil {
8787
return nil, err
8888
}
8989
return index.Manifests, nil
90+
case ocispec.MediaTypeImageIndex:
91+
content, err := FetchAll(ctx, fetcher, node)
92+
if err != nil {
93+
return nil, err
94+
}
95+
96+
var index ocispec.Index
97+
if err := json.Unmarshal(content, &index); err != nil {
98+
return nil, err
99+
}
100+
var nodes []ocispec.Descriptor
101+
if index.Subject != nil {
102+
nodes = append(nodes, *index.Subject)
103+
}
104+
return append(nodes, index.Manifests...), nil
90105
case spec.MediaTypeArtifactManifest:
91106
content, err := FetchAll(ctx, fetcher, node)
92107
if err != nil {

0 commit comments

Comments
 (0)