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

Deny unknown fields #349

Merged
merged 1 commit into from
Nov 15, 2024
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
1 change: 1 addition & 0 deletions buildpacks/ruby/src/layers/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ mod tests {

/// Struct for asserting the behavior of `cached_layer_write_metadata`
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)]
#[serde(deny_unknown_fields)]
struct TestMetadata {
value: String,
}
Expand Down
1 change: 1 addition & 0 deletions buildpacks/ruby/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ impl From<RubyBuildpackError> for libcnb::Error<RubyBuildpackError> {
buildpack_main!(RubyBuildpack);

#[derive(serde::Deserialize, serde::Serialize, Debug, Clone, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
struct BundleWithout(String);

impl BundleWithout {
Expand Down
2 changes: 2 additions & 0 deletions commons/src/gemfile_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl GemfileLock {
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
#[serde(deny_unknown_fields)]
pub struct ResolvedRubyVersion(pub String);

impl Display for ResolvedRubyVersion {
Expand All @@ -90,6 +91,7 @@ impl Display for ResolvedRubyVersion {
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
#[serde(deny_unknown_fields)]
pub struct ResolvedBundlerVersion(pub String);

impl Display for ResolvedBundlerVersion {
Expand Down
4 changes: 4 additions & 0 deletions commons/src/metadata_digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const PLATFORM_ENV_VAR: &str = "user configured environment variables";
/// add logic to your buildpack to re-run that command similar to the "escape valve" discussed
/// above, but triggered by buildpack author instead of the end user.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
#[serde(deny_unknown_fields)]
pub struct MetadataDigest {
platform_env: Option<PlatformEnvDigest>,
files: Option<PathsDigest>, // Must be last for serde to be happy https://github.com/toml-rs/toml-rs/issues/142
Expand Down Expand Up @@ -235,9 +236,11 @@ impl MetadataDigest {
}

#[derive(Serialize, Deserialize, Clone, Debug, Hash, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
struct ShaString(String);

#[derive(Serialize, Deserialize, Clone, Debug, Hash, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
struct PlatformEnvDigest(ShaString);
impl PlatformEnvDigest {
fn new(platform: &impl Platform) -> Self {
Expand All @@ -248,6 +251,7 @@ impl PlatformEnvDigest {
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
#[serde(deny_unknown_fields)]
struct PathsDigest(HashMap<PathBuf, ShaString>);

/// Main struct for detecting changes between two iterations
Expand Down
Loading