Merge pull request #963 from tonistiigi/bake-contexts-error

bake: use better error in named contexts not supported
pull/967/head
Tõnis Tiigi 3 years ago committed by GitHub
commit 5939a23af6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -147,7 +147,7 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions) (err error
resp, err := build.Build(ctx, dis, bo, dockerAPI(dockerCli), confutil.ConfigDir(dockerCli), printer)
if err != nil {
return err
return wrapBuildError(err, true)
}
if len(in.metadataFile) > 0 && resp != nil {

@ -226,7 +226,7 @@ func runBuild(dockerCli command.Cli, in buildOptions) (err error) {
}
imageID, err := buildTargets(ctx, dockerCli, map[string]build.Options{defaultTargetName: opts}, in.progress, contextPathHash, in.builder, in.metadataFile)
err = wrapBuildError(err)
err = wrapBuildError(err, false)
if err != nil {
return err
}
@ -526,14 +526,19 @@ func decodeExporterResponse(exporterResponse map[string]string) map[string]inter
return out
}
func wrapBuildError(err error) error {
func wrapBuildError(err error, bake bool) error {
if err == nil {
return nil
}
st, ok := grpcerrors.AsGRPCStatus(err)
if ok {
if st.Code() == codes.Unimplemented && strings.Contains(st.Message(), "unsupported frontend capability moby.buildkit.frontend.contexts") {
return &wrapped{err, "current frontend does not support --build-context. Named contexts are supported since Dockerfile v1.4"}
msg := "current frontend does not support --build-context."
if bake {
msg = "current frontend does not support defining additional contexts for targets."
}
msg += " Named contexts are supported since Dockerfile v1.4. Use #syntax directive in Dockerfile or update to latest BuildKit."
return &wrapped{err, msg}
}
}
return err

Loading…
Cancel
Save