@@ -192,6 +192,14 @@ func (s *imageStore) Update(ctx context.Context, image images.Image, fieldpaths
192192 key := strings .TrimPrefix (path , "labels." )
193193 updated .Labels [key ] = image .Labels [key ]
194194 continue
195+ } else if strings .HasPrefix (path , "annotations." ) {
196+ if updated .Target .Annotations == nil {
197+ updated .Target .Annotations = map [string ]string {}
198+ }
199+
200+ key := strings .TrimPrefix (path , "annotations." )
201+ updated .Target .Annotations [key ] = image .Target .Annotations [key ]
202+ continue
195203 }
196204
197205 switch path {
@@ -204,6 +212,8 @@ func (s *imageStore) Update(ctx context.Context, image images.Image, fieldpaths
204212 // make sense to modify the size or digest without touching the
205213 // mediatype, as well, for example.
206214 updated .Target = image .Target
215+ case "annotations" :
216+ updated .Target .Annotations = image .Target .Annotations
207217 default :
208218 return errors .Wrapf (errdefs .ErrInvalidArgument , "cannot update %q field on image %q" , path , image .Name )
209219 }
@@ -298,6 +308,11 @@ func readImage(image *images.Image, bkt *bolt.Bucket) error {
298308 }
299309 image .Labels = labels
300310
311+ image .Target .Annotations , err = boltutil .ReadAnnotations (bkt )
312+ if err != nil {
313+ return err
314+ }
315+
301316 tbkt := bkt .Bucket (bucketKeyTarget )
302317 if tbkt == nil {
303318 return errors .New ("unable to read target bucket" )
@@ -331,6 +346,10 @@ func writeImage(bkt *bolt.Bucket, image *images.Image) error {
331346 return errors .Wrapf (err , "writing labels for image %v" , image .Name )
332347 }
333348
349+ if err := boltutil .WriteAnnotations (bkt , image .Target .Annotations ); err != nil {
350+ return errors .Wrapf (err , "writing Annotations for image %v" , image .Name )
351+ }
352+
334353 // write the target bucket
335354 tbkt , err := bkt .CreateBucketIfNotExists (bucketKeyTarget )
336355 if err != nil {
0 commit comments