heroku / libcnb.rs

A framework for writing Cloud Native Buildpacks in Rust
BSD 3-Clause "New" or "Revised" License
35 stars 6 forks source link

BuildConfig: Want to get values that I set #825

Open schneems opened 4 months ago

schneems commented 4 months ago

Currently the values on BuildConfig are pub(crate) so I cannot access values that I've set:

pub struct BuildConfig {
    pub(crate) app_dir: PathBuf,
    pub(crate) cargo_profile: CargoProfile,
    pub(crate) target_triple: String,
    pub(crate) builder_name: String,
    pub(crate) buildpacks: Vec<BuildpackReference>,
    pub(crate) env: HashMap<String, String>,
    pub(crate) app_dir_preprocessor: Option<Rc<dyn Fn(PathBuf)>>,
    pub(crate) expected_pack_result: PackResult,
}

I'm wanting to inspect the builder_name to write logic like https://github.com/heroku/buildpacks-python/blob/de378063c83e1eec6302e79f93f189162b5bbbbf/tests/mod.rs#L31-L38. I would prefer to pass in a BuildConfig to a specific function and return a BuildConfig (or mutate a passed in build config, either way). Currently I cannot do this, because that value is not readable.

Options

Additional thoughts

While I'm looking at BuildConfig I think we should also make it Debug in addition to Clone