Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct Layer API #814

Merged
merged 29 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
44a01a9
Add struct layer API
Malax Mar 12, 2024
0d93533
Add deprecation annotations
Malax Mar 12, 2024
ec9067d
Move existing layer API to separate module, move shared code
Malax Mar 13, 2024
18bf79e
Make compilation succeed again
Malax Apr 8, 2024
10c2caf
Fix RustDoc
Malax Apr 8, 2024
7bc68d0
Add `#![allow(deprecated)]` to example and test buildpacks
Malax Apr 9, 2024
194035d
Remove no longer necessary clippy allow
Malax Apr 9, 2024
3fad3c4
Fix replace_layer_types visibility
Malax Apr 9, 2024
239c01c
Properly expose layer errors
Malax Apr 9, 2024
96d010d
Move shared tests for read_layer to shared module
Malax Apr 9, 2024
9d2ee42
Move write_layer to shared code
Malax Apr 9, 2024
9984be3
Fix WriteLayerError Display impl
Malax Apr 10, 2024
408000d
Rename execute to handle
Malax Apr 10, 2024
b0d5aed
Apply miscellaneous polish
Malax Jun 13, 2024
8171c64
Add struct_api handling tests
Malax Jun 14, 2024
fc81889
Rename LayerContents to LayerState, InspectExisting to InspectRestored
Malax Jun 14, 2024
21ad86b
Update CHANGELOG
Malax Jun 14, 2024
c900b88
Fix typos
Malax Jun 17, 2024
de6351b
Fix CHANGELOG entry
Malax Jun 17, 2024
06d4668
Rename LayerRef methods
Malax Jun 17, 2024
bfcb0ce
Rename CachedLayerDefinition callbacks
Malax Jun 17, 2024
e317deb
RustDoc update
Malax Jun 18, 2024
603f0c5
Renamed EmptyLayerCause variants
Malax Jun 18, 2024
3f2f832
Explain IntoAction in cached_layer example
Malax Jun 18, 2024
400b1b3
Explain IntoAction cached_layer docs
Malax Jun 18, 2024
a4877e4
Add uncached_layer example
Malax Jun 18, 2024
2625478
Rename remaining inspect_action related names
Malax Jun 18, 2024
11b6ce1
Add LayerRef::read_env
Malax Jun 18, 2024
57683ad
RustDoc improvements
Malax Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- `libcnb`:
- A new API for working with layers has been added. See the `BuildContext::cached_layer` and `BuildContext::uncached_layer` docs for examples of how to use this API. ([#814](https://github.com/heroku/libcnb.rs/pull/814))

### Changed

- `libcnb`:
- The `Layer` trait and related types and functions have been deprecated. Please migrate to the new API. ([#814](https://github.com/heroku/libcnb.rs/pull/814))
- Errors related to layers have been restructured. While this is technically a breaking change, buildpacks usually don't have to be modified in practice. ([#814](https://github.com/heroku/libcnb.rs/pull/814))

### Fixed

- `libcnb-data`:
Expand Down
4 changes: 4 additions & 0 deletions examples/execd/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// This example uses the older trait Layer API. The example will be updated to the newer API
// before the next libcnb.rs release.
#![allow(deprecated)]

mod layer;

use crate::layer::ExecDLayer;
Expand Down
382 changes: 373 additions & 9 deletions libcnb/src/build.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions libcnb/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::data::launch::ProcessTypeError;
use crate::layer::HandleLayerError;
use crate::layer::LayerError;
use libcnb_common::toml_file::TomlFileError;
use std::fmt::Debug;

Expand All @@ -11,8 +11,8 @@ pub type Result<T, E> = std::result::Result<T, Error<E>>;
/// An error that occurred during buildpack execution.
#[derive(thiserror::Error, Debug)]
pub enum Error<E> {
#[error("HandleLayer error: {0}")]
HandleLayerError(#[from] HandleLayerError),
#[error("Layer error: {0}")]
LayerError(#[from] LayerError),

#[error("Process type error: {0}")]
ProcessTypeError(#[from] ProcessTypeError),
Expand Down
15 changes: 9 additions & 6 deletions libcnb/src/layer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
//! Provides types and helpers to work with layers.

mod handling;
mod public_interface;
pub(crate) mod shared;
pub(crate) mod struct_api;
pub(crate) mod trait_api;

#[cfg(test)]
mod tests;
pub use shared::DeleteLayerError;
pub use shared::LayerError;
pub use shared::ReadLayerError;
pub use shared::WriteLayerError;

pub(crate) use handling::*;
pub use public_interface::*;
pub use struct_api::*;
pub use trait_api::*;
Loading