diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-03-10 11:49:10 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-03-10 11:49:10 +0100 |
commit | fd05d457f8c89a6da8ca241a972254c02a150fe7 (patch) | |
tree | 6ab6dd5fc7aab1605bd3e80e17460b0cf6d7bb24 /src/endpoint | |
parent | 7022b92db47341da9e93c044666d77fce477e404 (diff) | |
parent | 64c01a9b3337088fcee07a9d69e4f1c3e60aad5c (diff) |
Merge branch 'pathes-to-absolute'
Diffstat (limited to 'src/endpoint')
-rw-r--r-- | src/endpoint/configured.rs | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs index 219b6f9..7265dd6 100644 --- a/src/endpoint/configured.rs +++ b/src/endpoint/configured.rs @@ -395,8 +395,9 @@ impl<'a> PreparedContainer<'a> { let create_info = Self::build_container(endpoint, &job).await?; let container = endpoint.docker.containers().get(&create_info.id); - let (cpysrc, cpyart, cpyscr) = tokio::join!( + let (cpysrc, cpypch, cpyart, cpyscr) = tokio::join!( Self::copy_source_to_container(&container, &job), + Self::copy_patches_to_container(&container, &job), Self::copy_artifacts_to_container(&container, &job, staging_store, &release_stores), Self::copy_script_to_container(&container, &script) ); @@ -409,6 +410,14 @@ impl<'a> PreparedContainer<'a> { ) })?; + let _ = cpypch.with_context(|| { + anyhow!( + "Copying the patches to container {} on '{}'", + create_info.id, + endpoint.name + ) + })?; + let _ = cpyart.with_context(|| { anyhow!( "Copying the artifacts to container {} on '{}'", @@ -517,6 +526,44 @@ impl<'a> PreparedContainer<'a> { .map_err(Error::from) } + async fn copy_patches_to_container<'ca>( + container: &Container<'ca>, + job: &RunnableJob, + ) -> Result<()> { + use tokio::io::AsyncReadExt; + + log::debug!("Copying patches to container: {:?}", job.package().patches()); + job.package() + .patches() + .iter() + .map(|patch| async move { + let destination = PathBuf::from("/patches").join(patch); + trace!("Copying patch {} to container at /patches/{}", patch.display(), destination.display()); + + let mut buf = vec![]; + tokio::fs::OpenOptions::new() + .create(false) + .create_new(false) + .append(false) + .write(false) + .read(true) + .open(&patch) + .await + .with_context(|| anyhow!("Getting patch file: {}", patch.display()))? + .read_to_end(&mut buf) + .await + .with_context(|| anyhow!("Reading file {}", patch.display()))?; + + let _ = container.copy_file_into(destination, &buf).await?; + Ok(()) + }) + .collect::<futures::stream::FuturesUnordered<_>>() + .collect::<Result<()>>() + .await + .with_context(|| anyhow!("Copying patches to container {}", container.id())) + .map_err(Error::from) + } + async fn copy_artifacts_to_container<'ca>( container: &Container<'ca>, job: &RunnableJob, |