From dd9a07cfe42f589a21af14d5585ead857429c931 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Thu, 21 Sep 2023 14:56:45 +0100 Subject: [PATCH] Switch to the new "component" vs "composite" buildpack terminology Upstream has now officially defined names for what we had previously been calling meta-buildpacks vs single buildpacks: https://github.com/buildpacks/spec/blob/main/buildpack.md#cnb-terminology All types, docs and internal functions have been renamed to match. Fixes #639. GUS-W-14161652. --- CHANGELOG.md | 4 +- .../composite-one}/buildpack.toml | 4 +- .../composite-one}/package.toml | 0 libcnb-cargo/tests/integration_test.rs | 35 ++++---- libcnb-data/src/buildpack/mod.rs | 79 +++++++++++-------- libcnb-data/src/package_descriptor.rs | 7 +- .../src/buildpack_dependency_graph.rs | 6 +- libcnb-package/src/buildpack_kind.rs | 6 +- libcnb-package/src/package.rs | 26 +++--- libcnb-test/README.md | 2 +- .../buildpack.toml | 4 +- .../package.toml | 0 libcnb-test/tests/integration_test.rs | 4 +- libcnb/src/build.rs | 4 +- libcnb/src/detect.rs | 4 +- libcnb/src/layer/tests.rs | 4 +- 16 files changed, 106 insertions(+), 83 deletions(-) rename libcnb-cargo/tests/fixtures/multiple_buildpacks/{meta-buildpacks/meta-one => composite-buildpacks/composite-one}/buildpack.toml (87%) rename libcnb-cargo/tests/fixtures/multiple_buildpacks/{meta-buildpacks/meta-one => composite-buildpacks/composite-one}/package.toml (100%) rename libcnb-test/tests/fixtures/buildpacks/{libcnb-test-meta => libcnb-test-composite}/buildpack.toml (82%) rename libcnb-test/tests/fixtures/buildpacks/{libcnb-test-meta => libcnb-test-composite}/package.toml (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9415673..5bdcb25f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,13 +13,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `libcnb-data`: - `ExecDProgramOutputKey`, `ProcessType`, `LayerName`, `BuildpackId` and `StackId` now implement `Ord` and `PartialOrd`. ([#658](https://github.com/heroku/libcnb.rs/pull/658)) - - Add `generic::GenericMetadata` as a generic metadata type. Also makes it the default for `BuildpackDescriptor`, `SingleBuildpackDescriptor`, `MetaBuildpackDescriptor` and `LayerContentMetadata`. ([#664](https://github.com/heroku/libcnb.rs/pull/664)) + - Added `generic::GenericMetadata` as a generic metadata type. Also makes it the default for `BuildpackDescriptor`, `SingleBuildpackDescriptor`, `CompositeBuildpackDescriptor` and `LayerContentMetadata`. ([#664](https://github.com/heroku/libcnb.rs/pull/664)) - `libcnb-test`: - Added the `BuildpackReference::WorkspaceBuildpack` enum variant. This allows for the testing of any libcnb.rs or composite buildpack in the Cargo workspace, instead of only the buildpack of the current crate. **Note: The testing of composite buildpacks requires `pack` CLI version `>=0.30`.** ([#666](https://github.com/heroku/libcnb.rs/pull/666)) ### Changed - Renamed `libcnb-data`'s `Buildpackage` to `PackageDescriptor`. This required changes in many other names across multiple libcnb.rs crates for consistency. See the PR diff for details, but renames should be straightforward and unsurprising. ([#656](https://github.com/heroku/libcnb.rs/pull/656)) +- `libcnb-data`: + - Renamed multiple types to match the new composite vs component buildpack [upstream terminology](https://github.com/buildpacks/spec/blob/main/buildpack.md#cnb-terminology). Renamed `SingleBuildpackDescriptor` to `ComponentBuildpackDescriptor`, `MetaBuildpackDescriptor` to `CompositeBuildpackDescriptor` and `BuildpackDescriptor::{Single,Meta}` to `BuildpackDescriptor::{Component,Composite}`. ([#682](https://github.com/heroku/libcnb.rs/pull/682)) - `libcnb-cargo`: - No longer outputs paths for non-libcnb.rs and non-meta buildpacks. ([#657](https://github.com/heroku/libcnb.rs/pull/657)) - Build output for humans changed slightly, output intended for machines/scripting didn't change. ([#657](https://github.com/heroku/libcnb.rs/pull/657)) diff --git a/libcnb-cargo/tests/fixtures/multiple_buildpacks/meta-buildpacks/meta-one/buildpack.toml b/libcnb-cargo/tests/fixtures/multiple_buildpacks/composite-buildpacks/composite-one/buildpack.toml similarity index 87% rename from libcnb-cargo/tests/fixtures/multiple_buildpacks/meta-buildpacks/meta-one/buildpack.toml rename to libcnb-cargo/tests/fixtures/multiple_buildpacks/composite-buildpacks/composite-one/buildpack.toml index 01b40f88..241ebe51 100644 --- a/libcnb-cargo/tests/fixtures/multiple_buildpacks/meta-buildpacks/meta-one/buildpack.toml +++ b/libcnb-cargo/tests/fixtures/multiple_buildpacks/composite-buildpacks/composite-one/buildpack.toml @@ -1,8 +1,8 @@ api = "0.8" [buildpack] -id = "multiple-buildpacks/meta-one" -name = "Meta-buildpack Test" +id = "multiple-buildpacks/composite-one" +name = "Composite Buildpack Test" version = "0.0.0" homepage = "https://example.com" description = "Official test example" diff --git a/libcnb-cargo/tests/fixtures/multiple_buildpacks/meta-buildpacks/meta-one/package.toml b/libcnb-cargo/tests/fixtures/multiple_buildpacks/composite-buildpacks/composite-one/package.toml similarity index 100% rename from libcnb-cargo/tests/fixtures/multiple_buildpacks/meta-buildpacks/meta-one/package.toml rename to libcnb-cargo/tests/fixtures/multiple_buildpacks/composite-buildpacks/composite-one/package.toml diff --git a/libcnb-cargo/tests/integration_test.rs b/libcnb-cargo/tests/integration_test.rs index 680933a7..a1c27383 100644 --- a/libcnb-cargo/tests/integration_test.rs +++ b/libcnb-cargo/tests/integration_test.rs @@ -42,12 +42,17 @@ fn package_buildpack_in_single_buildpack_project() { #[test] #[ignore = "integration test"] -fn package_single_meta_buildpack_in_monorepo_buildpack_project() { +fn package_single_composite_buildpack_in_monorepo_buildpack_project() { let fixture_dir = copy_fixture_to_temp_dir("multiple_buildpacks").unwrap(); let output = Command::new(CARGO_LIBCNB_BINARY_UNDER_TEST) .args(["libcnb", "package", "--release"]) - .current_dir(fixture_dir.path().join("meta-buildpacks").join("meta-one")) + .current_dir( + fixture_dir + .path() + .join("composite-buildpacks") + .join("composite-one"), + ) .output() .unwrap(); @@ -61,14 +66,14 @@ fn package_single_meta_buildpack_in_monorepo_buildpack_project() { String::from_utf8_lossy(&output.stdout), format!( "{}\n", - packaged_buildpack_dir_resolver(&buildpack_id!("multiple-buildpacks/meta-one")) + packaged_buildpack_dir_resolver(&buildpack_id!("multiple-buildpacks/composite-one")) .to_string_lossy() ) ); - validate_packaged_meta_buildpack( - &packaged_buildpack_dir_resolver(&buildpack_id!("multiple-buildpacks/meta-one")), - &buildpack_id!("multiple-buildpacks/meta-one"), + validate_packaged_composite_buildpack( + &packaged_buildpack_dir_resolver(&buildpack_id!("multiple-buildpacks/composite-one")), + &buildpack_id!("multiple-buildpacks/composite-one"), &[ PackageDescriptorDependency::try_from(packaged_buildpack_dir_resolver(&buildpack_id!( "multiple-buildpacks/one" @@ -148,7 +153,9 @@ fn package_all_buildpacks_in_monorepo_buildpack_project() { format!( "{}\n", [ - packaged_buildpack_dir_resolver(&buildpack_id!("multiple-buildpacks/meta-one")), + packaged_buildpack_dir_resolver(&buildpack_id!( + "multiple-buildpacks/composite-one" + )), packaged_buildpack_dir_resolver(&buildpack_id!("multiple-buildpacks/one")), packaged_buildpack_dir_resolver(&buildpack_id!("multiple-buildpacks/two")), ] @@ -157,9 +164,9 @@ fn package_all_buildpacks_in_monorepo_buildpack_project() { ) ); - validate_packaged_meta_buildpack( - &packaged_buildpack_dir_resolver(&buildpack_id!("multiple-buildpacks/meta-one")), - &buildpack_id!("multiple-buildpacks/meta-one"), + validate_packaged_composite_buildpack( + &packaged_buildpack_dir_resolver(&buildpack_id!("multiple-buildpacks/composite-one")), + &buildpack_id!("multiple-buildpacks/composite-one"), &[ PackageDescriptorDependency::try_from(packaged_buildpack_dir_resolver(&buildpack_id!( "multiple-buildpacks/one" @@ -185,7 +192,7 @@ fn package_all_buildpacks_in_monorepo_buildpack_project() { #[test] #[ignore = "integration test"] -fn package_non_libcnb_buildpack_in_meta_buildpack_project() { +fn package_non_libcnb_buildpack_in_composite_buildpack_project() { let fixture_dir = copy_fixture_to_temp_dir("multiple_buildpacks").unwrap(); let output = Command::new(CARGO_LIBCNB_BINARY_UNDER_TEST) @@ -227,7 +234,7 @@ fn package_command_respects_ignore_files() { // The `ignore` crate supports `.ignore` files. So this first `cargo libcnb package` execution // just sanity checks that our ignore rules will be respected. let ignore_file = fixture_dir.path().join(".ignore"); - fs::write(&ignore_file, "meta-buildpacks\nbuildpacks\n").unwrap(); + fs::write(&ignore_file, "composite-buildpacks\nbuildpacks\n").unwrap(); let output = Command::new(CARGO_LIBCNB_BINARY_UNDER_TEST) .args(["libcnb", "package", "--release"]) @@ -251,7 +258,7 @@ fn package_command_respects_ignore_files() { // in a git repository will be respected. fs::create_dir(fixture_dir.path().join(".git")).unwrap(); let ignore_file = fixture_dir.path().join(".gitignore"); - fs::write(ignore_file, "meta-buildpacks\nbuildpacks\n").unwrap(); + fs::write(ignore_file, "composite-buildpacks\nbuildpacks\n").unwrap(); let output = Command::new(CARGO_LIBCNB_BINARY_UNDER_TEST) .args(["libcnb", "package", "--release"]) @@ -281,7 +288,7 @@ fn validate_packaged_buildpack(packaged_buildpack_dir: &Path, buildpack_id: &Bui ); } -fn validate_packaged_meta_buildpack( +fn validate_packaged_composite_buildpack( packaged_buildpack_dir: &Path, buildpack_id: &BuildpackId, expected_package_descriptor_dependencies: &[PackageDescriptorDependency], diff --git a/libcnb-data/src/buildpack/mod.rs b/libcnb-data/src/buildpack/mod.rs index c1346314..950e17c9 100644 --- a/libcnb-data/src/buildpack/mod.rs +++ b/libcnb-data/src/buildpack/mod.rs @@ -19,8 +19,9 @@ pub use version::*; /// For parsing of [buildpack.toml](https://github.com/buildpacks/spec/blob/main/buildpack.md#buildpacktoml-toml) /// files when support for multiple types of buildpack is required. /// -/// When a specific buildpack type is expected, use [`SingleBuildpackDescriptor`] or [`MetaBuildpackDescriptor`] directly instead, -/// since it allows for more detailed error messages if parsing fails. +/// When a specific buildpack type is expected, use [`ComponentBuildpackDescriptor`] or +/// [`CompositeBuildpackDescriptor`] directly instead, since they allow for more detailed +/// error messages if parsing fails. /// /// # Example: /// ``` @@ -49,40 +50,41 @@ pub use version::*; /// toml::from_str::(toml_str) /// .expect("buildpack.toml did not match a known type!"); /// match buildpack_descriptor { -/// BuildpackDescriptor::Single(buildpack) => { -/// println!("Found buildpack: {}", buildpack.buildpack.id); +/// BuildpackDescriptor::Component(buildpack) => { +/// println!("Found component buildpack: {}", buildpack.buildpack.id); /// } -/// BuildpackDescriptor::Meta(buildpack) => { -/// println!("Found meta-buildpack: {}", buildpack.buildpack.id); +/// BuildpackDescriptor::Composite(buildpack) => { +/// println!("Found composite buildpack: {}", buildpack.buildpack.id); /// } /// }; /// ``` #[derive(Deserialize, Debug)] #[serde(untagged)] pub enum BuildpackDescriptor { - Single(SingleBuildpackDescriptor), - Meta(MetaBuildpackDescriptor), + Component(ComponentBuildpackDescriptor), + Composite(CompositeBuildpackDescriptor), } impl BuildpackDescriptor { pub fn buildpack(&self) -> &Buildpack { match self { - BuildpackDescriptor::Single(descriptor) => &descriptor.buildpack, - BuildpackDescriptor::Meta(descriptor) => &descriptor.buildpack, + BuildpackDescriptor::Component(descriptor) => &descriptor.buildpack, + BuildpackDescriptor::Composite(descriptor) => &descriptor.buildpack, } } } -/// Data structure for the Buildpack descriptor (buildpack.toml) of a single buildpack. +/// Data structure for the Buildpack descriptor (buildpack.toml) of a component buildpack. /// /// Representation of [buildpack.toml](https://github.com/buildpacks/spec/blob/main/buildpack.md#buildpacktoml-toml) -/// when the buildpack is a single buildpack that implements the Buildpack Interface (ie: not a meta-buildpack). +/// when the buildpack is a component buildpack - one that implements the Buildpack Interface +/// (ie: contains `/bin/detect` and `/bin/build` executables). /// /// If support for multiple buildpack types is required, use [`BuildpackDescriptor`] instead. /// /// # Example: /// ``` -/// use libcnb_data::buildpack::{SingleBuildpackDescriptor, Stack}; +/// use libcnb_data::buildpack::{ComponentBuildpackDescriptor, Stack}; /// use libcnb_data::buildpack_id; /// /// let toml_str = r#" @@ -105,29 +107,31 @@ impl BuildpackDescriptor { /// "#; /// /// let buildpack_descriptor = -/// toml::from_str::(toml_str).unwrap(); +/// toml::from_str::(toml_str).unwrap(); /// assert_eq!(buildpack_descriptor.buildpack.id, buildpack_id!("foo/bar")); /// assert_eq!(buildpack_descriptor.stacks, [Stack::Any]); /// ``` #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] -pub struct SingleBuildpackDescriptor { +pub struct ComponentBuildpackDescriptor { pub api: BuildpackApi, pub buildpack: Buildpack, pub stacks: Vec, pub metadata: BM, } -/// Data structure for the Buildpack descriptor (buildpack.toml) of a meta-buildpack. +/// Data structure for the Buildpack descriptor (buildpack.toml) of a composite buildpack. /// /// Representation of [buildpack.toml](https://github.com/buildpacks/spec/blob/main/buildpack.md#buildpacktoml-toml) -/// when the buildpack is a meta-buildpack. +/// when the buildpack is a composite buildpack - one that does not implement the Buildpack Interface +/// itself (ie: does not contain `/bin/detect` and `/bin/build` executables) but instead references +/// other buildpacks via an order definition. /// /// If support for multiple buildpack types is required, use [`BuildpackDescriptor`] instead. /// /// # Example: /// ``` -/// use libcnb_data::buildpack::MetaBuildpackDescriptor; +/// use libcnb_data::buildpack::CompositeBuildpackDescriptor; /// use libcnb_data::buildpack_id; /// /// let toml_str = r#" @@ -153,12 +157,12 @@ pub struct SingleBuildpackDescriptor { /// "#; /// /// let buildpack_descriptor = -/// toml::from_str::(toml_str).unwrap(); +/// toml::from_str::(toml_str).unwrap(); /// assert_eq!(buildpack_descriptor.buildpack.id, buildpack_id!("foo/bar")); /// ``` #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] -pub struct MetaBuildpackDescriptor { +pub struct CompositeBuildpackDescriptor { pub api: BuildpackApi, pub buildpack: Buildpack, pub order: Vec, @@ -216,7 +220,7 @@ mod tests { #[test] #[allow(clippy::too_many_lines)] - fn deserialize_singlebuildpack() { + fn deserialize_component_buildpack() { let toml_str = r#" api = "0.9" @@ -261,7 +265,8 @@ id = "*" checksum = "abc123" "#; - let buildpack_descriptor = toml::from_str::(toml_str).unwrap(); + let buildpack_descriptor = + toml::from_str::(toml_str).unwrap(); assert_eq!( buildpack_descriptor.api, @@ -343,7 +348,7 @@ checksum = "abc123" } #[test] - fn deserialize_metabuildpack() { + fn deserialize_composite_buildpack() { let toml_str = r#" api = "0.9" @@ -381,7 +386,8 @@ optional = true checksum = "abc123" "#; - let buildpack_descriptor = toml::from_str::(toml_str).unwrap(); + let buildpack_descriptor = + toml::from_str::(toml_str).unwrap(); assert_eq!( buildpack_descriptor.api, @@ -453,7 +459,7 @@ checksum = "abc123" } #[test] - fn deserialize_minimal_singlebuildpack() { + fn deserialize_minimal_component_buildpack() { let toml_str = r#" api = "0.9" @@ -465,7 +471,8 @@ version = "0.0.1" id = "*" "#; - let buildpack_descriptor = toml::from_str::(toml_str).unwrap(); + let buildpack_descriptor = + toml::from_str::(toml_str).unwrap(); assert_eq!( buildpack_descriptor.api, @@ -494,7 +501,7 @@ id = "*" } #[test] - fn deserialize_minimal_metabuildpack() { + fn deserialize_minimal_composite_buildpack() { let toml_str = r#" api = "0.9" @@ -509,7 +516,8 @@ id = "foo/bar" version = "0.0.1" "#; - let buildpack_descriptor = toml::from_str::(toml_str).unwrap(); + let buildpack_descriptor = + toml::from_str::(toml_str).unwrap(); assert_eq!( buildpack_descriptor.api, @@ -546,7 +554,7 @@ version = "0.0.1" } #[test] - fn deserialize_buildpackdescriptor_single() { + fn deserialize_buildpackdescriptor_component() { let toml_str = r#" api = "0.9" @@ -561,12 +569,12 @@ id = "*" let buildpack_descriptor = toml::from_str::(toml_str).unwrap(); assert!(matches!( buildpack_descriptor, - BuildpackDescriptor::Single(_) + BuildpackDescriptor::Component(_) )); } #[test] - fn deserialize_buildpackdescriptor_meta() { + fn deserialize_buildpackdescriptor_composite() { let toml_str = r#" api = "0.9" @@ -582,7 +590,10 @@ version = "0.0.1" "#; let buildpack_descriptor = toml::from_str::(toml_str).unwrap(); - assert!(matches!(buildpack_descriptor, BuildpackDescriptor::Meta(_))); + assert!(matches!( + buildpack_descriptor, + BuildpackDescriptor::Composite(_) + )); } #[test] @@ -610,10 +621,10 @@ version = "0.0.1" "data did not match any variant of untagged enum BuildpackDescriptor\n" ); - let err = toml::from_str::(toml_str).unwrap_err(); + let err = toml::from_str::(toml_str).unwrap_err(); assert!(err.to_string().contains("unknown field `order`")); - let err = toml::from_str::(toml_str).unwrap_err(); + let err = toml::from_str::(toml_str).unwrap_err(); assert!(err.to_string().contains("unknown field `stacks`")); } } diff --git a/libcnb-data/src/package_descriptor.rs b/libcnb-data/src/package_descriptor.rs index 6a5c7b12..89172787 100644 --- a/libcnb-data/src/package_descriptor.rs +++ b/libcnb-data/src/package_descriptor.rs @@ -37,7 +37,9 @@ pub struct PackageDescriptor { /// The buildpack to package. pub buildpack: PackageDescriptorBuildpackReference, - /// A set of dependent buildpack locations, for packaging a meta-buildpack. Each dependent buildpack location must correspond to an order group within the meta-buildpack being packaged. + /// A set of dependent buildpack locations, for packaging a composite buildpack. + /// + /// Each dependent buildpack location must correspond to an order group within the composite buildpack being packaged. #[serde(default)] pub dependencies: Vec, @@ -62,6 +64,7 @@ impl Default for PackageDescriptor { #[serde(deny_unknown_fields)] pub struct PackageDescriptorBuildpackReference { /// A URL or path to an archive, or a path to a directory. + /// /// If the `uri` field is a relative path it will be relative to the `package.toml` file. #[serde(deserialize_with = "deserialize_uri_reference")] #[serde(serialize_with = "serialize_uri_reference")] @@ -83,7 +86,7 @@ impl TryFrom<&str> for PackageDescriptorBuildpackReference { } } -/// A dependent buildpack location for packaging a meta-buildpack. +/// A dependent buildpack location for packaging a composite buildpack. #[derive(Debug, Deserialize, Serialize, Eq, PartialEq, Clone)] #[serde(deny_unknown_fields)] pub struct PackageDescriptorDependency { diff --git a/libcnb-package/src/buildpack_dependency_graph.rs b/libcnb-package/src/buildpack_dependency_graph.rs index 385d8548..ae2901f0 100644 --- a/libcnb-package/src/buildpack_dependency_graph.rs +++ b/libcnb-package/src/buildpack_dependency_graph.rs @@ -12,9 +12,9 @@ use petgraph::Graph; use std::convert::Infallible; use std::path::{Path, PathBuf}; -/// Creates a dependency graph of libcnb.rs and meta buildpacks in a directory. +/// Creates a dependency graph of libcnb.rs and composite buildpacks in a directory. /// -/// Buildpacks that aren't implemented with libcnb.rs or aren't meta-buildpacks will not be part +/// Buildpacks that aren't implemented with libcnb.rs or aren't composite buildpacks will not be part /// of the dependency graph. Examples buildpacks that are not included are docker image URLs or /// directories containing CNBs written in bash. /// @@ -36,7 +36,7 @@ pub fn build_libcnb_buildpacks_dependency_graph( .filter(|buildpack_directory| { matches!( determine_buildpack_kind(buildpack_directory), - Some(BuildpackKind::LibCnbRs | BuildpackKind::Meta) + Some(BuildpackKind::LibCnbRs | BuildpackKind::Composite) ) }) .map(|buildpack_directory| { diff --git a/libcnb-package/src/buildpack_kind.rs b/libcnb-package/src/buildpack_kind.rs index d5ab9bb6..2873fbc8 100644 --- a/libcnb-package/src/buildpack_kind.rs +++ b/libcnb-package/src/buildpack_kind.rs @@ -7,19 +7,19 @@ pub fn determine_buildpack_kind(buildpack_dir: &Path) -> Option { read_toml_file::(buildpack_dir.join("buildpack.toml")) .ok() .map(|buildpack_descriptor| match buildpack_descriptor { - BuildpackDescriptor::Single(_) => { + BuildpackDescriptor::Component(_) => { if buildpack_dir.join("Cargo.toml").is_file() { BuildpackKind::LibCnbRs } else { BuildpackKind::Other } } - BuildpackDescriptor::Meta(_) => BuildpackKind::Meta, + BuildpackDescriptor::Composite(_) => BuildpackKind::Composite, }) } pub enum BuildpackKind { + Composite, LibCnbRs, - Meta, Other, } diff --git a/libcnb-package/src/package.rs b/libcnb-package/src/package.rs index 0bc794c9..5f502167 100644 --- a/libcnb-package/src/package.rs +++ b/libcnb-package/src/package.rs @@ -11,7 +11,7 @@ use std::ffi::OsString; use std::fs; use std::path::{Path, PathBuf}; -/// Packages either a libcnb.rs or a meta-buildpack. +/// Packages either a libcnb.rs or a composite buildpack. /// /// # Errors /// @@ -33,9 +33,9 @@ pub fn package_buildpack( destination, ) .map_err(PackageBuildpackError::PackageLibcnbBuildpackError), - Some(BuildpackKind::Meta) => { - package_meta_buildpack(buildpack_directory, destination, dependencies) - .map_err(PackageBuildpackError::PackageMetaBuildpackError) + Some(BuildpackKind::Composite) => { + package_composite_buildpack(buildpack_directory, destination, dependencies) + .map_err(PackageBuildpackError::PackageCompositeBuildpackError) } _ => Err(PackageBuildpackError::UnsupportedBuildpack), } @@ -44,7 +44,7 @@ pub fn package_buildpack( #[derive(thiserror::Error, Debug)] pub enum PackageBuildpackError { #[error("{0}")] - PackageMetaBuildpackError(PackageMetaBuildpackError), + PackageCompositeBuildpackError(PackageCompositeBuildpackError), #[error("{0}")] PackageLibcnbBuildpackError(PackageLibcnbBuildpackError), #[error("Buildpack is not supported to be packaged")] @@ -103,7 +103,7 @@ pub enum PackageLibcnbBuildpackError { CargoMetadataError(cargo_metadata::Error), } -/// Packages a meta-buildpack. +/// Packages a composite buildpack. /// /// Packaging consists of copying `buildpack.toml` as well as `package.toml` to the given /// destination path. @@ -116,40 +116,40 @@ pub enum PackageLibcnbBuildpackError { /// /// Returns `Err` if a `libcnb:` URI refers to a buildpack not in `buildpack_paths` or packaging /// otherwise failed (i.e. IO errors). -pub fn package_meta_buildpack( +pub fn package_composite_buildpack( buildpack_directory: &Path, destination: &Path, buildpack_paths: &BTreeMap, -) -> Result<(), PackageMetaBuildpackError> { +) -> Result<(), PackageCompositeBuildpackError> { fs::copy( buildpack_directory.join("buildpack.toml"), destination.join("buildpack.toml"), ) - .map_err(PackageMetaBuildpackError::CouldNotCopyBuildpackToml)?; + .map_err(PackageCompositeBuildpackError::CouldNotCopyBuildpackToml)?; let package_descriptor_path = buildpack_directory.join("package.toml"); let normalized_package_descriptor = read_toml_file::(&package_descriptor_path) - .map_err(PackageMetaBuildpackError::CouldNotReadPackageDescriptor) + .map_err(PackageCompositeBuildpackError::CouldNotReadPackageDescriptor) .and_then(|package_descriptor| { normalize_package_descriptor( &package_descriptor, &package_descriptor_path, buildpack_paths, ) - .map_err(PackageMetaBuildpackError::NormalizePackageDescriptorError) + .map_err(PackageCompositeBuildpackError::NormalizePackageDescriptorError) })?; write_toml_file( &normalized_package_descriptor, destination.join("package.toml"), ) - .map_err(PackageMetaBuildpackError::CouldNotWritePackageDescriptor) + .map_err(PackageCompositeBuildpackError::CouldNotWritePackageDescriptor) } #[derive(thiserror::Error, Debug)] -pub enum PackageMetaBuildpackError { +pub enum PackageCompositeBuildpackError { #[error("Could not copy buildpack.toml: {0}")] CouldNotCopyBuildpackToml(std::io::Error), #[error("Could not read package.toml: {0}")] diff --git a/libcnb-test/README.md b/libcnb-test/README.md index 69562282..bdc9ade5 100644 --- a/libcnb-test/README.md +++ b/libcnb-test/README.md @@ -213,7 +213,7 @@ fn additional_buildpacks() { - Rust tests are automatically run in parallel, however only if they are in the same crate. For integration tests Rust compiles each file as a separate crate. As such, make sure to - include all integration tests in a single file (either inlined or by including additional + include all integration tests in a single file (either inlined or by including additional test modules) to ensure they run in parallel. - If you would like to be able to more easily run your unit tests and integration tests separately, annotate each integration test with `#[ignore = "integration test"]`, which diff --git a/libcnb-test/tests/fixtures/buildpacks/libcnb-test-meta/buildpack.toml b/libcnb-test/tests/fixtures/buildpacks/libcnb-test-composite/buildpack.toml similarity index 82% rename from libcnb-test/tests/fixtures/buildpacks/libcnb-test-meta/buildpack.toml rename to libcnb-test/tests/fixtures/buildpacks/libcnb-test-composite/buildpack.toml index b21aeca3..95706626 100644 --- a/libcnb-test/tests/fixtures/buildpacks/libcnb-test-meta/buildpack.toml +++ b/libcnb-test/tests/fixtures/buildpacks/libcnb-test-composite/buildpack.toml @@ -1,8 +1,8 @@ api = "0.8" [buildpack] -id = "libcnb-test/meta" -name = "Meta-buildpack Test" +id = "libcnb-test/composite" +name = "Composite Buildpack Test" version = "0.0.0" homepage = "https://example.com" description = "Official test example" diff --git a/libcnb-test/tests/fixtures/buildpacks/libcnb-test-meta/package.toml b/libcnb-test/tests/fixtures/buildpacks/libcnb-test-composite/package.toml similarity index 100% rename from libcnb-test/tests/fixtures/buildpacks/libcnb-test-meta/package.toml rename to libcnb-test/tests/fixtures/buildpacks/libcnb-test-composite/package.toml diff --git a/libcnb-test/tests/integration_test.rs b/libcnb-test/tests/integration_test.rs index 043ac1d6..c50d7c5d 100644 --- a/libcnb-test/tests/integration_test.rs +++ b/libcnb-test/tests/integration_test.rs @@ -563,10 +563,10 @@ fn basic_build_with_libcnb_reference_to_single_buildpack() { #[test] #[ignore = "integration test"] -fn basic_build_with_libcnb_reference_to_meta_buildpack() { +fn basic_build_with_libcnb_reference_to_composite_buildpack() { TestRunner::default().build( BuildConfig::new("heroku/builder:22", "tests/fixtures/empty").buildpacks([ - BuildpackReference::WorkspaceBuildpack(buildpack_id!("libcnb-test/meta")), + BuildpackReference::WorkspaceBuildpack(buildpack_id!("libcnb-test/composite")), ]), |context| { assert_empty!(context.pack_stderr); diff --git a/libcnb/src/build.rs b/libcnb/src/build.rs index bedaac4b..49785511 100644 --- a/libcnb/src/build.rs +++ b/libcnb/src/build.rs @@ -5,7 +5,7 @@ use crate::data::buildpack::StackId; use crate::data::layer::LayerName; use crate::data::store::Store; use crate::data::{ - buildpack::SingleBuildpackDescriptor, buildpack_plan::BuildpackPlan, launch::Launch, + buildpack::ComponentBuildpackDescriptor, buildpack_plan::BuildpackPlan, launch::Launch, }; use crate::layer::{HandleLayerErrorOrBuildpackError, Layer, LayerData}; use crate::sbom::Sbom; @@ -19,7 +19,7 @@ pub struct BuildContext { pub stack_id: StackId, pub platform: B::Platform, pub buildpack_plan: BuildpackPlan, - pub buildpack_descriptor: SingleBuildpackDescriptor, + pub buildpack_descriptor: ComponentBuildpackDescriptor, pub store: Option, } diff --git a/libcnb/src/detect.rs b/libcnb/src/detect.rs index 083dd3c4..dd347b9e 100644 --- a/libcnb/src/detect.rs +++ b/libcnb/src/detect.rs @@ -2,7 +2,7 @@ use crate::buildpack::Buildpack; use crate::data::buildpack::StackId; -use crate::{data::build_plan::BuildPlan, data::buildpack::SingleBuildpackDescriptor}; +use crate::{data::build_plan::BuildPlan, data::buildpack::ComponentBuildpackDescriptor}; use std::fmt::Debug; use std::path::PathBuf; @@ -12,7 +12,7 @@ pub struct DetectContext { pub buildpack_dir: PathBuf, pub stack_id: StackId, pub platform: B::Platform, - pub buildpack_descriptor: SingleBuildpackDescriptor, + pub buildpack_descriptor: ComponentBuildpackDescriptor, } /// Describes the result of the detect phase. diff --git a/libcnb/src/layer/tests.rs b/libcnb/src/layer/tests.rs index 877673ce..ad33d12f 100644 --- a/libcnb/src/layer/tests.rs +++ b/libcnb/src/layer/tests.rs @@ -21,7 +21,7 @@ use crate::layer::{ }; use crate::layer_env::{LayerEnv, ModificationBehavior, Scope}; use crate::{read_toml_file, Buildpack, Env, LIBCNB_SUPPORTED_BUILDPACK_API}; -use libcnb_data::buildpack::{BuildpackVersion, SingleBuildpackDescriptor, Stack}; +use libcnb_data::buildpack::{BuildpackVersion, ComponentBuildpackDescriptor, Stack}; use libcnb_data::buildpack_plan::BuildpackPlan; use libcnb_data::layer::LayerName; use libcnb_data::layer_content_metadata::LayerContentMetadata; @@ -906,7 +906,7 @@ fn build_context(temp_dir: &TempDir) -> BuildContext { buildpack_plan: BuildpackPlan { entries: Vec::new(), }, - buildpack_descriptor: SingleBuildpackDescriptor { + buildpack_descriptor: ComponentBuildpackDescriptor { api: LIBCNB_SUPPORTED_BUILDPACK_API, buildpack: crate::data::buildpack::Buildpack { id: buildpack_id!("libcnb/test"),