build: refactor to avoid unneccessary nesting

Signed-off-by: Justin Chadwell <me@jedevc.com>
pull/1750/head
Justin Chadwell 2 years ago
parent 1fd23933c2
commit c6a78d216c

@ -792,8 +792,7 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
multiTarget := len(opt) > 1
for k, opt := range opt {
err := func(k string) error {
opt := opt
k, opt := k, opt
dps := m[k]
multiDriver := len(m[k]) > 1
@ -816,17 +815,17 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
for i, e := range so.Exports {
switch e.Type {
case "oci", "tar":
return errors.Errorf("%s for multi-node builds currently not supported", e.Type)
return nil, errors.Errorf("%s for multi-node builds currently not supported", e.Type)
case "image":
if pushNames == "" && e.Attrs["push"] != "" {
if ok, _ := strconv.ParseBool(e.Attrs["push"]); ok {
pushNames = e.Attrs["name"]
if pushNames == "" {
return errors.Errorf("tag is needed when pushing to registry")
return nil, errors.Errorf("tag is needed when pushing to registry")
}
names, err := toRepoOnly(e.Attrs["name"])
if err != nil {
return err
return nil, err
}
if ok, _ := strconv.ParseBool(e.Attrs["registry.insecure"]); ok {
insecurePush = true
@ -1100,12 +1099,6 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
}
return nil
})
return nil
}(k)
if err != nil {
return nil, err
}
}
if err := eg.Wait(); err != nil {

Loading…
Cancel
Save