Skip to content

Add index annotation support#306

Open
TIR44 wants to merge 1 commit into
buildpacks:mainfrom
TIR44:feature/index-annotations
Open

Add index annotation support#306
TIR44 wants to merge 1 commit into
buildpacks:mainfrom
TIR44:feature/index-annotations

Conversation

@TIR44

@TIR44 TIR44 commented May 31, 2026

Copy link
Copy Markdown

Summary

  • added ImageIndex.SetIndexAnnotations for top-level index annotations
  • applied index annotations through go-containerregistry's index annotation mutation
  • preserved top-level annotations when SaveDir() rewrites the local index.json
  • updated the fake ImageIndex
  • added unit coverage for OCI and Docker manifest list index annotations, no-annotation saves, and merge/update behavior for existing index annotation keys

Context

This is the imgutil prerequisite for buildpacks/pack#2586. The pack-side manifest annotate --index flow needs an imgutil API that can write annotations to the index manifest itself, not only to a manifest descriptor inside the index.

Tests

  • go test . -run TestCNBIndexSetIndexAnnotations -count=1
  • go test . -run 'TestCNBIndex(SetIndexAnnotations|SaveDirWithoutIndexAnnotations)' -count=1
  • go test . -count=1
  • go test ./... -run '^$' -count=1
  • make format

GitHub checks passed on the latest commit (6ad67aa): DCO, Linux, Linux containerd, Windows, Codecov patch, and Codecov project.

Local Docker-dependent tests could not be run because this machine has no Docker socket at /var/run/docker.sock:

  • go test ./layout -run TestLayoutIndex -count=1
  • go test ./fakes -count=1

@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.36%. Comparing base (c36b3eb) to head (6ad67aa).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #306      +/-   ##
==========================================
+ Coverage   34.66%   36.36%   +1.70%     
==========================================
  Files          39       39              
  Lines        3359     3378      +19     
==========================================
+ Hits         1164     1228      +64     
+ Misses       2000     1943      -57     
- Partials      195      207      +12     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TIR44
TIR44 marked this pull request as ready for review May 31, 2026 11:13
@TIR44
TIR44 requested a review from a team as a code owner May 31, 2026 11:13
@TIR44
TIR44 force-pushed the feature/index-annotations branch from 516e22c to 9a31ed1 Compare May 31, 2026 11:17
Signed-off-by: TiR <70480807+TIR44@users.noreply.github.com>
@TIR44
TIR44 force-pushed the feature/index-annotations branch from 9a31ed1 to 6ad67aa Compare May 31, 2026 11:38
Comment thread cnb_index.go
return err
}

index, err := imageIndex.IndexManifest()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we are re-reading IndexManifest when the only caller is SaveDir which already has pulled it?

Comment thread cnb_index.go
})
}

func (h *CNBIndex) SetIndexAnnotations(annotations map[string]string) (err error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more of a merge than a set. Maybe change the name to match the tests?

Comment thread cnb_index.go
})
}

func (h *CNBIndex) SetIndexAnnotations(annotations map[string]string) (err error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: new methods should have doc comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants