use crate::store_paths::models::StoreKind;
pub(in crate::adapters) fn custom_endpoint(
store: &StoreKind,
variable: &dyn Fn(&str) -> Option<String>,
) -> Option<String> {
let from_env = ["AWS_ENDPOINT", "AWS_ENDPOINT_URL"]
.iter()
.any(|name| variable(name).is_some_and(|value| !value.is_empty()));
match store {
StoreKind::S3 {
endpoint: Some(_), ..
} => Some("the S3 connection sets a custom endpoint".to_owned()),
StoreKind::S3 { .. } if from_env => {
Some("AWS_ENDPOINT or AWS_ENDPOINT_URL sets a custom S3 endpoint".to_owned())
}
_ => None,
}
}