Browse Source

Remove needless cloning of node `env` field for building

tags/v0.3.12-rc0
Philipp Oppermann 9 months ago
parent
commit
e31b2a3489
Failed to extract signature
3 changed files with 17 additions and 19 deletions
  1. +14
    -16
      binaries/cli/src/build.rs
  2. +1
    -1
      binaries/daemon/src/spawn.rs
  3. +2
    -2
      libraries/core/src/build.rs

+ 14
- 16
binaries/cli/src/build.rs View File

@@ -23,15 +23,15 @@ pub fn build(dataflow: String, uv: bool) -> eyre::Result<()> {
match node.kind()? {
dora_core::descriptor::NodeKind::Standard(_) => {
if let Some(build) = &node.build {
run_build_command(build, working_dir, uv, node.env.clone()).with_context(
|| format!("build command failed for standard node `{}`", node.id),
)?
run_build_command(build, working_dir, uv, &node.env).with_context(|| {
format!("build command failed for standard node `{}`", node.id)
})?
}
}
dora_core::descriptor::NodeKind::Runtime(runtime_node) => {
for operator in &runtime_node.operators {
if let Some(build) = &operator.config.build {
run_build_command(build, working_dir, uv, node.env.clone()).with_context(
run_build_command(build, working_dir, uv, &node.env).with_context(
|| {
format!(
"build command failed for operator `{}/{}`",
@@ -44,22 +44,20 @@ pub fn build(dataflow: String, uv: bool) -> eyre::Result<()> {
}
dora_core::descriptor::NodeKind::Custom(custom_node) => {
if let Some(build) = &custom_node.build {
run_build_command(build, working_dir, uv, node.env.clone()).with_context(
|| format!("build command failed for custom node `{}`", node.id),
)?
run_build_command(build, working_dir, uv, &node.env).with_context(|| {
format!("build command failed for custom node `{}`", node.id)
})?
}
}
dora_core::descriptor::NodeKind::Operator(operator) => {
if let Some(build) = &operator.config.build {
run_build_command(build, working_dir, uv, node.env.clone()).with_context(
|| {
format!(
"build command failed for operator `{}/{}`",
node.id,
operator.id.as_ref().unwrap_or(&default_op_id)
)
},
)?
run_build_command(build, working_dir, uv, &node.env).with_context(|| {
format!(
"build command failed for operator `{}/{}`",
node.id,
operator.id.as_ref().unwrap_or(&default_op_id)
)
})?
}
}
}


+ 1
- 1
binaries/daemon/src/spawn.rs View File

@@ -608,7 +608,7 @@ impl Spawner<'_> {
let uv = self.uv;
let node_env = node_env.clone();
let task = tokio::task::spawn_blocking(move || {
run_build_command(&build, &clone_dir, uv, node_env).context("build command failed")
run_build_command(&build, &clone_dir, uv, &node_env).context("build command failed")
});
task.await??;
}


+ 2
- 2
libraries/core/src/build.rs View File

@@ -7,7 +7,7 @@ pub fn run_build_command(
build: &str,
working_dir: &Path,
uv: bool,
envs: Option<BTreeMap<String, EnvValue>>,
envs: &Option<BTreeMap<String, EnvValue>>,
) -> eyre::Result<()> {
let lines = build.lines().collect::<Vec<_>>();
for build_line in lines {
@@ -26,7 +26,7 @@ pub fn run_build_command(
cmd.args(split);

// Inject Environment Variables
if let Some(envs) = envs.clone() {
if let Some(envs) = envs {
for (key, value) in envs {
let value = value.to_string();
cmd.env(key, value);


Loading…
Cancel
Save