ceph-csi/vendor/github.com/onsi/gomega/internal/defaults/env.go
Madhu Rajanna fb7dc13dfe rebase: update packages in go.mod to latest releases
updated few packages in go.mod to latest
available release.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2021-06-04 11:52:22 +00:00

23 lines
431 B
Go

package defaults
import (
"fmt"
"time"
)
func SetDurationFromEnv(getDurationFromEnv func(string) string, varSetter func(time.Duration), name string) {
durationFromEnv := getDurationFromEnv(name)
if len(durationFromEnv) == 0 {
return
}
duration, err := time.ParseDuration(durationFromEnv)
if err != nil {
panic(fmt.Sprintf("Expected a duration when using %s! Parse error %v", name, err))
}
varSetter(duration)
}