mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-25 14:30:22 +00:00
fb7dc13dfe
updated few packages in go.mod to latest available release. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
23 lines
431 B
Go
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)
|
|
}
|