Fix loading timezone info on windows (#32029)

* Fix loading timezone info on windows

* Move setting zoneinfo to config load

* Construct proper file path

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Tania B 2021-03-19 09:14:49 +00:00 committed by GitHub
parent f48a52e590
commit ea484312a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"
@ -48,6 +49,9 @@ const (
authProxySyncTTL = 60
)
// zoneInfo names environment variable for setting the path to look for the timezone database in go
const zoneInfo = "ZONEINFO"
var (
// App settings.
Env = Dev
@ -757,6 +761,14 @@ func (cfg *Cfg) validateStaticRootPath() error {
func (cfg *Cfg) Load(args *CommandLineArgs) error {
setHomePath(args)
// Fix for missing IANA db on Windows
_, zoneInfoSet := os.LookupEnv(zoneInfo)
if runtime.GOOS == "windows" && !zoneInfoSet {
if err := os.Setenv(zoneInfo, filepath.Join(HomePath, "tools", "zoneinfo.zip")); err != nil {
cfg.Logger.Error("Can't set ZONEINFO environment variable", "err", err)
}
}
iniFile, err := cfg.loadConfiguration(args)
if err != nil {
return err