@@ -80,6 +80,9 @@ def add_tracks_to_terraform_modules(
8080 {% for track in tracks %}
8181 module "track-{{ track }}" {
8282 source = "../challenges/{{ track }}/terraform"
83+ {% if build_container %}
84+ build_container = true
85+ {% endif %}
8386 {% if production %}
8487 deploy = "production"
8588 {% endif %}
@@ -96,6 +99,7 @@ def add_tracks_to_terraform_modules(
9699 fd .write (
97100 template .render (
98101 tracks = tracks - get_terraform_tracks_from_modules (),
102+ build_container = build_container ,
99103 production = production ,
100104 remote = remote ,
101105 )
@@ -145,6 +149,7 @@ def remove_tracks_from_terraform_modules(
145149 current_tracks = get_terraform_tracks_from_modules ()
146150
147151 create_terraform_modules_file (remote = remote , production = production )
152+ # TODO: loosing the build_container
148153 add_tracks_to_terraform_modules (
149154 tracks = (current_tracks - tracks ), remote = remote , production = production
150155 )
@@ -175,19 +180,16 @@ def remove_ctf_script_root_directory_from_path(path: str) -> str:
175180 return os .path .relpath (path = path , start = find_ctf_root_directory ())
176181
177182
183+ def load_yaml_file (file : str ) -> dict [str , Any ]:
184+ return yaml .safe_load (stream = open (file , mode = "r" , encoding = "utf-8" ))
185+
186+
178187def parse_track_yaml (track_name : str ) -> dict [str , Any ]:
179- r = yaml .safe_load (
180- stream = open (
181- file = (
182- p := os .path .join (
183- find_ctf_root_directory (), "challenges" , track_name , "track.yaml"
184- )
185- ),
186- mode = "r" ,
187- encoding = "utf-8" ,
188+ r = load_yaml_file (
189+ p := os .path .join (
190+ find_ctf_root_directory (), "challenges" , track_name , "track.yaml"
188191 )
189192 )
190-
191193 r ["file_location" ] = remove_ctf_script_root_directory_from_path (path = p )
192194
193195 return r
@@ -203,14 +205,11 @@ def parse_post_yamls(track_name: str) -> list[dict]:
203205 )
204206 ):
205207 if post .endswith (".yml" ) or post .endswith (".yaml" ):
206- with open (
207- file = os .path .join (posts_dir , post ), mode = "r" , encoding = "utf-8"
208- ) as f :
209- r = post_data = yaml .safe_load (stream = f )
210- r ["file_location" ] = remove_ctf_script_root_directory_from_path (
211- path = posts_dir
212- )
213- posts .append (post_data )
208+ r = load_yaml_file (os .path .join (posts_dir , post ))
209+ r ["file_location" ] = remove_ctf_script_root_directory_from_path (
210+ path = posts_dir
211+ )
212+ posts .append (r )
214213
215214 return posts
216215
0 commit comments