From ac6080bea9debebb9d3b4a40d2130864a9809daf Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 2 May 2025 11:55:27 +0200 Subject: [PATCH] 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 --- pkg/machine/ignition/ignition.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/machine/ignition/ignition.go b/pkg/machine/ignition/ignition.go index d8a0eabee3..3617c2e789 100644 --- a/pkg/machine/ignition/ignition.go +++ b/pkg/machine/ignition/ignition.go @@ -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