Skip to content

Commit

Permalink
test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
amsanghi committed Jul 18, 2024
1 parent d9d7d38 commit ab5e6fe
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions cmd/util/confighelpers/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"os"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -248,7 +247,6 @@ func EndCommonParse(k *koanf.Koanf, config interface{}) error {

// Default values
DecodeHook: mapstructure.ComposeDecodeHookFunc(
stringToSliceDurationHookFunc(","),
mapstructure.StringToTimeDurationHookFunc()),
Metadata: nil,
Result: config,
Expand All @@ -262,36 +260,6 @@ func EndCommonParse(k *koanf.Koanf, config interface{}) error {
return nil
}

func stringToSliceDurationHookFunc(sep string) mapstructure.DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if t != reflect.TypeOf([]time.Duration{}) {
return data, nil
}

raw, _ := data.(string)
if raw == "" {
return []time.Duration{}, nil
}
// raw[1:len(raw)-1] removes the '[' , ']' around the string
durationStrings := strings.Split(raw[1:len(raw)-1], sep)
var durations []time.Duration
for _, durationString := range durationStrings {
duration, err := time.ParseDuration(durationString)
if err != nil {
return nil, err
}
durations = append(durations, duration)
}
return durations, nil
}
}

func DumpConfig(k *koanf.Koanf, extraOverrideFields map[string]interface{}) error {
overrideFields := map[string]interface{}{"conf.dump": false}

Expand Down

0 comments on commit ab5e6fe

Please sign in to comment.