chore(sources/env): bump gosettings to v0.3.0-rc13
- Use `RetroKeys` option with env.* method calls - Use `CSV*` typed methods - Inject `handleDeprecatedKey` function
This commit is contained in:
20
internal/configuration/sources/env/health.go
vendored
20
internal/configuration/sources/env/health.go
vendored
@@ -1,15 +1,14 @@
|
||||
package env
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gosettings/sources/env"
|
||||
)
|
||||
|
||||
func (s *Source) ReadHealth() (health settings.Health, err error) {
|
||||
health.ServerAddress = s.env.String("HEALTH_SERVER_ADDRESS")
|
||||
targetAddressEnvKey, _ := s.getEnvWithRetro("HEALTH_TARGET_ADDRESS", []string{"HEALTH_ADDRESS_TO_PING"})
|
||||
health.TargetAddress = s.env.String(targetAddressEnvKey)
|
||||
health.TargetAddress = s.env.String("HEALTH_TARGET_ADDRESS",
|
||||
env.RetroKeys("HEALTH_ADDRESS_TO_PING"))
|
||||
|
||||
successWaitPtr, err := s.env.DurationPtr("HEALTH_SUCCESS_WAIT_DURATION")
|
||||
if err != nil {
|
||||
@@ -18,24 +17,19 @@ func (s *Source) ReadHealth() (health settings.Health, err error) {
|
||||
health.SuccessWait = *successWaitPtr
|
||||
}
|
||||
|
||||
health.VPN.Initial, err = s.readDurationWithRetro(
|
||||
health.VPN.Initial, err = s.env.DurationPtr(
|
||||
"HEALTH_VPN_DURATION_INITIAL",
|
||||
"HEALTH_OPENVPN_DURATION_INITIAL")
|
||||
env.RetroKeys("HEALTH_OPENVPN_DURATION_INITIAL"))
|
||||
if err != nil {
|
||||
return health, err
|
||||
}
|
||||
|
||||
health.VPN.Addition, err = s.readDurationWithRetro(
|
||||
health.VPN.Addition, err = s.env.DurationPtr(
|
||||
"HEALTH_VPN_DURATION_ADDITION",
|
||||
"HEALTH_OPENVPN_DURATION_ADDITION")
|
||||
env.RetroKeys("HEALTH_OPENVPN_DURATION_ADDITION"))
|
||||
if err != nil {
|
||||
return health, err
|
||||
}
|
||||
|
||||
return health, nil
|
||||
}
|
||||
|
||||
func (s *Source) readDurationWithRetro(envKey, retroEnvKey string) (d *time.Duration, err error) {
|
||||
envKey, _ = s.getEnvWithRetro(envKey, []string{retroEnvKey})
|
||||
return s.env.DurationPtr(envKey)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user