refact to materialize the propagation logic

- formats exports and parent-child just differ in how to discover
    their paths
  - share propagation logic for both formats

Signed-off-by: ferantivero <v-fean@microsoft.com>
pull/7047/head
ferantivero 6 years ago
parent f9428817f7
commit d0f23a28af

@ -417,28 +417,16 @@ func processImportValues(c *chart.Chart) error {
if len(r.ImportValues) > 0 { if len(r.ImportValues) > 0 {
var outiv []interface{} var outiv []interface{}
for _, riv := range r.ImportValues { for _, riv := range r.ImportValues {
nm := make(map[string]string, 0)
switch iv := riv.(type) { switch iv := riv.(type) {
case map[string]interface{}: case map[string]interface{}:
nm := map[string]string{ nm["child"] = iv["child"].(string)
"child": iv["child"].(string), nm["parent"] = iv["parent"].(string)
"parent": iv["parent"].(string),
}
outiv = append(outiv, nm)
s := name + "." + nm["child"]
// get child table
vv, err := cvals.Table(s)
if err != nil {
log.Printf("Warning: ImportValues missing table: %v", err)
continue
}
// create value map from child to be merged into parent
vm := pathToMap(nm["parent"], vv.AsMap())
b = coalesceTables(b, vm, c.Metadata.Name)
case string: case string:
nm := map[string]string{ nm["child"] = "exports." + iv
"child": "exports." + iv, nm["parent"] = "."
"parent": ".",
} }
outiv = append(outiv, nm) outiv = append(outiv, nm)
s := name + "." + nm["child"] s := name + "." + nm["child"]
// get child table // get child table
@ -450,7 +438,7 @@ func processImportValues(c *chart.Chart) error {
// create value map from child to be merged into parent // create value map from child to be merged into parent
vm := pathToMap(nm["parent"], vv.AsMap()) vm := pathToMap(nm["parent"], vv.AsMap())
b = coalesceTables(b, vm, c.Metadata.Name) b = coalesceTables(b, vm, c.Metadata.Name)
}
} }
// set our formatted import values // set our formatted import values
r.ImportValues = outiv r.ImportValues = outiv

Loading…
Cancel
Save