change creations conditions format
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f452c2ef09
commit
9005685ab5
@ -19,15 +19,12 @@ def are_all_conditions_met(lxc):
|
|||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
for condition in conditions:
|
for file in conditions['files']:
|
||||||
if condition["type"] == "file":
|
result.append(Path(file).is_file())
|
||||||
result.append(Path(condition["path"]).is_file())
|
for folder in conditions['folders']:
|
||||||
elif condition["type"] == "folder":
|
result.append(Path(folder).is_dir())
|
||||||
result.append(Path(condition["path"]).is_dir())
|
for program in conditions['programs']:
|
||||||
elif condition["type"] == "program":
|
result.append(lxc.run_command("which " + program, only_code=True) == 0)
|
||||||
result.append(lxc.run_command("which " + condition["program"], only_code=True) == 0)
|
|
||||||
else:
|
|
||||||
raise Exception(f"Unknown condition type {condition['type']}")
|
|
||||||
|
|
||||||
if all(result):
|
if all(result):
|
||||||
logging.info(f"All creations conditions met for LXC {lxc.lxc_id}, running deploy steps...")
|
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
|
:param lxc: lxc
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
creation = lxc.get_creation()
|
creation = lxc.get_creation()
|
||||||
creation_steps = creation["creation_steps"]
|
creation_steps = creation["creation_steps"]
|
||||||
|
|
||||||
for step in creation_steps:
|
for step in creation_steps:
|
||||||
if step["type"] == "command":
|
match step["type"]:
|
||||||
lxc.run_command(step["command"])
|
case "file":
|
||||||
elif step["type"] == "script":
|
if type(step["path"]) is list:
|
||||||
lxc.run_script(step["script"])
|
pass
|
||||||
else:
|
|
||||||
raise Exception(f"Unknown creation step type {step['type']}")
|
|
||||||
|
Loading…
Reference in New Issue
Block a user