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 <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2025-05-02 11:55:27 +02:00
parent a90fad3fc8
commit ac6080bea9

View File

@ -147,9 +147,13 @@ func (ign *DynamicIgnition) GenerateIgnitionConfig() error {
// local means the same as the host
// look up where it is pointing to on the host
if ign.TimeZone == "local" {
tz, err = getLocalTimeZone()
if err != nil {
return fmt.Errorf("error getting local timezone: %q", err)
if env, ok := os.LookupEnv("TZ"); ok {
tz = env
} else {
tz, err = getLocalTimeZone()
if err != nil {
return fmt.Errorf("error getting local timezone: %q", err)
}
}
}
// getLocalTimeZone() can return empty string, do not add broken symlink in that case