Added support for configuring array values with environment variables #3511

Signed-off-by: Andrii Soldatenko <andrii.soldatenko@dynatrace.com>
This commit is contained in:
Andrii Soldatenko 2023-07-16 21:00:18 +02:00
parent 003dd5aaa1
commit 916b94eb3a
No known key found for this signature in database
GPG key ID: 275C4B8ECD981CD1

View file

@ -166,6 +166,17 @@ func (p *Parser) overwriteFields(v reflect.Value, fullpath string, path []string
return p.overwriteStruct(v, fullpath, path, payload)
case reflect.Map:
return p.overwriteMap(v, fullpath, path, payload)
case reflect.Slice:
idx, err := strconv.Atoi(path[0])
if err != nil {
panic("non-numeric index: " + path[0])
}
if idx >= v.Len() {
panic("Undefined index: " + path[0])
}
return p.overwriteFields(v.Index(idx), fullpath, path[1:], payload)
case reflect.Interface:
if v.NumMethod() == 0 {
if !v.IsNil() {