|
|
@ -226,49 +226,72 @@ func processImportValues(c *chart.Chart) error {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b := make(map[string]interface{})
|
|
|
|
c.Values = copyMap(cvals)
|
|
|
|
|
|
|
|
overrides := make(map[string]interface{})
|
|
|
|
// import values from each dependency if specified in import-values
|
|
|
|
// import values from each dependency if specified in import-values
|
|
|
|
for _, r := range c.Metadata.Dependencies {
|
|
|
|
for _, r := range c.Metadata.Dependencies {
|
|
|
|
var outiv []interface{}
|
|
|
|
var outiv []interface{}
|
|
|
|
for _, riv := range r.ImportValues {
|
|
|
|
for _, riv := range r.ImportValues {
|
|
|
|
|
|
|
|
var strategy string
|
|
|
|
|
|
|
|
var values map[string]interface{}
|
|
|
|
|
|
|
|
var child string
|
|
|
|
|
|
|
|
parent := "."
|
|
|
|
switch iv := riv.(type) {
|
|
|
|
switch iv := riv.(type) {
|
|
|
|
case map[string]interface{}:
|
|
|
|
case map[string]interface{}:
|
|
|
|
child := iv["child"].(string)
|
|
|
|
var strategyOk bool
|
|
|
|
parent := iv["parent"].(string)
|
|
|
|
strategy, strategyOk = iv["strategy"].(string)
|
|
|
|
|
|
|
|
if !strategyOk {
|
|
|
|
outiv = append(outiv, map[string]string{
|
|
|
|
strategy = "ifNotPresent"
|
|
|
|
"child": child,
|
|
|
|
}
|
|
|
|
"parent": parent,
|
|
|
|
if key, ok := iv["key"].(string); ok {
|
|
|
|
})
|
|
|
|
child = "exports." + key
|
|
|
|
|
|
|
|
vm, err := cvals.Table(r.Name + "." + child)
|
|
|
|
// get child table
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log.Printf("Warning: ImportValues missing table: %v", err)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
values = vm.AsMap()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
child = iv["child"].(string)
|
|
|
|
|
|
|
|
parent = iv["parent"].(string)
|
|
|
|
vv, err := cvals.Table(r.Name + "." + child)
|
|
|
|
vv, err := cvals.Table(r.Name + "." + child)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("Warning: ImportValues missing table from chart %s: %v", r.Name, err)
|
|
|
|
log.Printf("Warning: ImportValues missing table from chart %s: %v", r.Name, err)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// create value map from child to be merged into parent
|
|
|
|
values = pathToMap(parent, vv.AsMap())
|
|
|
|
b = CoalesceTables(cvals, pathToMap(parent, vv.AsMap()))
|
|
|
|
}
|
|
|
|
case string:
|
|
|
|
case string:
|
|
|
|
|
|
|
|
// backwards compat to use the override strategy when using a string
|
|
|
|
|
|
|
|
strategy = "override"
|
|
|
|
child := "exports." + iv
|
|
|
|
child := "exports." + iv
|
|
|
|
outiv = append(outiv, map[string]string{
|
|
|
|
|
|
|
|
"child": child,
|
|
|
|
|
|
|
|
"parent": ".",
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
vm, err := cvals.Table(r.Name + "." + child)
|
|
|
|
vm, err := cvals.Table(r.Name + "." + child)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("Warning: ImportValues missing table: %v", err)
|
|
|
|
log.Printf("Warning: ImportValues missing table: %v", err)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = CoalesceTables(b, vm.AsMap())
|
|
|
|
values = vm.AsMap()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// merge the values from the child into the parent values according to the import strategy
|
|
|
|
|
|
|
|
if strategy == "override" {
|
|
|
|
|
|
|
|
overrides = CoalesceTables(overrides, values)
|
|
|
|
|
|
|
|
} else if strategy == "ifNotPresent" {
|
|
|
|
|
|
|
|
c.Values = CoalesceTables(c.Values, values)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.Printf("Warning: ImportValues with an invalid import strategy %v", strategy)
|
|
|
|
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
outiv = append(outiv, map[string]string{
|
|
|
|
|
|
|
|
"child": child,
|
|
|
|
|
|
|
|
"parent": parent,
|
|
|
|
|
|
|
|
"strategy": strategy,
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// set our formatted import values
|
|
|
|
// set our formatted import values
|
|
|
|
r.ImportValues = outiv
|
|
|
|
r.ImportValues = outiv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// merge the overrides into the parent values
|
|
|
|
// set the new values
|
|
|
|
c.Values = CoalesceTables(overrides, c.Values)
|
|
|
|
c.Values = CoalesceTables(cvals, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|