Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Tobin Feldman-Fitzthum <[email protected]>
  • Loading branch information
fitzthum committed Feb 1, 2023
1 parent 5bf909b commit 7df7d6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ impl KbsDb {
pub async fn new() -> Result<Self> {
let db_type = env::var("KBS_DB_TYPE")
.map_err(|e| anyhow!("KbsDb::new() - env var KBS_DB_TYPE parse error = {}", e))?;
let host_name = env::var("KBS_DB_HOST")
let db_host = env::var("KBS_DB_HOST")
.map_err(|e| anyhow!("KbsDb::new() - env var KBS_DB_HOST parse error = {}", e))?;
let user_name = env::var("KBS_DB_USER")
let db_user = env::var("KBS_DB_USER")
.map_err(|e| anyhow!("KbsDb::new() - env var KBS_DB_USER parse error = {}", e))?;
let db_pw = env::var("KBS_DB_PW")
.map_err(|e| anyhow!("KbsDb::new() - env var KBS_DB_PW parse error = {}", e))?;
Expand All @@ -66,10 +66,9 @@ impl KbsDb {
Err(_e) => 1000u32,
};

let db_url = if db_type == "sqlite" {
format!("{db_type}://{db_name}")
} else {
format!("{db_type}://{user_name}:{db_pw}@{host_name}/{db_name}")
let db_url = match &db_type[..] {
"sqlite" => format!("{db_type}://{db_name}"),
_ => format!("{db_type}://{db_user}:{db_pw}@{db_host}/{db_name}"),
};

let dbpool = AnyPoolOptions::new()
Expand Down
2 changes: 1 addition & 1 deletion src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl Key {
pub fn bytes(&self) -> Result<Vec<u8>> {
base64::decode(&self.payload).map_err(|e| {
// Provide full details in KBS log
error!("Binary secrets must be b64 encoded: {}", e);
error!("Binary secrets must be base64 encoded: {}", e);
anyhow!("Invalid Secret Format")
})
}
Expand Down

0 comments on commit 7df7d6c

Please sign in to comment.