-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Cargo.toml, image_builder.rs, and main.rs
- Loading branch information
1 parent
8c39430
commit a64a0db
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 !"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} |