chore(sources/env): bump gosettings to v0.3.0-rc9
This commit is contained in:
32
internal/configuration/sources/env/publicip.go
vendored
32
internal/configuration/sources/env/publicip.go
vendored
@@ -1,44 +1,18 @@
|
||||
package env
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gosettings/sources/env"
|
||||
)
|
||||
|
||||
func (s *Source) readPublicIP() (publicIP settings.PublicIP, err error) {
|
||||
publicIP.Period, err = readPublicIPPeriod()
|
||||
publicIP.Period, err = env.DurationPtr("PUBLICIP_PERIOD")
|
||||
if err != nil {
|
||||
return publicIP, err
|
||||
}
|
||||
|
||||
publicIP.IPFilepath = s.readPublicIPFilepath()
|
||||
_, publicIP.IPFilepath = s.getEnvWithRetro("PUBLICIP_FILE",
|
||||
[]string{"IP_STATUS_FILE"}, env.ForceLowercase(false))
|
||||
|
||||
return publicIP, nil
|
||||
}
|
||||
|
||||
func readPublicIPPeriod() (period *time.Duration, err error) {
|
||||
s := env.Get("PUBLICIP_PERIOD")
|
||||
if s == "" {
|
||||
return nil, nil //nolint:nilnil
|
||||
}
|
||||
|
||||
period = new(time.Duration)
|
||||
*period, err = time.ParseDuration(s)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("environment variable PUBLICIP_PERIOD: %w", err)
|
||||
}
|
||||
|
||||
return period, nil
|
||||
}
|
||||
|
||||
func (s *Source) readPublicIPFilepath() (filepath *string) {
|
||||
_, value := s.getEnvWithRetro("PUBLICIP_FILE",
|
||||
[]string{"IP_STATUS_FILE"}, env.ForceLowercase(false))
|
||||
if value != "" {
|
||||
return &value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user