Skip to content

Commit ac6080b

Browse files
committed
pkg/machinie: use TZ env for reading local timezone
The TZ var can be commonly used to overwrite the timezone so we should honour that one as well. Signed-off-by: Paul Holzinger <[email protected]>
1 parent a90fad3 commit ac6080b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/machine/ignition/ignition.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,13 @@ func (ign *DynamicIgnition) GenerateIgnitionConfig() error {
147147
// local means the same as the host
148148
// look up where it is pointing to on the host
149149
if ign.TimeZone == "local" {
150-
tz, err = getLocalTimeZone()
151-
if err != nil {
152-
return fmt.Errorf("error getting local timezone: %q", err)
150+
if env, ok := os.LookupEnv("TZ"); ok {
151+
tz = env
152+
} else {
153+
tz, err = getLocalTimeZone()
154+
if err != nil {
155+
return fmt.Errorf("error getting local timezone: %q", err)
156+
}
153157
}
154158
}
155159
// getLocalTimeZone() can return empty string, do not add broken symlink in that case

0 commit comments

Comments
 (0)