1
0
Fork 0

genreate: container: Add accounting support to Container.create

Add support for accouting to __init__ and create.

Signed-off-by: Enno Tensing <tenno@suij.in>
This commit is contained in:
Enno Tensing 2025-07-30 10:31:02 +02:00
parent 2a7bb0115c
commit 93245d5bc6
Signed by: tenno
GPG key ID: 95265603BD36E66C

View file

@ -531,6 +531,7 @@ class Container:
secrets: list | None secrets: list | None
volumes: list | None volumes: list | None
capabilities: list | None capabilities: list | None
accounting: Accounting
def __init__(self, json: dict, logger: Log | None = None) -> None: def __init__(self, json: dict, logger: Log | None = None) -> None:
"""Create from JSON.""" """Create from JSON."""
@ -560,6 +561,7 @@ class Container:
secrets = maybe(json, "secrets") secrets = maybe(json, "secrets")
volumes = maybe(json, "volumes") volumes = maybe(json, "volumes")
capabilities = maybe(json, "capabilities") capabilities = maybe(json, "capabilities")
accounting = maybe(json, "accounting")
self.name = str(name) self.name = str(name)
self.image = Image.from_json(image, logger) self.image = Image.from_json(image, logger)
self.privileged = privileged is not None and bool(privileged) self.privileged = privileged is not None and bool(privileged)
@ -576,6 +578,7 @@ class Container:
self.secrets = Secret.from_json(secrets, logger) self.secrets = Secret.from_json(secrets, logger)
self.volumes = Volume.from_json(volumes, logger) self.volumes = Volume.from_json(volumes, logger)
self.capabilities = Capability.from_json(capabilities, logger) self.capabilities = Capability.from_json(capabilities, logger)
self.accounting = Accounting.from_json(accounting, logger)
def create_volumes(self) -> str: def create_volumes(self) -> str:
"""Generate podman volume create commands.""" """Generate podman volume create commands."""
@ -625,6 +628,7 @@ class Container:
cmd += f"\t{volume.command()} \\\n" cmd += f"\t{volume.command()} \\\n"
for capability in self.capabilities: for capability in self.capabilities:
cmd += f"\t{capability.command()} \\\n" cmd += f"\t{capability.command()} \\\n"
cmd += f"{self.accounting.command()}"
cmd += f"\t{self.image.command()}\n" cmd += f"\t{self.image.command()}\n"
return cmd return cmd