Skip to content

Commit

Permalink
Remove unnecessary layer env logic
Browse files Browse the repository at this point in the history
As noted in the removed comment: It doesn't seem necessary as the layer env isn't explicitly modified as far as I can tell -- but perhaps there was some trait API magic happening I'm not familiar with?
  • Loading branch information
runesoerensen committed Sep 17, 2024
1 parent 56004d7 commit e0733ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
7 changes: 3 additions & 4 deletions buildpacks/ruby/src/layers/metrics_agent_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use flate2::read::GzDecoder;
use libcnb::additional_buildpack_binary_path;
use libcnb::data::layer_name;
use libcnb::layer::{
CachedLayerDefinition, EmptyLayerCause, InvalidMetadataAction, LayerRef, LayerState,
RestoredLayerAction,
CachedLayerDefinition, EmptyLayerCause, InvalidMetadataAction, LayerState, RestoredLayerAction,
};
use libherokubuildpack::digest::sha256;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -63,7 +62,7 @@ pub(crate) fn handle_metrics_agent_layer(
// TODO: Replace when implementing bullet_stream. Included with original comment:
// force the layer to be called within a Section logging context, not necessary but it's safer
_in_section_logger: &dyn SectionLogger,
) -> libcnb::Result<LayerRef<RubyBuildpack, (), String>, RubyBuildpackError> {
) -> libcnb::Result<(), RubyBuildpackError> {
let layer_ref = context.cached_layer(
layer_name!("metrics_agent"),
CachedLayerDefinition {
Expand Down Expand Up @@ -117,7 +116,7 @@ pub(crate) fn handle_metrics_agent_layer(
})?;
}
}
Ok(layer_ref)
Ok(())
}

fn write_execd_script(
Expand Down
26 changes: 9 additions & 17 deletions buildpacks/ruby/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,29 +131,21 @@ impl Buildpack for RubyBuildpack {
let ruby_version = gemfile_lock.resolve_ruby("3.1.3");

// ## Install metrics agent
(logger, env) = {
logger = {
let section = logger.section("Metrics agent");
if lockfile_contents.contains("barnes") {
let layer_ref = layers::metrics_agent_install::handle_metrics_agent_layer(
layers::metrics_agent_install::handle_metrics_agent_layer(
&context,
section.as_ref(),
)?;
(
section.end_section(),
// TODO: This should likely be removed (also eliminating the need for the `handle_metrics_agent_layer` function to return a `LayerRef`)?
// Included the logic here for reference, but it doesn't seem necessary (the layer env isn't explicitly modified as far as I can tell, but perhaps there's some trait API magic happening I'm not familiar with?).
layer_ref.read_env()?.apply(Scope::Build, &env),
)
section.end_section()
} else {
(
section
.step(&format!(
"Skipping install ({barnes} gem not found)",
barnes = fmt::value("barnes")
))
.end_section(),
env,
)
section
.step(&format!(
"Skipping install ({barnes} gem not found)",
barnes = fmt::value("barnes")
))
.end_section()
}
};

Expand Down

0 comments on commit e0733ed

Please sign in to comment.