summaryrefslogtreecommitdiffstats
path: root/src/endpoint/configured.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-11-07 10:05:50 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-11-07 14:53:15 +0100
commit545383b30c9e3660ac43038102d4b94b11b31993 (patch)
treeb046421dc25cb0fbb71bb310514c92839ca7b404 /src/endpoint/configured.rs
parent59dbc0b70ac0dd18ce0ff8d8dab0f8351f4239ab (diff)
Implement artifact copying to container
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/endpoint/configured.rs')
-rw-r--r--src/endpoint/configured.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs
index 7d353d6..998e925 100644
--- a/src/endpoint/configured.rs
+++ b/src/endpoint/configured.rs
@@ -208,6 +208,31 @@ impl Endpoint {
.build();
let container = self.docker.containers().get(&container_id);
+ { // Copy all Path artifacts to the container
+ job.resources()
+ .into_iter()
+ .filter_map(JobResource::artifact)
+ .cloned()
+ .map(|art| async {
+ let artifact_file_name = art.path().file_name()
+ .ok_or_else(|| anyhow!("BUG: artifact {} is not a file", art.path().display()))?;
+ let destination = PathBuf::from("/inputs/").join(artifact_file_name);
+ trace!("Copying {} to container: {}:{}", art.path().display(), container_id, destination.display());
+ let buf = tokio::fs::read(art.path())
+ .await
+ .map(Vec::from)
+ .map_err(Error::from)?;
+
+ drop(art); // ensure `art` is moved into closure
+ container.copy_file_into(destination, &buf)
+ .await
+ .map_err(Error::from)
+ })
+ .collect::<futures::stream::FuturesUnordered<_>>()
+ .collect::<Result<Vec<_>>>()
+ .await?;
+ }
+
container
.copy_file_into(script_path, script)
.map(|r| r.with_context(|| anyhow!("Copying the script into the container {} on '{}'", container_id, self.name)))