Skip to content

Commit

Permalink
revert moving hooks to a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Mar 14, 2024
1 parent b123dff commit db20be7
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions confmap/confmap.go
Expand Up @@ -148,26 +148,23 @@ func (l *Conf) ToStringMap() map[string]any {
// Decodes time.Duration from strings. Allows custom unmarshaling for structs implementing
// encoding.TextUnmarshaler. Allows custom unmarshaling for structs implementing confmap.Unmarshaler.
func decodeConfig(m *Conf, result any, errorUnused bool, topLevelUnmarshaling bool) error {
hookFuncs := []mapstructure.DecodeHookFunc{
expandNilStructPointersHookFunc(),
mapstructure.StringToSliceHookFunc(","),
mapKeyStringToMapKeyTextUnmarshalerHookFunc(),
mapstructure.StringToTimeDurationHookFunc(),
mapstructure.TextUnmarshallerHookFunc(),
unmarshalerHookFunc(result, topLevelUnmarshaling),
// after the main unmarshaler hook is called,
// we unmarshal the embedded structs if present to merge with the result:
unmarshalerEmbeddedStructsHookFunc(),
zeroSliceHookFunc(),
}
dc := &mapstructure.DecoderConfig{
ErrorUnused: errorUnused,
Result: result,
TagName: "mapstructure",
WeaklyTypedInput: true,
MatchName: caseSensitiveMatchName,
DecodeHook: mapstructure.ComposeDecodeHookFunc(
hookFuncs...,
expandNilStructPointersHookFunc(),
mapstructure.StringToSliceHookFunc(","),
mapKeyStringToMapKeyTextUnmarshalerHookFunc(),
mapstructure.StringToTimeDurationHookFunc(),
mapstructure.TextUnmarshallerHookFunc(),
unmarshalerHookFunc(result, topLevelUnmarshaling),
// after the main unmarshaler hook is called,
// we unmarshal the embedded structs if present to merge with the result:
unmarshalerEmbeddedStructsHookFunc(),
zeroSliceHookFunc(),
),
}
decoder, err := mapstructure.NewDecoder(dc)
Expand Down

0 comments on commit db20be7

Please sign in to comment.