diff --git a/buildpacks/ruby/src/layers/metrics_agent_install.rs b/buildpacks/ruby/src/layers/metrics_agent_install.rs index d6594290..7aad6b40 100644 --- a/buildpacks/ruby/src/layers/metrics_agent_install.rs +++ b/buildpacks/ruby/src/layers/metrics_agent_install.rs @@ -82,8 +82,8 @@ impl Layer for MetricsAgentInstall { let bin_dir = layer_path.join("bin"); let mut timer = self.section.say_with_inline_timer("Downloading"); - let agentmon = install_agentmon(&bin_dir).map_err(RubyBuildpackError::MetricsAgentError)?; - + let agentmon = + agentmon_download(&bin_dir).map_err(RubyBuildpackError::MetricsAgentError)?; timer.done(); self.section.say("Writing scripts"); @@ -196,14 +196,13 @@ fn write_execd_script( Ok(execd) } -fn install_agentmon(dir: &Path) -> Result { - let agentmon = download_untar(DOWNLOAD_URL, &dir).map(|_| dir.join("agentmon"))?; +fn agentmon_download(dir: &Path) -> Result { + download_to_dir(DOWNLOAD_URL, dir)?; - chmod_plus_x(&agentmon).map_err(MetricsAgentInstallError::PermissionError)?; - Ok(agentmon) + Ok(dir.join("agentmon")) } -fn download_untar( +fn download_to_dir( url: impl AsRef, destination: &Path, ) -> Result<(), MetricsAgentInstallError> { @@ -214,6 +213,9 @@ fn download_untar( untar(agentmon_tgz.path(), destination)?; + chmod_plus_x(&destination.join("agentmon")) + .map_err(MetricsAgentInstallError::PermissionError)?; + Ok(()) }