Skip to content

Commit

Permalink
cleanup: clippy compliance
Browse files Browse the repository at this point in the history
Signed-off-by: Mathias-Boulay <[email protected]>
  • Loading branch information
Mathias-Boulay authored and BioTheWolff committed Apr 23, 2024
1 parent a36c948 commit 4a2a8bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
20 changes: 12 additions & 8 deletions src/fs-gen/src/image_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ type BoxedLayer = Box<dyn Layer<Inode = u64, Handle = u64> + Send + Sync>;
/// let passthrough_layer = new_passthroughfs_layer("/path/to/layer")
/// ```
fn new_passthroughfs_layer(rootdir: &str) -> Result<BoxedLayer> {
let mut config = passthrough::Config::default();
config.root_dir = String::from(rootdir);
config.xattr = true;
config.do_import = true;
let config = passthrough::Config {
root_dir: String::from(rootdir),
xattr: true,
do_import: true,
..Default::default()
};
let fs = Box::new(PassthroughFs::<()>::new(config)?);
fs.import()
.with_context(|| format!("Failed to create the passthrough layer: {}", rootdir))?;
Expand Down Expand Up @@ -67,10 +69,12 @@ pub fn merge_layer(blob_paths: &[PathBuf], output_folder: &Path) -> Result<()> {
ensure_folder_created(output_folder)?;

// Setup the overlay fs config
let mut config = Config::default();
config.work = "/work".into();
config.mountpoint = output_folder.to_string_lossy().into();
config.do_import = true;
let config = Config {
work: "/work".into(),
mountpoint: output_folder.to_string_lossy().into(),
do_import: true,
..Default::default()
};

let fs = OverlayFs::new(None, lower_layers, config)
.with_context(|| "Failed to construct the Overlay fs struct !".to_string())?;
Expand Down
16 changes: 8 additions & 8 deletions src/fs-gen/src/image_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ pub fn download_image_fs(
output_file: PathBuf,
) -> Result<Vec<PathBuf>, Box<dyn Error>> {
// Get image's name and tag
let image_and_tag: Vec<&str> = image_name.split(":").collect();
let tag: &str;
if image_and_tag.len() < 2 {
tag = "latest"
let image_and_tag: Vec<&str> = image_name.split(':').collect();

let tag = if image_and_tag.len() < 2 {
"latest"
} else {
tag = image_and_tag[1];
}
image_and_tag[1]
};
let image_name = image_and_tag[0];

// Download image manifest
Expand Down Expand Up @@ -81,7 +81,7 @@ fn download_manifest(image_name: &str, digest: &str) -> Result<serde_json::Value
);

let manifest_response = client
.get(&manifest_url)
.get(manifest_url)
.header(
"Accept",
"application/vnd.docker.distribution.manifest.v2+json",
Expand Down Expand Up @@ -140,7 +140,7 @@ fn download_layers(
let tar = GzDecoder::new(response);

let mut output_path = PathBuf::new();
output_path.push(&output_dir);
output_path.push(output_dir);
output_path.push(digest);

unpack_tarball(tar, &output_path)?;
Expand Down

0 comments on commit 4a2a8bb

Please sign in to comment.