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:
parent
3908ab3013
commit
a8bf51020d
1 changed files with 4 additions and 0 deletions
|
@ -535,6 +535,7 @@ class Container:
|
|||
replace: bool
|
||||
restart: str
|
||||
pull_policy: str
|
||||
timezone: str
|
||||
network: Network
|
||||
dns: Dns
|
||||
ports: Ports
|
||||
|
@ -561,6 +562,7 @@ class Container:
|
|||
replace = maybe(json, "replace")
|
||||
pull_policy = maybe_or(json, "pull_policy", "always")
|
||||
restart = maybe_or(json, "restart", "no")
|
||||
timezone = maybe_or(json, "timezone", "local")
|
||||
network = maybe(json, "network")
|
||||
dns = maybe(json, "dns")
|
||||
ports = maybe(json, "ports")
|
||||
|
@ -576,6 +578,7 @@ class Container:
|
|||
self.replace = replace is not None and bool(replace)
|
||||
self.pull_policy = str(pull_policy)
|
||||
self.restart = str(restart)
|
||||
self.timezone = str(timezone)
|
||||
self.network = Network.from_json(network, logger)
|
||||
self.dns = Dns.from_json(dns, logger)
|
||||
self.ports = Ports.from_json(ports, logger)
|
||||
|
@ -624,6 +627,7 @@ class Container:
|
|||
cmd += "\t--read-only \\\n"
|
||||
cmd += f"\t--restart={self.restart} \\\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.dns.command()} \\\n"
|
||||
cmd += f"{self.ports.command()}"
|
||||
|
|
Loading…
Add table
Reference in a new issue