Skip to content

Commit 1909641

Browse files
committed
Fix linting errors and rebase
1 parent f0e6f4b commit 1909641

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

ctfcli/core/challenge.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,10 @@ def lint(self, skip_hadolint=False, flag_format="flag{") -> bool:
885885
issues["fields"].append(f"challenge.yml is missing required field: {field}")
886886

887887
# Check that the image field and Dockerfile match
888-
if (self.challenge_directory / "Dockerfile").is_file() and challenge.get("image", "") not in [".", "__compose__"]:
888+
if (self.challenge_directory / "Dockerfile").is_file() and challenge.get("image", "") not in [
889+
".",
890+
"__compose__",
891+
]:
889892
issues["dockerfile"].append("Dockerfile exists but image field does not point to it or compose")
890893

891894
# Check that Dockerfile exists and is EXPOSE'ing a port

ctfcli/core/deployment/registry.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def deploy(self, skip_login=False, *args, **kwargs) -> DeploymentResult:
2626
return DeploymentResult(False)
2727

2828
if self.challenge.image.compose:
29-
click.secho(
30-
"Cannot use registry deployer with __compose__ stacks", fg="red"
31-
)
29+
click.secho("Cannot use registry deployer with __compose__ stacks", fg="red")
3230
return DeploymentResult(False)
3331

3432
# resolve a location for the image push

ctfcli/core/deployment/ssh.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def deploy(self, *args, **kwargs) -> DeploymentResult:
2727
def _deploy_compose_stack(self, *args, **kwargs) -> DeploymentResult:
2828
host_url = urlparse(self.host)
2929
target_path = str(host_url.path)
30-
if target_path == '/': # Don't put challenges in the root of the filesystem.
31-
target_path = ''
32-
elif target_path == '//': # If you really want to, add a second slash as part of your path: ssh://1.1.1.1//
33-
target_path = '/'
34-
elif target_path.startswith('/~/'): # Support relative paths by starting your path with /~/
35-
target_path = target_path.removeprefix('/~/')
30+
if target_path == "/": # Don't put challenges in the root of the filesystem.
31+
target_path = ""
32+
elif target_path == "//": # If you really want to, add a second slash as part of your path: ssh://1.1.1.1//
33+
target_path = "/"
34+
elif target_path.startswith("/~/"): # Support relative paths by starting your path with /~/
35+
target_path = target_path.removeprefix("/~/")
3636
try:
3737
subprocess.run(["ssh", host_url.netloc, f"mkdir -p '{target_path}/'"], check=True)
3838
subprocess.run(
@@ -47,8 +47,7 @@ def _deploy_compose_stack(self, *args, **kwargs) -> DeploymentResult:
4747
[
4848
"ssh",
4949
host_url.netloc,
50-
f"cd {remote_path} && "
51-
"docker compose up -d --build --remove-orphans -y",
50+
f"cd {remote_path} && " "docker compose up -d --build --remove-orphans -y",
5251
],
5352
check=True,
5453
)

ctfcli/core/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ class InvalidChallengeFile(ChallengeException):
3838
class RemoteChallengeNotFound(ChallengeException):
3939
pass
4040

41+
4142
class ImageException(ChallengeException):
4243
pass
4344

45+
4446
class InvalidComposeOperation(ImageException):
4547
pass
4648

0 commit comments

Comments
 (0)