Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Jesse Szwedko <[email protected]>
  • Loading branch information
jszwedko committed Aug 14, 2024
1 parent 8f1230d commit 34964f4
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/config/loading/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,24 @@ impl SecretBackendLoader {
let mut secrets: HashMap<String, String> = HashMap::new();

for (backend_name, keys) in &self.secret_keys {
let backend = self.backends.get_mut(&ComponentKey::from(backend_name.clone())).ok_or_else(|| format!("Backend \"{backend_name}\" is required for secret retrieval but was not found in config."))?;
let backend = self.backends
.get_mut(&ComponentKey::from(backend_name.clone()))
.ok_or_else(|| {
format!("Backend \"{backend_name}\" is required for secret retrieval but was not found in config.")
})?;

debug!(message = "Retrieving secrets from a backend.", backend = ?backend_name, keys = ?keys);
let backend_secrets = backend
.retrieve(keys.clone(), signal_rx)
.map_ok(|backend_secrets| {
backend_secrets.into_iter().map(|(k, v)| {
trace!(message = "Successfully retrieved a secret.", backend = ?backend_name, key = ?k);
(format!("{backend_name}.{k}"), v)
}).collect::<HashMap<String, String>>()
})
.map_err(|e| {
format!(
"Error while retrieving secret from backend \"{backend_name}\": {e}.",
)
format!("Error while retrieving secret from backend \"{backend_name}\": {e}.",)
})
.await?;

secrets.extend(backend_secrets);
for (k, v) in backend_secrets {
trace!(message = "Successfully retrieved a secret.", backend = ?backend_name, key = ?k);
secrets.insert(format!("{backend_name}.{k}"), v);
}
}

Ok(secrets)
Expand Down

0 comments on commit 34964f4

Please sign in to comment.