Skip to content

Commit

Permalink
Support map[string]config{} by creating a ptr to the config value
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVitek committed Oct 10, 2024
1 parent 83af6e7 commit f76be65
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,19 @@ func (g *collector) collectSecretFields(v reflect.Value, path string) {
case reflect.Map:
for _, key := range v.MapKeys() {
item := v.MapIndex(key)
g.collectSecretFields(item, fmt.Sprintf("%v[%v]", path, key))

if item.Kind() == reflect.Struct {
// If the value is a struct, create a pointer to the map value and modify via pointer
ptr := reflect.New(item.Type())
ptr.Elem().Set(item)

g.collectSecretFields(ptr, fmt.Sprintf("%v[%v]", path, key))

// Set the modified struct back into the map
v.SetMapIndex(key, ptr.Elem())
} else {
g.collectSecretFields(item, fmt.Sprintf("%v[%v]", path, key))
}
}

case reflect.String:
Expand Down

0 comments on commit f76be65

Please sign in to comment.