Skip to content

Commit

Permalink
feat: prevent serializing verifySSL if it is default (#2801)
Browse files Browse the repository at this point in the history
Signed-off-by: Elis Lulja <[email protected]>
  • Loading branch information
asimpleidea committed Sep 27, 2024
1 parent 3d402ea commit e0dd52b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/config/upstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use derive_setters::Setters;
use serde::{Deserialize, Serialize};
use tailcall_macros::{DirectiveDefinition, InputDefinition};

use crate::core::default_verify_ssl;
use crate::core::is_default;
use crate::core::macros::MergeRight;
use crate::core::merge_right::MergeRight;
use crate::core::{default_verify_ssl, is_default, verify_ssl_is_default};

const DEFAULT_MAX_SIZE: usize = 100;

Expand Down Expand Up @@ -149,12 +148,13 @@ pub struct Upstream {
#[serde(
default = "default_verify_ssl",
rename = "verifySSL",
skip_serializing_if = "is_default"
skip_serializing_if = "verify_ssl_is_default"
)]
/// A boolean value that determines whether to verify certificates.
/// Setting this as `false` will make tailcall accept self-signed certificates.
/// NOTE: use this *only* during development or testing. It is highly
/// recommended to keep this enabled (`true`) in production.
/// Setting this as `false` will make tailcall accept self-signed
/// certificates. NOTE: use this *only* during development or testing.
/// It is highly recommended to keep this enabled (`true`) in
/// production.
pub verify_ssl: Option<bool>,
}

Expand Down
4 changes: 4 additions & 0 deletions src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ pub fn is_default<T: Default + Eq>(val: &T) -> bool {
*val == T::default()
}

pub fn verify_ssl_is_default(val: &Option<bool>) -> bool {
val.is_none() || val.unwrap()
}

#[cfg(test)]
pub mod tests {
use std::collections::HashMap;
Expand Down

0 comments on commit e0dd52b

Please sign in to comment.