Skip to content

Commit eb42308

Browse files
committed
associate build result info with its corresponding challenge
Signed-off-by: Robert Detjens <github@detjens.dev>
1 parent 75b35bd commit eb42308

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/builder/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ pub fn build_challenges(
5151
profile_name: &str,
5252
push: bool,
5353
extract_artifacts: bool,
54-
) -> Result<Vec<BuildResult>> {
54+
) -> Result<Vec<(&ChallengeConfig, BuildResult)>> {
5555
enabled_challenges(profile_name)?
56-
.iter()
57-
.map(|chal| build_challenge(profile_name, chal, push, extract_artifacts))
56+
.into_iter()
57+
.map(|chal| build_challenge(profile_name, chal, push, extract_artifacts).map(|r| (chal, r)))
5858
.collect::<Result<_>>()
5959
}
6060

src/deploy/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ use crate::builder::BuildResult;
88
use crate::clients::{bucket_client, kube_client};
99
use crate::cluster_setup as setup;
1010
use crate::configparser::config::ProfileConfig;
11-
use crate::configparser::{enabled_challenges, get_config, get_profile_config};
11+
use crate::configparser::{enabled_challenges, get_config, get_profile_config, ChallengeConfig};
1212

1313
/// Render challenge manifest templates and apply to cluster
14-
pub async fn deploy_challenges(profile_name: &str, build_results: &[BuildResult]) -> Result<()> {
14+
pub async fn deploy_challenges(
15+
profile_name: &str,
16+
build_results: &[(&ChallengeConfig, BuildResult)],
17+
) -> Result<()> {
1518
let profile = get_profile_config(profile_name)?;
1619
let enabled_challenges = enabled_challenges(profile_name)?;
1720

@@ -22,7 +25,7 @@ pub async fn deploy_challenges(profile_name: &str, build_results: &[BuildResult]
2225
/// Returns urls of upload files.
2326
pub async fn upload_assets(
2427
profile_name: &str,
25-
build_results: &[BuildResult],
28+
build_results: &[(&ChallengeConfig, BuildResult)],
2629
) -> Result<Vec<String>> {
2730
let profile = get_profile_config(profile_name)?;
2831
let enabled_challenges = enabled_challenges(profile_name)?;
@@ -36,7 +39,10 @@ pub async fn upload_assets(
3639
}
3740

3841
/// Sync deployed challenges with rCTF frontend
39-
pub async fn update_frontend(profile_name: &str, build_results: &[BuildResult]) -> Result<()> {
42+
pub async fn update_frontend(
43+
profile_name: &str,
44+
build_results: &[(&ChallengeConfig, BuildResult)],
45+
) -> Result<()> {
4046
let profile = get_profile_config(profile_name)?;
4147
let enabled_challenges = enabled_challenges(profile_name)?;
4248

0 commit comments

Comments
 (0)