From c255c04eed9d151687a8ed55b41d6cd5967f788c Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Tue, 8 Mar 2022 10:06:03 -0800 Subject: [PATCH] bake: restore consistent output for metadata Metadata formatting should not depend on the number of targets. Signed-off-by: Tonis Tiigi --- commands/bake.go | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/commands/bake.go b/commands/bake.go index 74d09113..53d2f671 100644 --- a/commands/bake.go +++ b/commands/bake.go @@ -150,21 +150,13 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions) (err error return wrapBuildError(err, true) } - if len(in.metadataFile) > 0 && resp != nil { - if len(resp) == 1 { - for _, r := range resp { - if err := writeMetadataFile(in.metadataFile, decodeExporterResponse(r.ExporterResponse)); err != nil { - return err - } - } - } else { - dt := make(map[string]interface{}) - for t, r := range resp { - dt[t] = decodeExporterResponse(r.ExporterResponse) - } - if err := writeMetadataFile(in.metadataFile, dt); err != nil { - return err - } + if len(in.metadataFile) > 0 { + dt := make(map[string]interface{}) + for t, r := range resp { + dt[t] = decodeExporterResponse(r.ExporterResponse) + } + if err := writeMetadataFile(in.metadataFile, dt); err != nil { + return err } }