From 8264d3c4bef71b582b33896ae26a79643a188acf Mon Sep 17 00:00:00 2001 From: Hannah Neary Date: Tue, 10 Dec 2024 13:16:31 +0000 Subject: [PATCH] Error on env --- control-plane/src/configuration.rs | 12 ++++++------ control-plane/src/orchestration.rs | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/control-plane/src/configuration.rs b/control-plane/src/configuration.rs index e5b0c251..fd0c476c 100644 --- a/control-plane/src/configuration.rs +++ b/control-plane/src/configuration.rs @@ -1,4 +1,4 @@ -use std::str::FromStr; +use std::{env::VarError, str::FromStr}; use openssl::{ ec::EcKey, @@ -132,11 +132,11 @@ pub fn get_team_uuid() -> String { std::env::var("EV_TEAM_UUID").expect("EV_TEAM_UUID is not set in env") } -pub fn get_enclave_run_config() -> EnclaveRunConfig { - let num_cpus = std::env::var("ENCLAVE_NUM_CPUS").unwrap_or_else(|_| "2".to_string()); - let ram_size_mib = std::env::var("ENCLAVE_RAM_SIZE_MIB").unwrap_or_else(|_| "512".to_string()); - let debug_mode = std::env::var("ENCLAVE_DEBUG_MODE").unwrap_or_else(|_| "false".to_string()); - EnclaveRunConfig::new(num_cpus, ram_size_mib, debug_mode) +pub fn get_enclave_run_config() -> Result { + let num_cpus = std::env::var("ENCLAVE_NUM_CPUS")?; + let ram_size_mib = std::env::var("ENCLAVE_RAM_SIZE_MIB")?; + let debug_mode = std::env::var("ENCLAVE_DEBUG_MODE")?; + Ok(EnclaveRunConfig::new(num_cpus, ram_size_mib, debug_mode)) } pub fn get_cert_provisoner_host() -> String { diff --git a/control-plane/src/orchestration.rs b/control-plane/src/orchestration.rs index 1d7ecafc..b0e92527 100644 --- a/control-plane/src/orchestration.rs +++ b/control-plane/src/orchestration.rs @@ -18,6 +18,8 @@ pub enum OrchestrationError { SerdeError(#[from] serde_json::Error), #[error(transparent)] Io(#[from] std::io::Error), + #[error(transparent)] + VarError(#[from] std::env::VarError), } static EMPTY_VEC: Vec = Vec::new(); @@ -56,7 +58,7 @@ impl Orchestration { } pub async fn start_enclave() -> Result<(), OrchestrationError> { - let run_config = get_enclave_run_config(); + let run_config = get_enclave_run_config()?; info!("[HOST] Checking for running enclaves...");