Skip to content

Commit

Permalink
oci: Refine storing manifests in index.json.
Browse files Browse the repository at this point in the history
Before this commit, all untagged manifests were stored in index.json.
Now, we only store manifests which are not tagged and which predecessors are not
tagged.

Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
  • Loading branch information
eiffel-fl committed Jan 8, 2024
1 parent 0b78aa6 commit 732d87d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions content/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,23 @@ func (s *Store) saveIndex() error {
tagged.Add(desc.Digest)
}
}
// 2. Add descriptors that are not associated with any tag
// 2. Add descriptors that are not associated with any tag.
// We only add descriptors which are not tagged and which do not have a tagged
// predecessors.
outer:
for ref, desc := range refMap {
if ref == desc.Digest.String() && !tagged.Contains(desc.Digest) {
// skip tagged ones since they have been added in step 1
predecessors, err := s.graph.Predecessors(nil, desc)
if err != nil {
continue
}

for _, predecessor := range predecessors {
if tagged.Contains(predecessor.Digest){
continue outer
}
}

manifests = append(manifests, deleteAnnotationRefName(desc))
}
}
Expand Down

0 comments on commit 732d87d

Please sign in to comment.