Skip to content

Commit bef537e

Browse files
committed
fix: resolve compilation warnings for secure-storage feature
- Add conditional imports for anyhow::{anyhow, Context} only when secure-storage is enabled - Mark unused variables with _ when secure-storage is disabled - Conditionally compile SERVICE_NAME constant only when needed - Fix error handling in keyring operations
1 parent 5934efb commit bef537e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/redisctl/src/credential_store.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
//! - Plaintext storage (fallback)
77
//! - Environment variable override
88
9-
use anyhow::{Context, Result};
9+
use anyhow::Result;
10+
#[cfg(feature = "secure-storage")]
11+
use anyhow::{Context, anyhow};
1012
use std::env;
1113

1214
/// Prefix that indicates a value should be retrieved from the keyring
1315
const KEYRING_PREFIX: &str = "keyring:";
1416

1517
/// Service name for keyring entries
18+
#[cfg(feature = "secure-storage")]
1619
const SERVICE_NAME: &str = "redisctl";
1720

1821
/// Storage backend for credentials
@@ -97,6 +100,7 @@ impl CredentialStore {
97100
#[cfg(not(feature = "secure-storage"))]
98101
{
99102
// Without secure-storage feature, always use plaintext
103+
let _ = key; // Not used without secure-storage
100104
Ok(value.to_string())
101105
}
102106
}
@@ -150,14 +154,17 @@ impl CredentialStore {
150154
match entry.delete_credential() {
151155
Ok(()) => Ok(()),
152156
Err(keyring::Error::NoEntry) => Ok(()), // Already deleted
153-
Err(e) => Err(e).context("Failed to delete credential from keyring"),
157+
Err(e) => {
158+
Err(anyhow!(e)).context("Failed to delete credential from keyring")
159+
}
154160
}
155161
}
156162
CredentialStorage::Plaintext => Ok(()), // Nothing to delete for plaintext
157163
}
158164
}
159165
#[cfg(not(feature = "secure-storage"))]
160166
{
167+
let _ = key; // Not used without secure-storage
161168
Ok(()) // Nothing to delete for plaintext
162169
}
163170
}

0 commit comments

Comments
 (0)