From 015f2e5a168b4ca291f0ca3dcb090de01f6d7f74 Mon Sep 17 00:00:00 2001 From: Enno Tensing Date: Tue, 22 Jul 2025 13:34:04 +0200 Subject: [PATCH] generate: container: Rename Container.crate to Container.create_container Since the environemt creation are now seperate methods, the create and create_container split is no longer needed. Signed-off-by: Enno Tensing --- generate/container.py | 54 +++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/generate/container.py b/generate/container.py index 7cb79ac..9db3b4e 100644 --- a/generate/container.py +++ b/generate/container.py @@ -421,33 +421,6 @@ class Container: self.volumes = Volume.from_json(volumes, logger) self.capabilities = Capability.from_json(capabilities, logger) - def create(self) -> str: - """Generate podman container create command.""" - cmd = f"# Create container {self.name}" - cmd += "podman container crate \\\n" - cmd += f"\t--name={self.name} \\\n" - if self.privileged: - cmd += "\t--privileged \\\n" - if self.replace: - cmd += "\t--replace \\\n" - if self.read_only: - cmd += "\t--read-only \\\n" - cmd += f"\t--restart={self.restart} \\\n" - cmd += f"\t--pull={self.pull_policy} \\\n" - cmd += f"\t{self.network.command()} \\\n" - cmd += f"\t{self.dns.command()} \\\n" - cmd += f"{self.ports.command()}" - if self.env is not None: - cmd += f"\t{self.env.command()} \\\n" - for secret in self.secrets: - cmd += f"\t{secret.command()} \\\n" - for volume in self.volumes: - cmd += f"\t{volume.command()} \\\n" - for capability in self.capabilities: - cmd += f"\t{capability.command()} \\\n" - cmd += f"\t{self.image.command()}\n" - return cmd - def create_volumes(self) -> str: """Generate podman volume create commands.""" if self.volumes is None: @@ -473,9 +446,30 @@ class Container: return self.env.create() def create_container(self) -> str: - """Create podman container.""" - cmd = "" - cmd += self.create() + """Generate podman container create command.""" + cmd = f"# Create container {self.name}" + cmd += "podman container crate \\\n" + cmd += f"\t--name={self.name} \\\n" + if self.privileged: + cmd += "\t--privileged \\\n" + if self.replace: + cmd += "\t--replace \\\n" + if self.read_only: + cmd += "\t--read-only \\\n" + cmd += f"\t--restart={self.restart} \\\n" + cmd += f"\t--pull={self.pull_policy} \\\n" + cmd += f"\t{self.network.command()} \\\n" + cmd += f"\t{self.dns.command()} \\\n" + cmd += f"{self.ports.command()}" + if self.env is not None: + cmd += f"\t{self.env.command()} \\\n" + for secret in self.secrets: + cmd += f"\t{secret.command()} \\\n" + for volume in self.volumes: + cmd += f"\t{volume.command()} \\\n" + for capability in self.capabilities: + cmd += f"\t{capability.command()} \\\n" + cmd += f"\t{self.image.command()}\n" return cmd def start_container(self) -> str: