better map merge
This commit is contained in:
parent
a1fcd4093c
commit
ee2779cc9d
@ -41,11 +41,11 @@ func newRenderContext(host *clustersconfig.Host, cfg *clustersconfig.Config) (ct
|
||||
group.Vars,
|
||||
host.Vars,
|
||||
} {
|
||||
for k, v := range oVars {
|
||||
vars[k] = v
|
||||
}
|
||||
mapMerge(vars, oVars)
|
||||
}
|
||||
|
||||
log.Print("vars: ", vars)
|
||||
|
||||
return &renderContext{
|
||||
Host: host,
|
||||
Group: group,
|
||||
@ -58,6 +58,19 @@ func newRenderContext(host *clustersconfig.Host, cfg *clustersconfig.Config) (ct
|
||||
}, nil
|
||||
}
|
||||
|
||||
func mapMerge(target, source map[string]interface{}) {
|
||||
for k, v := range source {
|
||||
if tMap, targetIsMap := target[k].(map[string]interface{}); targetIsMap {
|
||||
if sMap, sourceIsMap := v.(map[string]interface{}); sourceIsMap {
|
||||
mapMerge(tMap, sMap)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
target[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
func (ctx *renderContext) Config() string {
|
||||
if ctx.ConfigTemplate == nil {
|
||||
log.Fatalf("no such config: %q", ctx.Group.Config)
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func registerWS(rest *restful.Container) {
|
||||
// Admin API
|
||||
// Admin-level APIs
|
||||
ws := &restful.WebService{}
|
||||
ws.Filter(adminAuth).
|
||||
HeaderParameter("Authorization", "Admin bearer token")
|
||||
|
Loading…
Reference in New Issue
Block a user