Skip to content
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
36 changes: 35 additions & 1 deletion bottlecap/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use figment::{providers::Env, Figment};
use serde::{Deserialize, Deserializer};
use serde_json::Value;
use trace_propagation_style::{deserialize_trace_propagation_style, TracePropagationStyle};
use tracing::debug;

use crate::config::{
flush_strategy::FlushStrategy,
Expand Down Expand Up @@ -260,7 +261,13 @@ pub fn get_config(config_directory: &Path) -> Result<Config, ConfigError> {
if config.site.is_empty() {
config.site = "datadoghq.com".to_string();
}

// TODO(astuyve)
// Bit of a hack as we're not checking individual privatelink setups
// potentially a user could use the proxy for logs and privatelink for APM
if std::env::var("NO_PROXY").map_or(false, |no_proxy| no_proxy.contains(&config.site)) {
debug!("NO_PROXY contains DD_SITE, disabling proxy");
config.https_proxy = None;
}
// Merge YAML nested fields
//
// Set logs_config_processing_rules if not defined in env
Expand Down Expand Up @@ -522,6 +529,33 @@ pub mod tests {
});
}

#[test]
fn test_proxy_config() {
figment::Jail::expect_with(|jail| {
jail.clear_env();
jail.set_env("DD_PROXY_HTTPS", "my-proxy:3128");
let config = get_config(Path::new("")).expect("should parse config");
assert_eq!(config.https_proxy, Some("my-proxy:3128".to_string()));
Ok(())
});
}

#[test]
fn test_noproxy_config() {
figment::Jail::expect_with(|jail| {
jail.clear_env();
jail.set_env("DD_SITE", "datadoghq.eu");
jail.set_env("DD_PROXY_HTTPS", "my-proxy:3128");
jail.set_env(
"NO_PROXY",
"127.0.0.1,localhost,172.16.0.0/12,us-east-1.amazonaws.com,datadoghq.eu",
);
let config = get_config(Path::new("")).expect("should parse noproxy");
assert_eq!(config.https_proxy, None);
Ok(())
});
}

#[test]
fn test_parse_flush_strategy_end() {
figment::Jail::expect_with(|jail| {
Expand Down
Loading