mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-10-31 08:03:43 +08:00 
			
		
		
		
	Merge pull request #1569 from tonistiigi/v0.10.2-picks
[v0.10] cherry-picks for v0.10.2
This commit is contained in:
		| @@ -144,6 +144,9 @@ func ReadTargets(ctx context.Context, files []File, targets, overrides []string, | ||||
| 	// The logic is purposely duplicated from `build/build`.go for keeping this visible in `bake --print`. | ||||
| 	if v := os.Getenv("SOURCE_DATE_EPOCH"); v != "" { | ||||
| 		for _, f := range m { | ||||
| 			if f.Args == nil { | ||||
| 				f.Args = make(map[string]*string) | ||||
| 			} | ||||
| 			if _, ok := f.Args["SOURCE_DATE_EPOCH"]; !ok { | ||||
| 				f.Args["SOURCE_DATE_EPOCH"] = &v | ||||
| 			} | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import ( | ||||
| 	"context" | ||||
| 	"crypto/rand" | ||||
| 	_ "crypto/sha256" // ensure digests can be computed | ||||
| 	"encoding/base64" | ||||
| 	"encoding/hex" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| @@ -1157,7 +1158,24 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s | ||||
| 						descs := make([]specs.Descriptor, 0, len(res)) | ||||
|  | ||||
| 						for _, r := range res { | ||||
| 							s, ok := r.ExporterResponse[exptypes.ExporterImageDigestKey] | ||||
| 							s, ok := r.ExporterResponse[exptypes.ExporterImageDescriptorKey] | ||||
| 							if ok { | ||||
| 								dt, err := base64.StdEncoding.DecodeString(s) | ||||
| 								if err != nil { | ||||
| 									return err | ||||
| 								} | ||||
| 								var desc specs.Descriptor | ||||
| 								if err := json.Unmarshal(dt, &desc); err != nil { | ||||
| 									return errors.Wrapf(err, "failed to unmarshal descriptor %s", s) | ||||
| 								} | ||||
| 								descs = append(descs, desc) | ||||
| 								continue | ||||
| 							} | ||||
| 							// This is fallback for some very old buildkit versions. | ||||
| 							// Note that the mediatype isn't really correct as most of the time it is image manifest and | ||||
| 							// not manifest list but actually both are handled because for Docker mediatypes the | ||||
| 							// mediatype value in the Accpet header does not seem to matter. | ||||
| 							s, ok = r.ExporterResponse[exptypes.ExporterImageDigestKey] | ||||
| 							if ok { | ||||
| 								descs = append(descs, specs.Descriptor{ | ||||
| 									Digest:    digest.Digest(s), | ||||
|   | ||||
							
								
								
									
										12
									
								
								build/git.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								build/git.go
									
									
									
									
									
								
							| @@ -52,20 +52,20 @@ func getGitAttributes(ctx context.Context, contextPath string, dockerfilePath st | ||||
| 	gitc, err := gitutil.New(gitutil.WithContext(ctx), gitutil.WithWorkingDir(wd)) | ||||
| 	if err != nil { | ||||
| 		if st, err := os.Stat(path.Join(wd, ".git")); err == nil && st.IsDir() { | ||||
| 			return res, errors.New("git was not found in the system. Current commit information was not captured by the build") | ||||
| 			return res, errors.New("buildx: git was not found in the system. Current commit information was not captured by the build") | ||||
| 		} | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if !gitc.IsInsideWorkTree() { | ||||
| 		if st, err := os.Stat(path.Join(wd, ".git")); err == nil && st.IsDir() { | ||||
| 			return res, errors.New("failed to read current commit information with git rev-parse --is-inside-work-tree") | ||||
| 			return res, errors.New("buildx: failed to read current commit information with git rev-parse --is-inside-work-tree") | ||||
| 		} | ||||
| 		return res, nil | ||||
| 	} | ||||
|  | ||||
| 	if sha, err := gitc.FullCommit(); err != nil { | ||||
| 		return res, errors.Wrapf(err, "failed to get git commit") | ||||
| 		return res, errors.Wrapf(err, "buildx: failed to get git commit") | ||||
| 	} else if sha != "" { | ||||
| 		if gitc.IsDirty() { | ||||
| 			sha += "-dirty" | ||||
| @@ -78,9 +78,7 @@ func getGitAttributes(ctx context.Context, contextPath string, dockerfilePath st | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if rurl, err := gitc.RemoteURL(); err != nil { | ||||
| 		return res, errors.Wrapf(err, "failed to get git remote url") | ||||
| 	} else if rurl != "" { | ||||
| 	if rurl, err := gitc.RemoteURL(); err == nil && rurl != "" { | ||||
| 		if setGitLabels { | ||||
| 			res["label:"+specs.AnnotationSource] = rurl | ||||
| 		} | ||||
| @@ -91,7 +89,7 @@ func getGitAttributes(ctx context.Context, contextPath string, dockerfilePath st | ||||
|  | ||||
| 	if setGitLabels { | ||||
| 		if root, err := gitc.RootDir(); err != nil { | ||||
| 			return res, errors.Wrapf(err, "failed to get git root dir") | ||||
| 			return res, errors.Wrapf(err, "buildx: failed to get git root dir") | ||||
| 		} else if root != "" { | ||||
| 			if dockerfilePath == "" { | ||||
| 				dockerfilePath = filepath.Join(wd, "Dockerfile") | ||||
|   | ||||
| @@ -62,6 +62,7 @@ func (b *Builder) LoadNodes(ctx context.Context, withData bool) (_ []Node, err e | ||||
| 				node := Node{ | ||||
| 					Node:        n, | ||||
| 					ProxyConfig: storeutil.GetProxyConfig(b.opts.dockerCli), | ||||
| 					Platforms:   n.Platforms, | ||||
| 				} | ||||
| 				defer func() { | ||||
| 					b.nodes[i] = node | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Tõnis Tiigi
					Tõnis Tiigi