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

Post PR #88 Cleanup #98

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Changes from all commits
Commits
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
33 changes: 1 addition & 32 deletions src/buildpacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,7 @@ pub(crate) fn read_image_repository_metadata(
metadata
.as_ref()
.and_then(|metadata| metadata.get("release").and_then(|value| value.as_table()))
.and_then(|release| {
release
.get("image")
// TODO: remove this once each buildpack.toml metadata is updated to
// replace [metadata.release.docker] with [metadata.release.image]
.or_else(|| release.get("docker"))
.and_then(|value| value.as_table())
})
.and_then(|release| release.get("image").and_then(|value| value.as_table()))
.and_then(|docker| docker.get("repository").and_then(|value| value.as_str()))
.map(|value| value.to_string())
}
Expand All @@ -64,30 +57,6 @@ mod test {
use libcnb_data::buildpack::BuildpackDescriptor;
use libcnb_package::GenericMetadata;

#[test]
fn test_read_image_repository_metadata_deprecated() {
let data = r#"
api = "0.9"

[buildpack]
id = "foo/bar"
version = "0.0.1"

[[stacks]]
id = "*"

[metadata.release.docker]
repository = "deprecated repository value"
"#;

let buildpack_descriptor =
toml::from_str::<BuildpackDescriptor<GenericMetadata>>(data).unwrap();
assert_eq!(
read_image_repository_metadata(&buildpack_descriptor),
Some("deprecated repository value".to_string())
);
}

#[test]
fn test_read_image_repository_metadata() {
let data = r#"
Expand Down