add general shizzle
(cherry picked from commit 72d164f3960436093d01d00d5ed6d43bc2e4e256)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package helmunit
|
||||
|
||||
import (
|
||||
"github.com/Jeffail/gabs"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
func mergeMaps(a, b map[string]interface{}) map[string]interface{} {
|
||||
out := make(map[string]interface{}, len(a))
|
||||
for k, v := range a {
|
||||
out[k] = v
|
||||
}
|
||||
for k, v := range b {
|
||||
if v, ok := v.(map[string]interface{}); ok {
|
||||
if bv, ok := out[k]; ok {
|
||||
if bv, ok := bv.(map[string]interface{}); ok {
|
||||
out[k] = mergeMaps(bv, v)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
out[k] = v
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func yamlToJson(yamlInput []byte) (jsonOutput *gabs.Container, err error) {
|
||||
jsonBytes, err := yaml.YAMLToJSON(yamlInput)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
jsonParsed, err := gabs.ParseJSON(jsonBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonParsed, nil
|
||||
}
|
||||
Reference in New Issue
Block a user