diff --git a/coman/Cargo.toml b/coman/Cargo.toml index dd21c42..d718a66 100644 --- a/coman/Cargo.toml +++ b/coman/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "coman" -version = "0.8.0" +version = "0.8.1" edition = "2024" description = "Compute Manager for managing HPC compute" authors = ["Ralf Grubenmann "] diff --git a/coman/src/config.rs b/coman/src/config.rs index 9ac61ca..48689eb 100644 --- a/coman/src/config.rs +++ b/coman/src/config.rs @@ -45,6 +45,10 @@ pub enum ComputePlatform { #[derive(Clone, Debug, Serialize, Deserialize, Default)] pub struct CscsConfig { + #[serde(default)] + pub client_id: Option, + #[serde(default)] + pub client_secret: Option, #[serde(default)] pub current_system: String, #[serde(default)] diff --git a/coman/src/cscs/handlers.rs b/coman/src/cscs/handlers.rs index 8bbde55..280a71f 100644 --- a/coman/src/cscs/handlers.rs +++ b/coman/src/cscs/handlers.rs @@ -57,15 +57,24 @@ use crate::{ const CSCS_MAX_DIRECT_SIZE: usize = 5242880; async fn get_access_token() -> Result { - let client_id = match get_secret(CLIENT_ID_SECRET_NAME).await { - Ok(Some(client_id)) => client_id, - Ok(None) => Err(eyre!("not logged in"))?, - Err(e) => Err(e)?, + let config = Config::new()?; + let client_id = if let Some(client_id) = config.values.cscs.client_id { + Secret(client_id) + } else { + match get_secret(CLIENT_ID_SECRET_NAME).await { + Ok(Some(client_id)) => client_id, + Ok(None) => Err(eyre!("not logged in"))?, + Err(e) => Err(e)?, + } }; - let client_secret = match get_secret(CLIENT_SECRET_SECRET_NAME).await { - Ok(Some(client_secret)) => client_secret, - Ok(None) => Err(eyre!("not logged in"))?, - Err(e) => Err(e)?, + let client_secret = if let Some(client_secret) = config.values.cscs.client_secret { + Secret(client_secret) + } else { + match get_secret(CLIENT_SECRET_SECRET_NAME).await { + Ok(Some(client_secret)) => client_secret, + Ok(None) => Err(eyre!("not logged in"))?, + Err(e) => Err(e)?, + } }; let token = client_credentials_login(client_id, client_secret).await?; Ok(token.0)