improved coalesce readability by getting rid of continue statements

Signed-off-by: Bernd Gutjahr <bernd.gutjahr@microfocus.com>
pull/8800/head
Bernd Gutjahr 5 years ago
parent 4fafe2fe11
commit 2343903a0d

@ -111,8 +111,6 @@ func coalesceGlobals(dest, src map[string]interface{}) {
vv := copyMap(val.(map[string]interface{})) vv := copyMap(val.(map[string]interface{}))
if destv, ok := dg[key]; !ok { if destv, ok := dg[key]; !ok {
// Here there is no merge. We're just adding. // Here there is no merge. We're just adding.
dg[key] = vv
continue
} else { } else {
if destvmap, ok := destv.(map[string]interface{}); !ok { if destvmap, ok := destv.(map[string]interface{}); !ok {
log.Printf("Conflict: cannot merge map onto non-map for %q. Skipping.", key) log.Printf("Conflict: cannot merge map onto non-map for %q. Skipping.", key)
@ -120,17 +118,16 @@ func coalesceGlobals(dest, src map[string]interface{}) {
// Basically, we reverse order of coalesce here to merge // Basically, we reverse order of coalesce here to merge
// top-down. // top-down.
CoalesceTables(vv, destvmap) CoalesceTables(vv, destvmap)
dg[key] = vv
continue
} }
} }
dg[key] = vv
} else if dv, ok := dg[key]; ok && istable(dv) { } else if dv, ok := dg[key]; ok && istable(dv) {
// It's not clear if this condition can actually ever trigger. // It's not clear if this condition can actually ever trigger.
log.Printf("key %s is table. Skipping", key) log.Printf("key %s is table. Skipping", key)
continue } else {
// TODO: Do we need to do any additional checking on the value?
dg[key] = val
} }
// TODO: Do we need to do any additional checking on the value?
dg[key] = val
} }
dest[GlobalKey] = dg dest[GlobalKey] = dg
} }
@ -159,15 +156,15 @@ func coalesceValues(c *chart.Chart, v map[string]interface{}) {
src, ok := val.(map[string]interface{}) src, ok := val.(map[string]interface{})
if !ok { if !ok {
// If the original value is nil, there is nothing to coalesce, so we don't print // If the original value is nil, there is nothing to coalesce, so we don't print
// the warning but simply continue // the warning
if val != nil { if val != nil {
log.Printf("warning: skipped value for %s: Not a table.", key) log.Printf("warning: skipped value for %s: Not a table.", key)
} }
continue } else {
// Because v has higher precedence than nv, dest values override src
// values.
CoalesceTables(dest, src)
} }
// Because v has higher precedence than nv, dest values override src
// values.
CoalesceTables(dest, src)
} }
} else { } else {
// If the key is not in v, copy it from nv. // If the key is not in v, copy it from nv.

Loading…
Cancel
Save