Skip to content

Commit

Permalink
Always write the script, only conditionally download
Browse files Browse the repository at this point in the history
  • Loading branch information
schneems committed Jun 17, 2024
1 parent 25be647 commit 64ca3f4
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions buildpacks/ruby/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,35 +173,28 @@ impl Buildpack for RubyBuildpack {
section = section.step("Using cached metrics agent");
}
libcnb::layer::LayerState::Empty { .. } => {
let bin_dir = metrics_layer.path().join("bin");

let timer = section.step_timed("Downloading");
let agentmon_path =
layers::metrics_agent_install::install_agentmon(&bin_dir)
.map_err(RubyBuildpackError::MetricsAgentError)?;
section = timer.finish_timed_step();

section = section.step("Writing scripts");
let execd = layers::metrics_agent_install::write_execd_script(
&agentmon_path,
&metrics_layer.path(),
let timer = section.step_timed("Downloading metrics agent");
layers::metrics_agent_install::install_agentmon(
&metrics_layer.path().join("bin"),
)
.map_err(RubyBuildpackError::MetricsAgentError)?;

metrics_layer.replace_metadata(
layers::metrics_agent_install::Metadata {
download_url: Some(
layers::metrics_agent_install::DOWNLOAD_URL.to_string(),
),
},
)?;

metrics_layer
.replace_exec_d_programs(vec![("spawn_metrics_agent", execd)])?;
section = timer.finish_timed_step();
}
};

// Get the new PATH/env from the layer?
let agentmon_path = metrics_layer.path().join("bin").join("agentmon");
section = section.step("Writing scripts");
let execd = layers::metrics_agent_install::write_execd_script(
&agentmon_path,
&metrics_layer.path(),
)
.map_err(RubyBuildpackError::MetricsAgentError)?;

metrics_layer.replace_metadata(layers::metrics_agent_install::Metadata {
download_url: Some(layers::metrics_agent_install::DOWNLOAD_URL.to_string()),
})?;

metrics_layer.replace_exec_d_programs(vec![("spawn_metrics_agent", execd)])?;

(
section.end_section(),
Expand Down

0 comments on commit 64ca3f4

Please sign in to comment.