|
|
|
@ -112,7 +112,7 @@ func coalesceDeps(chrt *chart.Chart, dest map[string]interface{}, prefix string,
|
|
|
|
|
dvmap := dv.(map[string]interface{})
|
|
|
|
|
subPrefix := concatPrefix(prefix, chrt.Metadata.Name)
|
|
|
|
|
// Get globals out of dest and merge them into dvmap.
|
|
|
|
|
coalesceGlobals(slog.Default().With(slog.String("chart", chrt.Name())), dvmap, dest, subPrefix, merge)
|
|
|
|
|
coalesceGlobals(dvmap, dest, subPrefix, merge)
|
|
|
|
|
// Now coalesce the rest of the values.
|
|
|
|
|
var err error
|
|
|
|
|
dest[subchart.Name()], err = coalesce(subchart, dvmap, subPrefix, merge)
|
|
|
|
@ -127,14 +127,14 @@ func coalesceDeps(chrt *chart.Chart, dest map[string]interface{}, prefix string,
|
|
|
|
|
// coalesceGlobals copies the globals out of src and merges them into dest.
|
|
|
|
|
//
|
|
|
|
|
// For convenience, returns dest.
|
|
|
|
|
func coalesceGlobals(logger *slog.Logger, dest, src map[string]interface{}, prefix string, _ bool) {
|
|
|
|
|
func coalesceGlobals(dest, src map[string]interface{}, prefix string, _ bool) {
|
|
|
|
|
var dg, sg map[string]interface{}
|
|
|
|
|
|
|
|
|
|
if destglob, ok := dest[GlobalKey]; !ok {
|
|
|
|
|
dg = make(map[string]interface{})
|
|
|
|
|
} else if dg, ok = destglob.(map[string]interface{}); !ok {
|
|
|
|
|
// Destination is not a table
|
|
|
|
|
logger.Warn("skipping coalescing global values", slog.String("key", GlobalKey), slog.String("error", "key is not a table"))
|
|
|
|
|
slog.Warn("skipping coalescing global values", slog.String("key", GlobalKey), slog.String("error", "key is not a table"))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -142,7 +142,7 @@ func coalesceGlobals(logger *slog.Logger, dest, src map[string]interface{}, pref
|
|
|
|
|
sg = make(map[string]interface{})
|
|
|
|
|
} else if sg, ok = srcglob.(map[string]interface{}); !ok {
|
|
|
|
|
// Source is not a table
|
|
|
|
|
logger.Warn("skipping coalescing global values", slog.String("key", GlobalKey), slog.String("error", "key is not a table"))
|
|
|
|
|
slog.Warn("skipping coalescing global values", slog.String("key", GlobalKey), slog.String("error", "key is not a table"))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -158,7 +158,7 @@ func coalesceGlobals(logger *slog.Logger, dest, src map[string]interface{}, pref
|
|
|
|
|
dg[key] = vv
|
|
|
|
|
} else {
|
|
|
|
|
if destvmap, ok := destv.(map[string]interface{}); !ok {
|
|
|
|
|
logger.Warn("skipping key", slog.String("key", key), slog.String("error", "cannot merge table and non-table values"))
|
|
|
|
|
slog.Warn("skipping key", slog.String("key", key), slog.String("error", "cannot merge table and non-table values"))
|
|
|
|
|
} else {
|
|
|
|
|
// Basically, we reverse order of coalesce here to merge
|
|
|
|
|
// top-down.
|
|
|
|
@ -166,13 +166,13 @@ func coalesceGlobals(logger *slog.Logger, dest, src map[string]interface{}, pref
|
|
|
|
|
// In this location coalesceTablesFullKey should always have
|
|
|
|
|
// merge set to true. The output of coalesceGlobals is run
|
|
|
|
|
// through coalesce where any nils will be removed.
|
|
|
|
|
coalesceTablesFullKey(logger, vv, destvmap, subPrefix, true)
|
|
|
|
|
coalesceTablesFullKey(vv, destvmap, subPrefix, true)
|
|
|
|
|
dg[key] = vv
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if dv, ok := dg[key]; ok && istable(dv) {
|
|
|
|
|
// It's not clear if this condition can actually ever trigger.
|
|
|
|
|
logger.Warn("skipping key", slog.String("key", key), slog.String("error", "cannot merge table and non-table values"))
|
|
|
|
|
slog.Warn("skipping key", slog.String("key", key), slog.String("error", "cannot merge table and non-table values"))
|
|
|
|
|
} else {
|
|
|
|
|
// TODO: Do we need to do any additional checking on the value?
|
|
|
|
|
dg[key] = val
|
|
|
|
@ -242,7 +242,7 @@ func coalesceValues(c *chart.Chart, v map[string]interface{}, prefix string, mer
|
|
|
|
|
|
|
|
|
|
// Because v has higher precedence than nv, dest values override src
|
|
|
|
|
// values.
|
|
|
|
|
coalesceTablesFullKey(slog.Default().With(slog.String("chart", c.Name())), dest, src, concatPrefix(subPrefix, key), merge)
|
|
|
|
|
coalesceTablesFullKey(dest, src, concatPrefix(subPrefix, key), merge)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -265,20 +265,17 @@ func childChartMergeTrue(chrt *chart.Chart, key string, merge bool) bool {
|
|
|
|
|
//
|
|
|
|
|
// dest is considered authoritative.
|
|
|
|
|
func CoalesceTables(dst, src map[string]interface{}) map[string]interface{} {
|
|
|
|
|
return coalesceTablesFullKey(nil, dst, src, "", false)
|
|
|
|
|
return coalesceTablesFullKey(dst, src, "", false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func MergeTables(dst, src map[string]interface{}) map[string]interface{} {
|
|
|
|
|
return coalesceTablesFullKey(nil, dst, src, "", true)
|
|
|
|
|
return coalesceTablesFullKey(dst, src, "", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// coalesceTablesFullKey merges a source map into a destination map.
|
|
|
|
|
//
|
|
|
|
|
// dest is considered authoritative.
|
|
|
|
|
func coalesceTablesFullKey(logger *slog.Logger, dst, src map[string]interface{}, prefix string, merge bool) map[string]interface{} {
|
|
|
|
|
if logger == nil {
|
|
|
|
|
logger = slog.Default()
|
|
|
|
|
}
|
|
|
|
|
func coalesceTablesFullKey(dst, src map[string]interface{}, prefix string, merge bool) map[string]interface{} {
|
|
|
|
|
|
|
|
|
|
// When --reuse-values is set but there are no modifications yet, return new values
|
|
|
|
|
if src == nil {
|
|
|
|
@ -297,12 +294,12 @@ func coalesceTablesFullKey(logger *slog.Logger, dst, src map[string]interface{},
|
|
|
|
|
dst[key] = val
|
|
|
|
|
} else if istable(val) {
|
|
|
|
|
if istable(dv) {
|
|
|
|
|
coalesceTablesFullKey(logger, dv.(map[string]interface{}), val.(map[string]interface{}), fullkey, merge)
|
|
|
|
|
coalesceTablesFullKey(dv.(map[string]interface{}), val.(map[string]interface{}), fullkey, merge)
|
|
|
|
|
} else {
|
|
|
|
|
logger.Warn("skipping key", slog.String("key", fullkey), slog.String("error", "cannot merge table and non-table values"))
|
|
|
|
|
slog.Warn("skipping key", slog.String("key", fullkey), slog.String("error", "cannot merge table and non-table values"))
|
|
|
|
|
}
|
|
|
|
|
} else if istable(dv) && val != nil {
|
|
|
|
|
logger.Warn("skipping key", slog.String("key", fullkey), slog.String("error", "cannot merge table and non-table values"))
|
|
|
|
|
slog.Warn("skipping key", slog.String("key", fullkey), slog.String("error", "cannot merge table and non-table values"))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return dst
|
|
|
|
|