Skip to content

Commit 6250a47

Browse files
authored
Merge pull request #28 from nsec/fixes
Fixed multiple issues
2 parents ebbce11 + f87db81 commit 6250a47

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ jobs:
4747
4848
- name: Copy CTF files
4949
run: |
50-
mkdir -p test-ctf/challenges
51-
cp -r ./challenges test-ctf/
52-
ls -al test-ctf/
53-
ls -al test-ctf/challenges
50+
mkdir -p test-ctf/challenges
51+
cp -r ./challenges test-ctf/
52+
ls -al test-ctf/
53+
ls -al test-ctf/challenges
5454
5555
- name: ctf version
5656
working-directory: test-ctf
@@ -196,10 +196,3 @@ jobs:
196196
ctf redeploy --production --tracks mock-track-python-service
197197
[ "$(incus list --all-projects -cn -fcsv | wc -l)" -eq 2 ] || exit 1
198198
ctf destroy --force
199-
200-
- name: Check deployment results
201-
run: |
202-
incus project list
203-
incus network zone record list ctf
204-
incus network list --all-projects
205-
incus list --all-projects

ctf/deploy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def run_ansible_playbook(remote: str, production: bool, track: str, path: str) -
230230
LOG.info(msg=f"Running common yaml with ansible for track {track}...")
231231
ansible_args = [
232232
"ansible-playbook",
233-
"../../../.deploy/common.yaml",
233+
os.path.join(CTF_ROOT_DIRECTORY, ".deploy", "common.yaml"),
234234
"-i",
235235
"inventory",
236236
] + extra_args

ctf/destroy.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def destroy(
5757

5858
terraform_tracks = get_terraform_tracks_from_modules()
5959

60+
total_deployed_tracks = len(terraform_tracks)
61+
6062
r = (
6163
subprocess.run(
6264
args=["incus", "project", "get-current"],
@@ -110,7 +112,11 @@ def destroy(
110112
terraform_binary(),
111113
"destroy",
112114
"-auto-approve",
113-
*[f"-target=module.track-{track}" for track in terraform_tracks],
115+
*(
116+
[] # If every track needs to be destroyed, destroy everything including the network zone as well.
117+
if total_deployed_tracks == len(terraform_tracks)
118+
else [f"-target=module.track-{track}" for track in terraform_tracks]
119+
),
114120
],
115121
cwd=os.path.join(CTF_ROOT_DIRECTORY, ".deploy"),
116122
check=False,
@@ -194,6 +200,7 @@ def destroy(
194200
capture_output=True,
195201
env=ENV,
196202
)
203+
197204
remove_tracks_from_terraform_modules(
198205
tracks=terraform_tracks,
199206
remote=remote,

ctf/templates/main.tf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ resource "incus_project" "this" {
88
config = {
99
"features.images" = "false"
1010
"user.contacts.dev" = join(", ", local.track.contacts.dev)
11-
"user.contacts.qa" = join(", ", local.track.contacts.qa)
12-
"user.contacts.support" = join(", ", local.track.contacts.support)
11+
"user.contacts.qa" = length(local.track.contacts.qa) > 0 ? join(", ", local.track.contacts.qa) : null
12+
"user.contacts.support" = length(local.track.contacts.support) > 0 ? join(", ", local.track.contacts.support) : null
1313
}
1414
}
1515

ctf/templates/track.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ services:
3939
# Each service name must be unique for a given instance (container/VM).
4040
- name: {% if data.template == "python-service" %}HTTP-5000{% else %}HTTP{% endif %}
4141
# Name of the container or VM
42-
instance: main-site
42+
instance: {{ data.name }}
4343
# The IPv6 address was randomly generated from the MAC Address (hwaddr) and the subnets defined in main.tf.
4444
# If you need other machines, you can choose another MAC Address and get the IPv6 from the MAC AND the IPv6 subnet ({{ data.ipv6_subnet }}) at https://eui64-calc.princelle.org/
4545
address: '{{ data.full_ipv6_address }}'

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies = [
1818
"setuptools",
1919
"typer==0.16.0",
2020
]
21-
version = "2.1.0"
21+
version = "3.0.0"
2222
classifiers = [
2323
"Programming Language :: Python :: 3",
2424
"Operating System :: OS Independent",

0 commit comments

Comments
 (0)