mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 10:03:42 +08:00 
			
		
		
		
	build: improve error messages for docker driver
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com> Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
		@@ -391,7 +391,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
 | 
			
		||||
 | 
			
		||||
	for _, e := range opt.CacheTo {
 | 
			
		||||
		if e.Type != "inline" && !nodeDriver.Features(ctx)[driver.CacheExport] {
 | 
			
		||||
			return nil, nil, notSupported(nodeDriver, driver.CacheExport)
 | 
			
		||||
			return nil, nil, notSupported(driver.CacheExport, nodeDriver, "https://docs.docker.com/go/build-cache-backends/")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -529,7 +529,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
 | 
			
		||||
	// set up exporters
 | 
			
		||||
	for i, e := range opt.Exports {
 | 
			
		||||
		if e.Type == "oci" && !nodeDriver.Features(ctx)[driver.OCIExporter] {
 | 
			
		||||
			return nil, nil, notSupported(nodeDriver, driver.OCIExporter)
 | 
			
		||||
			return nil, nil, notSupported(driver.OCIExporter, nodeDriver, "https://docs.docker.com/go/build-exporters/")
 | 
			
		||||
		}
 | 
			
		||||
		if e.Type == "docker" {
 | 
			
		||||
			features := docker.Features(ctx, e.Attrs["context"])
 | 
			
		||||
@@ -555,7 +555,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
 | 
			
		||||
					opt.Exports[i].Output = wrapWriteCloser(w)
 | 
			
		||||
				}
 | 
			
		||||
			} else if !nodeDriver.Features(ctx)[driver.DockerExporter] {
 | 
			
		||||
				return nil, nil, notSupported(nodeDriver, driver.DockerExporter)
 | 
			
		||||
				return nil, nil, notSupported(driver.DockerExporter, nodeDriver, "https:/docs.docker.com/go/build-exporters/")
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if e.Type == "image" && nodeDriver.IsMobyDriver() {
 | 
			
		||||
@@ -627,7 +627,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
 | 
			
		||||
			pp[i] = platforms.Format(p)
 | 
			
		||||
		}
 | 
			
		||||
		if len(pp) > 1 && !nodeDriver.Features(ctx)[driver.MultiPlatform] {
 | 
			
		||||
			return nil, nil, notSupported(nodeDriver, driver.MultiPlatform)
 | 
			
		||||
			return nil, nil, notSupported(driver.MultiPlatform, nodeDriver, "https://docs.docker.com/go/build-multi-platform/")
 | 
			
		||||
		}
 | 
			
		||||
		so.FrontendAttrs["platform"] = strings.Join(pp, ",")
 | 
			
		||||
	}
 | 
			
		||||
@@ -1560,8 +1560,10 @@ func waitContextDeps(ctx context.Context, index int, results *waitmap.Map, so *c
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func notSupported(d driver.Driver, f driver.Feature) error {
 | 
			
		||||
	return errors.Errorf("%s feature is currently not supported for %s driver. Please switch to a different driver (eg. \"docker buildx create --use\")", f, d.Factory().Name())
 | 
			
		||||
func notSupported(f driver.Feature, d driver.Driver, docs string) error {
 | 
			
		||||
	return errors.Errorf(`%s is not supported for the %s driver.
 | 
			
		||||
Switch to a different driver, or turn on the containerd image store, and try again.
 | 
			
		||||
Learn more at %s`, f, d.Factory().Name(), docs)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func noDefaultLoad() bool {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user