in agent/envoy_bootstrap/envoy_bootstrap.go [1229:1282]
func mergeCustomConfigMaps(dst, src map[string]interface{}) (map[string]interface{}, error) {
// Tracing should not be merged also no need to case sanitize for tracing as it is a single word.
if srcTracing, ok := src[tracingKey]; ok {
if _, ok := dst[tracingKey]; ok {
return nil, fmt.Errorf("multiple tracing configurations were specified")
}
dst[tracingKey] = srcTracing
log.Info("Tracing config merged")
}
// Stats configs should not be merged
src, err := normalizeMapKeyToCamelCase(src, statsConfigKey)
if err != nil {
return nil, err
}
if srcStats, ok := src[statsConfigKey]; ok {
if _, ok := dst[statsConfigKey]; ok {
return nil, fmt.Errorf("multiple stats configurations were specified")
}
dst[statsConfigKey] = srcStats
log.Info("Stats config merged")
}
// Stats sinks are appended
src, err = normalizeMapKeyToCamelCase(src, statsSinksKey)
if err != nil {
return nil, err
}
dst = extendDstMapInterfaceWithSrcForAKey(dst, src, statsSinksKey)
// The bootstrap static resources could be part of any config supplied, so merge for all.
// Expect Static Resources to be provided either via staticResources (lowerCamelCase) key or via
// static_resources (snake_case) key. If both are provided then below func call will error out.
src, err = normalizeMapKeyToCamelCase(src, staticResourcesKey)
if err != nil {
return nil, err
}
dst, err = mergeStaticResourcesMaps(dst, src)
if err != nil {
return nil, err
}
// Merge rest of the bootstrap configurations except for the resource which are explicitly merged above
// in the previous steps. All the bootstrap resources list can be found in the envoy docs at
// https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/bootstrap/v3/bootstrap.proto#config-bootstrap-v3-bootstrap
for _, key := range [...]string{tracingKey, statsConfigKey, statsSinksKey, staticResourcesKey} {
delete(src, key)
}
if dst, err = mergeDstMapInterfaceWithSrc(dst, src); err != nil {
return nil, err
}
return dst, nil
}