diff --git a/src/builder/artifacts.rs b/src/builder/artifacts.rs index 21fdf5c..e3b447f 100644 --- a/src/builder/artifacts.rs +++ b/src/builder/artifacts.rs @@ -51,28 +51,15 @@ async fn extract_files( files ); - // try_join_all( - // files - // .iter() - // .enumerate() // need index to avoid copy collisions - // .map(|(i, f)| docker::copy_file(container, f, None)), - // ) - // .await - - let mut results = vec![]; - - for f in files.iter() { - let from = Path::new(f); - // if no rename is given, use basename of `from` as target path - // these files should go in chal directory, so pass it in + try_join_all(files.iter().map(|f| { + let from = PathBuf::from(f); let to = chal .directory .join(from.file_name().unwrap().to_str().unwrap()); - results.push(copy_file(container, from, &to).await?); - } - - Ok(results) + copy_file(container, from, to) + })) + .await } /// Extract one file from container and rename diff --git a/src/builder/docker.rs b/src/builder/docker.rs index 35d95f1..92021fd 100644 --- a/src/builder/docker.rs +++ b/src/builder/docker.rs @@ -148,8 +148,8 @@ pub async fn remove_container(name: &str) -> Result<()> { Ok(()) } -pub async fn copy_file(container_id: &str, from: &Path, to: &Path) -> Result { - info!("copying {container_id}:{from:?} to {to:?}"); +pub async fn copy_file(container_id: &str, from: PathBuf, to: PathBuf) -> Result { + debug!("copying {container_id}:{from:?} to {to:?}"); let client = client().await?; @@ -182,7 +182,7 @@ pub async fn copy_file(container_id: &str, from: &Path, to: &Path) -> Result>>()?; - debug!("extracted assets: {:?}", assets); + info!("extracted artifacts: {:?}", assets); } Ok(built_tags) } - -// /// Push passed tags to registry -// pub fn push_tags(tags: Vec) -> Result> { -// let config = get_config()?; - -// let built_tags = tags -// .iter() -// .map(|tag| { -// push_image(tag, &config.registry.build) -// .with_context(|| format!("error pushing image {tag}")) -// }) -// .collect::>()?; - -// Ok(built_tags) -// } - -// /// Extract any assets needed from given challenges -// pub fn extract_assets( -// profile_name: &str, -// built_chals: Vec<&ChallengeConfig>, -// ) -> Result> { -// built_chals.iter().map(|chal| { -// chal.provide.iter().filter(|p| p.from.is_some()).map(|p| { -// assets::extract_asset(p, container) -// }) - -// // let tag = format!( -// // image_tag!(), -// // registry = config.registry.domain, -// // challenge = chal.name, -// // container = p.name, -// // profile = profile_name -// // ); -// }); - -// Ok(vec![]) -// }