Fix loading timezone info on windows (#32029) (#32149)

* 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>
(cherry picked from commit ea484312a0)

Co-authored-by: Tania B <yalyna.ts@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-03-19 10:41:26 +01:00
committed by GitHub
co-authored by Tania B
parent bc463d6a2f
commit fbf3469e80
+12
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
@@ -751,6 +755,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