mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 10:03:42 +08:00 
			
		
		
		
	Merge pull request #2230 from jedevc/imagetools-resolver-copy-dupe
fix: avoid modifying source during resolver.Copy
This commit is contained in:
		@@ -4,6 +4,7 @@ import (
 | 
				
			|||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"maps"
 | 
				
			||||||
	"net/url"
 | 
						"net/url"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -230,13 +231,17 @@ func (r *Resolver) Copy(ctx context.Context, src *Source, dest reference.Named)
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	source, repo := u.Hostname(), strings.TrimPrefix(u.Path, "/")
 | 
					 | 
				
			||||||
	if src.Desc.Annotations == nil {
 | 
					 | 
				
			||||||
		src.Desc.Annotations = make(map[string]string)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	src.Desc.Annotations["containerd.io/distribution.source."+source] = repo
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = contentutil.CopyChain(ctx, contentutil.FromPusher(p), contentutil.FromFetcher(f), src.Desc)
 | 
						desc := src.Desc
 | 
				
			||||||
 | 
						desc.Annotations = maps.Clone(desc.Annotations)
 | 
				
			||||||
 | 
						if desc.Annotations == nil {
 | 
				
			||||||
 | 
							desc.Annotations = make(map[string]string)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						source, repo := u.Hostname(), strings.TrimPrefix(u.Path, "/")
 | 
				
			||||||
 | 
						desc.Annotations["containerd.io/distribution.source."+source] = repo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						err = contentutil.CopyChain(ctx, contentutil.FromPusher(p), contentutil.FromFetcher(f), desc)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user