Skip to content

Commit

Permalink
fix time.Duration parsing in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
arriven committed Apr 16, 2022
1 parent c26197a commit 1dbaa92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/config/advanced/packetgen-slowloris.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
jobs:
- type: packetgen
args:
interval_ms: 10000
interval: "10s"
connection:
type: net
args:
Expand Down
10 changes: 9 additions & 1 deletion src/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,15 @@ func Decode(input any, output any) error {
return strings.EqualFold(strings.Map(filter, lhs), strings.Map(filter, rhs))
}

decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{Squash: true, WeaklyTypedInput: true, MatchName: matchName, Result: output})
decoderConfig := &mapstructure.DecoderConfig{
Squash: true,
WeaklyTypedInput: true,
MatchName: matchName,
DecodeHook: mapstructure.StringToTimeDurationHookFunc(),
Result: output,
}

decoder, err := mapstructure.NewDecoder(decoderConfig)
if err != nil {
return err
}
Expand Down

0 comments on commit 1dbaa92

Please sign in to comment.