Skip to content

Commit

Permalink
fix(): add cred_type and app_id in output
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainSieb committed Aug 20, 2024
1 parent 17f719d commit 9dd323c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ unsafe_code = "forbid"

[lints.clippy]
enum_glob_use = "deny"
pedantic = "deny"
nursery = "deny"
pedantic = { level = "deny", priority = -1 }
nursery = { level = "deny", priority = -1 }
unwrap_used = "deny"
redundant_pub_crate = "allow"

[profile.release]
strip = true # Automatically strip symbols from the binary
Expand Down
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async fn get_token(
Ok(res)
}

fn parse_credentials(application: &Application, credentials: &[Credential]) -> String {
fn parse_credentials(application: &Application, credentials: &[Credential], cred_type: &str) -> String {
let mut res = String::new(); // This is what we are going to return
let mut jours_restants: i64;
let date_now = Utc::now();
Expand All @@ -100,7 +100,7 @@ fn parse_credentials(application: &Application, credentials: &[Credential]) -> S
application.app_id
));
res.push_str(&format!(
"application_{}_{id}{{application=\"{}\",type=\"secret\",app=\"Azure Certificat Expiration\"}} {jours_restants}\n\n",
"application_{}_{id}{{application=\"{}\",type=\"{cred_type}\",app=\"Azure {cred_type} Expiration\",app_id=\"{0}_{id}\"}} {jours_restants}\n\n",
application.app_id,
application.display_name));
}
Expand Down Expand Up @@ -141,12 +141,14 @@ async fn get_subscription_list(
res.push_str(&parse_credentials(
&application,
&application.password_credentials,
"secret"
));

// Handle certificates
res.push_str(&parse_credentials(
&application,
&application.key_credentials,
"certificate"
));
}

Expand Down

0 comments on commit 9dd323c

Please sign in to comment.