Skip to content

Commit

Permalink
fix(vmm): cleanup code
Browse files Browse the repository at this point in the history
Signed-off-by: Muriel Paraire <72733662+MurielParaire@users.noreply.github.com>
  • Loading branch information
MurielParaire committed May 3, 2024
1 parent a186dde commit cfdb10d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/vmm/src/grpc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ impl VmmService {
curr_dir: &OsStr,
) -> std::result::Result<PathBuf, VmmErrors> {
// define initramfs file placement
let initramfs_entire_file_path =
curr_dir.to_str().unwrap().to_owned() + &format!("/tools/rootfs/{}.img", language);
let initramfs_entire_file_path = &format!("{:?}/tools/rootfs/{language}.img", curr_dir);

// set image name
let image = format!("{}:alpine", language);
let image = format!("{language}:alpine");

// check if an initramfs already exists
let rootfs_exists = Path::new(&initramfs_entire_file_path)
Expand Down Expand Up @@ -84,7 +83,7 @@ impl VmmService {
vec![
"./tools/rootfs/mkrootfs.sh",
&image,
agent_file_name.to_str().unwrap(),
&format!("{:?}", agent_file_name),
&initramfs_entire_file_path,
],
)
Expand Down Expand Up @@ -117,14 +116,15 @@ impl VmmService {
args: Vec<&str>,
) -> std::result::Result<PathBuf, VmmErrors> {
// define file path
let entire_path = curr_dir.to_str().unwrap().to_owned() + end_path;
let entire_path = &format!("{:?}/tools/rootfs/{end_path}.img", curr_dir);

// Check if the file is on the system, else build it
let exists = Path::new(&entire_path)
.try_exists()
.map_err(VmmErrors::VmmBuildEnvironment)?;

if !exists {
// we know that the filepath is valid and has more than 1 / in it so we can unwrap
info!(
"File {:?} not found, building it",
&entire_path.split('/').last().unwrap()
Expand Down

0 comments on commit cfdb10d

Please sign in to comment.