1
0
Fork 0

generate: container: Implement timezone support

Get timezone from the container config and fall back to local, which
uses the hosts timezone, if the config entry is missing or not a string.

Signed-off-by: Enno Tensing <tenno@suij.in>
This commit is contained in:
Enno Tensing 2025-07-30 11:07:21 +02:00
parent 3908ab3013
commit a8bf51020d
Signed by: tenno
GPG key ID: 95265603BD36E66C

View file

@ -535,6 +535,7 @@ class Container:
replace: bool replace: bool
restart: str restart: str
pull_policy: str pull_policy: str
timezone: str
network: Network network: Network
dns: Dns dns: Dns
ports: Ports ports: Ports
@ -561,6 +562,7 @@ class Container:
replace = maybe(json, "replace") replace = maybe(json, "replace")
pull_policy = maybe_or(json, "pull_policy", "always") pull_policy = maybe_or(json, "pull_policy", "always")
restart = maybe_or(json, "restart", "no") restart = maybe_or(json, "restart", "no")
timezone = maybe_or(json, "timezone", "local")
network = maybe(json, "network") network = maybe(json, "network")
dns = maybe(json, "dns") dns = maybe(json, "dns")
ports = maybe(json, "ports") ports = maybe(json, "ports")
@ -576,6 +578,7 @@ class Container:
self.replace = replace is not None and bool(replace) self.replace = replace is not None and bool(replace)
self.pull_policy = str(pull_policy) self.pull_policy = str(pull_policy)
self.restart = str(restart) self.restart = str(restart)
self.timezone = str(timezone)
self.network = Network.from_json(network, logger) self.network = Network.from_json(network, logger)
self.dns = Dns.from_json(dns, logger) self.dns = Dns.from_json(dns, logger)
self.ports = Ports.from_json(ports, logger) self.ports = Ports.from_json(ports, logger)
@ -624,6 +627,7 @@ class Container:
cmd += "\t--read-only \\\n" cmd += "\t--read-only \\\n"
cmd += f"\t--restart={self.restart} \\\n" cmd += f"\t--restart={self.restart} \\\n"
cmd += f"\t--pull={self.pull_policy} \\\n" cmd += f"\t--pull={self.pull_policy} \\\n"
cmd += f"\t--tz={self.timezone} \\\n"
cmd += f"\t{self.network.command()} \\\n" cmd += f"\t{self.network.command()} \\\n"
cmd += f"\t{self.dns.command()} \\\n" cmd += f"\t{self.dns.command()} \\\n"
cmd += f"{self.ports.command()}" cmd += f"{self.ports.command()}"