Skip to content

Commit

Permalink
Update Cargo.toml, image_builder.rs, and main.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias-Boulay committed Apr 17, 2024
1 parent 8c39430 commit a64a0db
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/fs-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ edition = "2021"
clap = { version = "4.5.3", features = ["derive", "wrap_help", "string"] }
once_cell = "1.19.0"
regex = "1.10.4"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
validator = { version = "0.17.0", features = ["derive"] }
vfs = "0.12.0"
22 changes: 22 additions & 0 deletions src/fs-gen/src/image_builder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use std::path::{Path, PathBuf};

use vfs::{FileSystem, OverlayFS, PhysicalFS, VfsPath};

pub fn build_new_image(blob_paths: &Vec<PathBuf>, output_folder: &Path) {
let virtual_paths = blob_paths
.iter()
.map(|p| VfsPath::new(PhysicalFS::new(p)))
.collect::<Vec<VfsPath>>();

let vfs = OverlayFS::new(&virtual_paths);
let toto: Vec<String> = vfs.read_dir("/home").unwrap().collect();
println!("{:?}", toto);
println!("{:?}", vfs);
let overlay_root: VfsPath = vfs.into();

let output_vpath = VfsPath::new(PhysicalFS::new(output_folder));

overlay_root
.copy_dir(&output_vpath)
.expect("Failed to copy the blobs !");
}
13 changes: 12 additions & 1 deletion src/fs-gen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
use std::{
path::{Path, PathBuf},
str::FromStr,
};

use clap::Parser;

use crate::cli_args::CliArgs;
use crate::{cli_args::CliArgs, image_builder::build_new_image};

mod cli_args;
mod image_builder;

fn main() {
let args = CliArgs::get_args();
println!("Hello, world!, {:?}", args);

let paths: Vec<PathBuf> =
vec![PathBuf::from_str("../../image-gen/blobs/sha256/layer_1").unwrap()];

build_new_image(&paths, &PathBuf::from_str("./titi").unwrap());
}

0 comments on commit a64a0db

Please sign in to comment.