summaryrefslogtreecommitdiff
path: root/pkg/machine/ignition_linux.go
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2021-12-14 14:16:09 -0600
committerBrent Baude <bbaude@redhat.com>2021-12-16 12:40:20 -0600
commita86495ea6fdd56519afc65586c0f7f9c0f4f5ab2 (patch)
treebdf7576ddf565cf60b889bc7fd825b40ec6376e5 /pkg/machine/ignition_linux.go
parent273da42af237dde44d34d215dfafa33f0b76d9ab (diff)
downloadpodman-a86495ea6fdd56519afc65586c0f7f9c0f4f5ab2.tar.gz
podman-a86495ea6fdd56519afc65586c0f7f9c0f4f5ab2.tar.bz2
podman-a86495ea6fdd56519afc65586c0f7f9c0f4f5ab2.zip
Set machine timezone
Added an option to podman machine init to declare the timezone of the resulting machine. the default is to use the value of the host name or else a given timezone name like America/Chicago. Fixes: #11895 Signed-off-by: Brent Baude <bbaude@redhat.com> [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/machine/ignition_linux.go')
-rw-r--r--pkg/machine/ignition_linux.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/machine/ignition_linux.go b/pkg/machine/ignition_linux.go
new file mode 100644
index 000000000..6db5a8e7a
--- /dev/null
+++ b/pkg/machine/ignition_linux.go
@@ -0,0 +1,15 @@
+package machine
+
+import (
+ "os/exec"
+ "strings"
+)
+
+func getLocalTimeZone() (string, error) {
+ output, err := exec.Command("timedatectl", "show", "--property=Timezone").Output()
+ if err != nil {
+ return "", err
+ }
+ // Remove prepended field and the newline
+ return strings.TrimPrefix(strings.TrimSuffix(string(output), "\n"), "Timezone="), nil
+}