Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions ctf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import jinja2
import yaml

from ctf import ENV
from ctf.logger import LOG

Expand Down Expand Up @@ -225,15 +224,12 @@ def find_ctf_root_directory() -> str:
if "CTF_ROOT_DIR" in ENV
else os.path.join(os.getcwd(), ".")
)
if not is_ctf_dir(path=path):
while path != (path := os.path.dirname(p=path)):
ctf_dir = is_ctf_dir(path)

while path != (path := os.path.dirname(p=path)):
dir = os.listdir(path=path)

if ".deploy" not in dir:
continue
if "challenges" not in dir:
continue
break
if ctf_dir:
break

if path == "/":
LOG.critical(
Expand All @@ -246,6 +242,16 @@ def find_ctf_root_directory() -> str:
return (__CTF_ROOT_DIRECTORY := path)


def is_ctf_dir(path):
ctf_dir = True
dir = os.listdir(path=path)
if ".deploy" not in dir:
ctf_dir = False
if "challenges" not in dir:
ctf_dir = False
return ctf_dir


def terraform_binary() -> str:
path = shutil.which(cmd="tofu")
if not path:
Expand Down
Loading