Merge pull request #3066 from seefs001/fix/aws-header-override
Fix/aws header override
This commit is contained in:
@@ -436,11 +436,46 @@ func mergeChannelOverride(base map[string]interface{}, tpl map[string]interface{
|
||||
}
|
||||
out := cloneStringAnyMap(base)
|
||||
for k, v := range tpl {
|
||||
if strings.EqualFold(strings.TrimSpace(k), "operations") {
|
||||
baseOps, hasBaseOps := extractParamOperations(out[k])
|
||||
tplOps, hasTplOps := extractParamOperations(v)
|
||||
if hasTplOps {
|
||||
if hasBaseOps {
|
||||
out[k] = append(tplOps, baseOps...)
|
||||
} else {
|
||||
out[k] = tplOps
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
if _, exists := out[k]; exists {
|
||||
continue
|
||||
}
|
||||
out[k] = v
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func extractParamOperations(value interface{}) ([]interface{}, bool) {
|
||||
switch ops := value.(type) {
|
||||
case []interface{}:
|
||||
if len(ops) == 0 {
|
||||
return []interface{}{}, true
|
||||
}
|
||||
cloned := make([]interface{}, 0, len(ops))
|
||||
cloned = append(cloned, ops...)
|
||||
return cloned, true
|
||||
case []map[string]interface{}:
|
||||
cloned := make([]interface{}, 0, len(ops))
|
||||
for _, op := range ops {
|
||||
cloned = append(cloned, op)
|
||||
}
|
||||
return cloned, true
|
||||
default:
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
|
||||
func appendChannelAffinityTemplateAdminInfo(c *gin.Context, meta channelAffinityMeta) {
|
||||
if c == nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user