Skip to content

Commit 95bdecc

Browse files
committed
fix: avoid modifying source during resolver.Copy
Signed-off-by: Justin Chadwell <[email protected]>
1 parent 082d5d7 commit 95bdecc

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

util/imagetools/create.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"encoding/json"
7+
"maps"
78
"net/url"
89
"strings"
910

@@ -230,13 +231,17 @@ func (r *Resolver) Copy(ctx context.Context, src *Source, dest reference.Named)
230231
if err != nil {
231232
return err
232233
}
233-
source, repo := u.Hostname(), strings.TrimPrefix(u.Path, "/")
234-
if src.Desc.Annotations == nil {
235-
src.Desc.Annotations = make(map[string]string)
234+
235+
desc := src.Desc
236+
desc.Annotations = maps.Clone(desc.Annotations)
237+
if desc.Annotations == nil {
238+
desc.Annotations = make(map[string]string)
236239
}
237-
src.Desc.Annotations["containerd.io/distribution.source."+source] = repo
238240

239-
err = contentutil.CopyChain(ctx, contentutil.FromPusher(p), contentutil.FromFetcher(f), src.Desc)
241+
source, repo := u.Hostname(), strings.TrimPrefix(u.Path, "/")
242+
desc.Annotations["containerd.io/distribution.source."+source] = repo
243+
244+
err = contentutil.CopyChain(ctx, contentutil.FromPusher(p), contentutil.FromFetcher(f), desc)
240245
if err != nil {
241246
return err
242247
}

0 commit comments

Comments
 (0)