From 340b60eaa047d32e9aed83d1699ccea0b7aa8a41 Mon Sep 17 00:00:00 2001 From: rawdaGastan Date: Mon, 21 Oct 2024 12:27:33 +0300 Subject: [PATCH] fix parsing env --- docker2fl/src/docker2fl.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/docker2fl/src/docker2fl.rs b/docker2fl/src/docker2fl.rs index f195415..4340558 100644 --- a/docker2fl/src/docker2fl.rs +++ b/docker2fl/src/docker2fl.rs @@ -263,21 +263,18 @@ async fn container_boot( args = entries.to_vec(); } - if container_config.env.is_some() { - for entry in container_config.env.expect("failed to get env").iter() { - let mut split = entry.split('='); - env.insert( - split.next().expect("failed to get env key").to_string(), - split.next().expect("failed to get env value").to_string(), - ); + if let Some(envs) = container_config.env { + for entry in envs.iter() { + if let Some((key, value)) = entry.split_once('=') { + env.insert(key.to_string(), value.to_string()); + } } } - let working_dir = container_config - .working_dir - .expect("failed to get working dir"); - if !working_dir.is_empty() { - cwd = working_dir; + if let Some(ref working_dir) = container_config.working_dir { + if !working_dir.is_empty() { + cwd = working_dir.to_string(); + } } let metadata = json!({