change creations conditions format
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Mathieu Broillet 2023-06-11 22:11:16 +02:00
parent f452c2ef09
commit 9005685ab5
Signed by: mathieu
GPG Key ID: A08E484FE95074C1

View File

@ -19,15 +19,12 @@ def are_all_conditions_met(lxc):
result = []
for condition in conditions:
if condition["type"] == "file":
result.append(Path(condition["path"]).is_file())
elif condition["type"] == "folder":
result.append(Path(condition["path"]).is_dir())
elif condition["type"] == "program":
result.append(lxc.run_command("which " + condition["program"], only_code=True) == 0)
else:
raise Exception(f"Unknown condition type {condition['type']}")
for file in conditions['files']:
result.append(Path(file).is_file())
for folder in conditions['folders']:
result.append(Path(folder).is_dir())
for program in conditions['programs']:
result.append(lxc.run_command("which " + program, only_code=True) == 0)
if all(result):
logging.info(f"All creations conditions met for LXC {lxc.lxc_id}, running deploy steps...")
@ -44,14 +41,11 @@ def run_creations_steps(lxc):
:param lxc: lxc
:return: None
"""
creation = lxc.get_creation()
creation_steps = creation["creation_steps"]
for step in creation_steps:
if step["type"] == "command":
lxc.run_command(step["command"])
elif step["type"] == "script":
lxc.run_script(step["script"])
else:
raise Exception(f"Unknown creation step type {step['type']}")
match step["type"]:
case "file":
if type(step["path"]) is list:
pass