From a86495ea6fdd56519afc65586c0f7f9c0f4f5ab2 Mon Sep 17 00:00:00 2001
From: Brent Baude <bbaude@redhat.com>
Date: Tue, 14 Dec 2021 14:16:09 -0600
Subject: 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>
---
 cmd/podman/machine/init.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'cmd/podman')

diff --git a/cmd/podman/machine/init.go b/cmd/podman/machine/init.go
index adde887f7..bee6844df 100644
--- a/cmd/podman/machine/init.go
+++ b/cmd/podman/machine/init.go
@@ -38,7 +38,6 @@ func init() {
 	})
 	flags := initCmd.Flags()
 	cfg := registry.PodmanConfig()
-
 	cpusFlagName := "cpus"
 	flags.Uint64Var(
 		&initOpts.CPUS,
@@ -69,6 +68,13 @@ func init() {
 		"now", false,
 		"Start machine now",
 	)
+	timezoneFlagName := "timezone"
+	defaultTz := cfg.TZ()
+	if len(defaultTz) < 1 {
+		defaultTz = "local"
+	}
+	flags.StringVar(&initOpts.TimeZone, timezoneFlagName, defaultTz, "Set timezone")
+	_ = initCmd.RegisterFlagCompletionFunc(timezoneFlagName, completion.AutocompleteDefault)
 
 	ImagePathFlagName := "image-path"
 	flags.StringVar(&initOpts.ImagePath, ImagePathFlagName, cfg.Machine.Image, "Path to qcow image")
-- 
cgit v1.2.3-54-g00ecf