go-containerregistry
go-containerregistry copied to clipboard
crane: mutate OCI image layout with annotations, layers etc.
Describe the bug
This is not a bug, and this is a feature.
Additional context
Recently, @sudo-bmitch talked about OCI image layout^1. He showed a demo of making file operations on the OCI image layout directory for adding new blobs, annotations, etc. crane already has the support of working with OCI image layout through a package pkg/v1/layout
available in go-containerregistry but editing the OCI image layout for such operations adding new blobs, annotations, etc. is not possible, so, we talked with @imjasonh about this, and mutate
cmd is the best place to implement this. Based on that, I've tested a sample code to make changes to OCI image layout, and it worked:
img2 := mutate.Annotations(img, annotations).(v1.Image)
err = p.ReplaceImage(img2, match.Digests(digest))
if err != nil {
return fmt.Errorf("replacing image: %w", err)
}
PTAL @Dentrax