1
0
Fork 0

Compare commits

...

3 commits

Author SHA1 Message Date
fb6aadb63c
generate: generate: Bump to 0.0.9
Signed-off-by: Enno Tensing <tenno@suij.in>
2025-08-07 21:04:14 +02:00
2476d72192
generate: container: Update Network.from_json and Environment.command
Signed-off-by: Enno Tensing <tenno@suij.in>
2025-08-07 21:03:33 +02:00
ec61600b87
generate: container: s/container crate/container create
Signed-off-by: Enno Tensing <tenno@suij.in>
2025-08-07 21:00:39 +02:00
2 changed files with 7 additions and 6 deletions

View file

@ -382,7 +382,7 @@ class Environment:
"""Option for podman container create.""" """Option for podman container create."""
if len(self.variables) == 0: if len(self.variables) == 0:
return "" return ""
return f"--env-file={self.file}" return f"\t--env-file={self.file} \\\n"
def create(self) -> str: def create(self) -> str:
"""Create env file.""" """Create env file."""
@ -480,10 +480,12 @@ class Network:
return cls("", []) return cls("", [])
mode = maybe(val, "mode") mode = maybe(val, "mode")
options = maybe(val, "options") options = maybe(val, "options")
if mode is None or options is None or not isinstance(options, list): if mode is None:
err = "Network configuration is missing or has malformed elements!" err = "Network configuration is missing or has malformed elements!"
logger.log_error(err) logger.log_error(err)
return cls("", []) return cls("", [])
if options is None or not isinstance(options, list):
return cls(str(mode), [])
return cls(str(mode), options) return cls(str(mode), options)
def command(self) -> str: def command(self) -> str:
@ -675,7 +677,7 @@ class Container:
def create_container(self) -> str: def create_container(self) -> str:
"""Generate podman container create command.""" """Generate podman container create command."""
cmd = f"# Create container {self.name}\n" cmd = f"# Create container {self.name}\n"
cmd += "podman container crate \\\n" cmd += "podman container create \\\n"
cmd += f"\t--name={self.name} \\\n" cmd += f"\t--name={self.name} \\\n"
if self.privileged: if self.privileged:
cmd += "\t--privileged \\\n" cmd += "\t--privileged \\\n"
@ -689,8 +691,7 @@ class Container:
cmd += f"{self.network.command()}" cmd += f"{self.network.command()}"
cmd += f"{self.dns.command()}" cmd += f"{self.dns.command()}"
cmd += f"{self.ports.command()}" cmd += f"{self.ports.command()}"
if self.env is not None: cmd += f"{self.env.command()}"
cmd += f"\t{self.env.command()} \\\n"
for secret in self.secrets: for secret in self.secrets:
cmd += f"\t{secret.command()} \\\n" cmd += f"\t{secret.command()} \\\n"
for volume in self.volumes: for volume in self.volumes:

View file

@ -14,7 +14,7 @@ from pathlib import Path
from container import ConfigError, Container from container import ConfigError, Container
from log import Log from log import Log
GENERATE_VERSION = "0.0.8" GENERATE_VERSION = "0.0.9"
HEADER = f"""#!/bin/sh HEADER = f"""#!/bin/sh
# This script was generated by containerctl v{GENERATE_VERSION} # This script was generated by containerctl v{GENERATE_VERSION}
# Report bugs with _this script_ to <tenno+containerctl@suij.in> # Report bugs with _this script_ to <tenno+containerctl@suij.in>