1
0
Fork 0

Compare commits

..

No commits in common. "4ce53cb20b99e2340f3769c5efdfe87e6d74c794" and "64b797d18d2b7dda3d661f521b2f0d619e3f1e49" have entirely different histories.

4 changed files with 37 additions and 28 deletions

View file

@ -101,8 +101,19 @@
]
},
"env": {
"type": "object"
}
"type": "object",
"properties": {
"FOO": {
"type": "string"
},
"MAN_WIDTH": {
"type": "string"
}
},
"required": [
"FOO",
"MAN_WIDTH"
]
},
"secrets": {
"type": "object"
@ -138,6 +149,18 @@
},
"required": [
"name",
"image"
"image",
"privileged",
"read_only",
"replace",
"pull_policy",
"restart",
"network",
"dns",
"ports",
"env",
"secrets",
"volumes",
"capabilities"
]
}
}

View file

@ -42,7 +42,7 @@
}
},
"volumes": {
"etc": "/etc:ro,noexec",
"etc": "/etc",
"var": "/var"
},
"capabilities": {

View file

@ -72,7 +72,7 @@ class Volume:
cmd = f"# Create volume {self.name}\n"
cmd += f"if ! podman volume exists '{self.name}' 2> /dev/null\n"
cmd += "then\n"
cmd += f"\tpodman volume create '{self.name}'\n"
cmd += "\tpodman volume create '{self.name}'\n"
cmd += "fi\n"
return cmd
@ -123,9 +123,7 @@ class Secret:
def command(self) -> str:
"""Option for podman container create."""
cmd = (
f"--secret {self.name},:"
f"type={self.secret_type},"
f"target={self.target}"
f"--secret {self.name},type={self.secret_type},target={self.target}"
)
# Not a password, ruff...
if self.secret_type == "mount" and self.options != "": # noqa: S105
@ -190,7 +188,7 @@ class Environment:
cmd = f"# Remove env-file {self.file}\n"
cmd += f"if [ -e '{self.file}' ]\n"
cmd += "then\n"
cmd += f"\trm '{self.file}'\n"
cmd += "\trm '{self.file}'\n"
cmd += "fi\n"
return cmd

View file

@ -14,14 +14,6 @@ from pathlib import Path
from container import ConfigError, Container
from log import Log
GENERATE_VERSION = "0.0.2"
HEADER = f"""#!/bin/sh
# This script was generated by containerctl v{GENERATE_VERSION}
# Report bugs with _this script_ to <tenno+containerctl@suij.in>
"""
def load_container_config(file: Path, log: Log) -> dict | None:
"""Load a container config."""
@ -106,17 +98,13 @@ def main() -> None:
Path(base).mkdir()
for script, method in scripts.items():
s = Path(f"{base}/{script}")
script_content = ""
if script == "create":
script_content += ct.create_volumes()
script_content += ct.create_secrets()
script_content += ct.create_environment()
script_content += method()
if script_content == "":
script_content = "true"
with s.open("w+", encoding="utf-8") as f:
f.write(HEADER)
f.write(script_content)
f.write("#!/bin/sh\n")
if script == "create":
f.write(ct.create_volumes())
f.write(ct.create_secrets())
f.write(ct.create_environment())
f.write(method())
s.chmod(
stat.S_IRWXU
| stat.S_IRGRP