From f86a47d86ab4340fb094f4e814ddcc2cbf16b2bb Mon Sep 17 00:00:00 2001 From: Manuel Sopena Ballesteros Date: Mon, 28 Oct 2024 17:34:32 +0100 Subject: [PATCH] refactor: clean lint warning messages --- src/common/jwt_ops.rs | 6 ++--- src/keycloak.rs | 56 ------------------------------------------- src/lib.rs | 1 - src/node/console.rs | 8 +++---- src/pcs.rs | 2 -- 5 files changed, 7 insertions(+), 66 deletions(-) delete mode 100644 src/keycloak.rs diff --git a/src/common/jwt_ops.rs b/src/common/jwt_ops.rs index 486ad6c..afca579 100644 --- a/src/common/jwt_ops.rs +++ b/src/common/jwt_ops.rs @@ -5,11 +5,11 @@ use serde_json::Value; use crate::hsm; -// FIXME: replace Error to my own one +/* // FIXME: replace Error to my own one #[deprecated( note = "Please, avoid using this function, if you need to get the list of HSM groups available to the user, then use `mesa::common::jwt_ops::get_hsm_name_available` because this function has the hack removing system wide hsm group names like alps, aplsm, alpse, etc. If you want the preffereed username, then use `mesa::common::jwt_ops::`mesa::common::jwt_ops::get_preferred_username" -)] -pub fn get_claims_from_jwt_token(token: &str) -> Result> { +)] */ +fn get_claims_from_jwt_token(token: &str) -> Result> { let base64_claims = token .split(' ') .nth(1) diff --git a/src/keycloak.rs b/src/keycloak.rs deleted file mode 100644 index 0b8cfe2..0000000 --- a/src/keycloak.rs +++ /dev/null @@ -1,56 +0,0 @@ -pub mod http_client { - use crate::error::Error; - - pub async fn create_role( - shasta_token: &str, - shasta_base_url: &str, - shasta_root_cert: &[u8], - group_name_opt: Option<&String>, - role_name: &str, - role_description: &str, - ) -> Result<(), Error> { - let realm = "shasta"; - let client_uuid = "838a32c1-8b1c-408f-9c94-2a431cb8e713"; - - let client_uuid = ""; - log::info!("Add Role {}", role_name); - let client; - - let client_builder = reqwest::Client::builder() - .add_root_certificate(reqwest::Certificate::from_pem(shasta_root_cert)?); - - // Build client - if std::env::var("SOCKS5").is_ok() { - // socks5 proxy - log::debug!("SOCKS5 enabled"); - let socks5proxy = reqwest::Proxy::all(std::env::var("SOCKS5").unwrap())?; - - // rest client to authenticate - client = client_builder.proxy(socks5proxy).build()?; - } else { - client = client_builder.build()?; - } - - let api_url: String = - format!("{shasta_base_url}/keycloak/admin/realms/{realm}/clients/{client_uuid}/roles"); - - let role = serde_json::json!({ - "name": role_name, - "description": role_description - }); - - client - .post(api_url) - .header("Authorization", format!("Bearer {}", shasta_token)) - .json(&role) // make sure this is not a string! - .send() - .await? - .error_for_status()? - .json() - .await?; - // TODO Parse the output!!! - // TODO add some debugging output - - Ok(()) - } -} diff --git a/src/lib.rs b/src/lib.rs index 77be33c..59583e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,5 @@ pub mod error; #[cfg(feature = "ochami")] pub mod hsm; pub mod ims; -pub mod keycloak; pub mod node; pub mod pcs; diff --git a/src/node/console.rs b/src/node/console.rs index 6d78c5b..559a495 100644 --- a/src/node/console.rs +++ b/src/node/console.rs @@ -119,8 +119,8 @@ pub async fn get_container_attachment_to_cfs_session_image_target( // Waiting for pod to start while pods.items.is_empty() && i <= max { - format!( - "\nPod for cfs session {} not ready. Trying again in 2 secs. Attempt {} of {}\n", + println!( + "Pod for cfs session {} not ready. Trying again in 2 secs. Attempt {} of {}", cfs_session_name, i + 1, max @@ -192,8 +192,8 @@ pub async fn get_container_attachment_to_cfs_session_image_target( // Waiting for pod to start while pods.items.is_empty() && i <= max { - format!( - "\nPod for cfs session {} not ready. Trying again in 2 secs. Attempt {} of {}\n", + println!( + "Pod for cfs session {} not ready. Trying again in 2 secs. Attempt {} of {}", cfs_session_name, i + 1, max diff --git a/src/pcs.rs b/src/pcs.rs index 433d830..e24a308 100644 --- a/src/pcs.rs +++ b/src/pcs.rs @@ -279,7 +279,6 @@ pub mod transitions { shasta_base_url, shasta_token, shasta_root_cert, - xname_vec, transition_id, ) .await?; @@ -291,7 +290,6 @@ pub mod transitions { shasta_base_url: &str, shasta_token: &str, shasta_root_cert: &[u8], - xname_vec: &Vec, transition_id: &str, ) -> Result { let mut transition_status = "";