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

Update libcnb to 0.11.0 #371

Merged
merged 2 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
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
58 changes: 29 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
[workspace]

members = [
"buildpacks/jvm",
"buildpacks/maven",
"buildpacks/jvm-function-invoker"
]

[workspace.package]
version = "0.0.0"
rust-version = "1.64"
edition = "2021"
publish = false

[workspace.dependencies]
libcnb = "0.11.0"
libherokubuildpack = "0.11.0"
libcnb-test = "0.11.0"
12 changes: 6 additions & 6 deletions buildpacks/jvm-function-invoker/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "jvm-function-invoker-buildpack"
version = "0.0.0"
publish = false
edition = "2021"
rust-version = "1.56"
version.workspace = true
rust-version.workspace = true
edition.workspace = true
publish.workspace = true
Malax marked this conversation as resolved.
Show resolved Hide resolved

[dependencies]
indoc = "1.0.7"
libcnb = "0.10.0"
libherokubuildpack = { version = "0.10.0", features = ["toml"] }
libcnb.workspace = true
libherokubuildpack.workspace = true
serde = "1.0.144"
thiserror = "1.0.35"
toml = "0.5.9"
Expand Down
2 changes: 1 addition & 1 deletion buildpacks/jvm-function-invoker/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use libcnb::read_toml_file;
use libherokubuildpack::toml_select_value;
use libherokubuildpack::toml::toml_select_value;
use std::path::Path;
use toml::Value;

Expand Down
2 changes: 1 addition & 1 deletion buildpacks/jvm-function-invoker/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use libcnb::{Error, TomlFileError};
use crate::layers::bundle::BundleLayerError;
use crate::layers::opt::OptLayerError;
use crate::layers::runtime::RuntimeLayerError;
use libherokubuildpack::log_error;
use libherokubuildpack::log::log_error;

#[derive(thiserror::Error, Debug)]
pub enum JvmFunctionInvokerBuildpackError {
Expand Down
11 changes: 4 additions & 7 deletions buildpacks/jvm-function-invoker/src/layers/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
use crate::error::JvmFunctionInvokerBuildpackError;
use crate::JvmFunctionInvokerBuildpack;
use libcnb::build::BuildContext;
use libcnb::data::layer_content_metadata::LayerTypes;
use libcnb::generic::GenericMetadata;
use libcnb::layer::{Layer, LayerResult, LayerResultBuilder};
use libcnb::layer_env::{LayerEnv, ModificationBehavior, Scope};
use libcnb::{read_toml_file, Env, TomlFileError};

use libherokubuildpack::log::{log_header, log_info};
use serde::Deserialize;
use std::path::Path;
use std::process::Command;

use serde::Deserialize;
use thiserror::Error;

use crate::error::JvmFunctionInvokerBuildpackError;
use crate::JvmFunctionInvokerBuildpack;
use libherokubuildpack::{log_header, log_info};

pub struct BundleLayer {
pub env: Env,
}
Expand Down
12 changes: 6 additions & 6 deletions buildpacks/jvm-function-invoker/src/layers/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use crate::error::JvmFunctionInvokerBuildpackError;
use crate::JvmFunctionInvokerBuildpack;
use libcnb::build::BuildContext;
use libcnb::data::layer_content_metadata::LayerTypes;
use libcnb::layer::{ExistingLayerStrategy, Layer, LayerData, LayerResult, LayerResultBuilder};
use libcnb::layer_env::{LayerEnv, ModificationBehavior, Scope};
use std::path::Path;

use libherokubuildpack::digest::sha256;
use libherokubuildpack::download::{download_file, DownloadError};
use libherokubuildpack::log::log_info;
use serde::{Deserialize, Serialize};
use std::path::Path;
use thiserror::Error;

use crate::error::JvmFunctionInvokerBuildpackError;
use crate::JvmFunctionInvokerBuildpack;
use libherokubuildpack::{download_file, log_info, sha256, DownloadError};

pub struct RuntimeLayer;

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
5 changes: 3 additions & 2 deletions buildpacks/jvm-function-invoker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use libcnb::detect::{DetectContext, DetectResult, DetectResultBuilder};
use libcnb::generic::GenericPlatform;
use libcnb::layer_env::Scope;
use libcnb::{Buildpack, Env};
use libherokubuildpack::{log_header, log_info, on_error_heroku};
use libherokubuildpack::error::on_error;
use libherokubuildpack::log::{log_header, log_info};
use serde::Deserialize;

mod common;
Expand Down Expand Up @@ -96,7 +97,7 @@ impl Buildpack for JvmFunctionInvokerBuildpack {
}

fn on_error(&self, error: libcnb::Error<Self::Error>) {
on_error_heroku(handle_buildpack_error, error)
on_error(handle_buildpack_error, error)
}
}

Expand Down
13 changes: 7 additions & 6 deletions buildpacks/jvm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[package]
name = "heroku-openjdk"
version = "0.0.0"
edition = "2021"
publish = false
version.workspace = true
rust-version.workspace = true
edition.workspace = true
publish.workspace = true

[dependencies]
fs_extra = "1.2.0"
java-properties = "1.4.1"
libcnb = "0.10.0"
libherokubuildpack = "0.10.0"
libcnb.workspace = true
libherokubuildpack.workspace = true
serde = { version = "1.0.144", features = ["derive"] }
sha2 = "0.10.6"
tempfile = "3.3.0"
Expand All @@ -18,4 +19,4 @@ ureq = "2.5.0"
indoc = "1.0.7"

[dev-dependencies]
libcnb-test = "0.10.0"
libcnb-test.workspace = true
3 changes: 2 additions & 1 deletion buildpacks/jvm/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use crate::{
NormalizeVersionStringError, OpenJdkBuildpackError, ReadVersionStringError, ValidateSha256Error,
};
use indoc::formatdoc;
use libherokubuildpack::{log_error, DownloadError};
use libherokubuildpack::download::DownloadError;
use libherokubuildpack::log::log_error;
use std::fmt::Debug;

#[allow(clippy::too_many_lines)]
Expand Down
4 changes: 2 additions & 2 deletions buildpacks/jvm/src/layers/heroku_metrics_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ impl Layer for HerokuMetricsAgentLayer {
context: &BuildContext<Self::Buildpack>,
layer_path: &Path,
) -> Result<LayerResult<Self::Metadata>, <Self::Buildpack as Buildpack>::Error> {
libherokubuildpack::log_header("Installing Heroku JVM metrics agent");
libherokubuildpack::log::log_header("Installing Heroku JVM metrics agent");

let agent_jar_path = layer_path.join("heroku-metrics-agent.jar");

let metrics_agent_metadata = &context.buildpack_descriptor.metadata.heroku_metrics_agent;

libherokubuildpack::download_file(&metrics_agent_metadata.url, &agent_jar_path)
libherokubuildpack::download::download_file(&metrics_agent_metadata.url, &agent_jar_path)
.map_err(OpenJdkBuildpackError::MetricsAgentDownloadError)?;

validate_sha256(&agent_jar_path, &metrics_agent_metadata.sha256)
Expand Down
6 changes: 3 additions & 3 deletions buildpacks/jvm/src/layers/openjdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ impl Layer for OpenJdkLayer {
context: &BuildContext<Self::Buildpack>,
layer_path: &Path,
) -> Result<LayerResult<Self::Metadata>, OpenJdkBuildpackError> {
libherokubuildpack::log_header("Installing OpenJDK");
libherokubuildpack::log::log_header("Installing OpenJDK");

let temp_dir = tempdir().map_err(OpenJdkBuildpackError::CannotCreateOpenJdkTempDir)?;
let path = temp_dir.path().join("openjdk.tar.gz");

libherokubuildpack::download_file(&self.tarball_url, &path)
libherokubuildpack::download::download_file(&self.tarball_url, &path)
.map_err(OpenJdkBuildpackError::OpenJdkDownloadError)?;

std::fs::File::open(&path)
.map_err(OpenJdkBuildpackError::CannotOpenOpenJdkTarball)
.and_then(|mut file| {
libherokubuildpack::decompress_tarball(&mut file, &layer_path)
libherokubuildpack::tar::decompress_tarball(&mut file, &layer_path)
.map_err(OpenJdkBuildpackError::CannotDecompressOpenJdkTarball)
})?;

Expand Down
4 changes: 2 additions & 2 deletions buildpacks/jvm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use libcnb::data::layer_name;
use libcnb::detect::{DetectContext, DetectResult, DetectResultBuilder};
use libcnb::generic::GenericPlatform;
use libcnb::Buildpack;
use libherokubuildpack::DownloadError;
use libherokubuildpack::download::DownloadError;
use serde::{Deserialize, Serialize};

pub struct OpenJdkBuildpack;
Expand Down Expand Up @@ -89,7 +89,7 @@ impl Buildpack for OpenJdkBuildpack {
}

fn on_error(&self, error: libcnb::Error<Self::Error>) {
libherokubuildpack::on_error_heroku(on_error_jvm_buildpack, error);
libherokubuildpack::error::on_error(on_error_jvm_buildpack, error);
}
}

Expand Down
2 changes: 1 addition & 1 deletion buildpacks/jvm/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) fn validate_sha256<P: AsRef<Path>, S: Into<String>>(
) -> Result<(), ValidateSha256Error> {
let expected_sha256 = expected_sha256.into();

libherokubuildpack::sha256(path.as_ref())
libherokubuildpack::digest::sha256(path.as_ref())
.map_err(ValidateSha256Error::CouldNotObtainSha256)
.and_then(|actual_sha256| {
if expected_sha256 == actual_sha256 {
Expand Down
Loading