From fccee09e35b8896bb92204a9f92c726a9e5502bd Mon Sep 17 00:00:00 2001 From: BioTheWolff <47079795+BioTheWolff@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:33:44 +0200 Subject: [PATCH] cleanup: make it cleaner for a PR --- src/fs-gen/src/cli_args.rs | 9 ++++----- src/fs-gen/src/image_builder.rs | 4 +++- src/fs-gen/src/main.rs | 7 +++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/fs-gen/src/cli_args.rs b/src/fs-gen/src/cli_args.rs index 350f6c7..8a224a7 100644 --- a/src/fs-gen/src/cli_args.rs +++ b/src/fs-gen/src/cli_args.rs @@ -1,12 +1,12 @@ -use std::{env, path::PathBuf}; +//! Command-line interface arguments and their management +use std::{env, path::PathBuf}; use clap::{command, Parser}; use regex::Regex; - use once_cell::sync::Lazy; use validator::Validate; -// So, for any of you who may be scared, this is the regex from the OCI Distribution Sepcification for the image name + the tag +/// Official regex from the OCI Distribution Sepcification (image name and tag) static RE_IMAGE_NAME: Lazy = Lazy::new(|| { Regex::new(r"[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*(\/[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*)*:[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}").unwrap() }); @@ -16,7 +16,6 @@ static RE_IMAGE_NAME: Lazy = Lazy::new(|| { #[command(version, about, long_about = None)] pub struct CliArgs { /// The name of the image to download - #[arg(short, long)] #[validate(regex(path = *RE_IMAGE_NAME))] pub image_name: String, @@ -33,7 +32,7 @@ impl CliArgs { let validation = args.validate(); if validation.is_err() { - panic!("Invalid arguments: {}", validation.expect_err("wut")); + panic!("Invalid arguments: {}", validation.expect_err("Invalid arguments given")); } args diff --git a/src/fs-gen/src/image_builder.rs b/src/fs-gen/src/image_builder.rs index 8319048..60edc4a 100644 --- a/src/fs-gen/src/image_builder.rs +++ b/src/fs-gen/src/image_builder.rs @@ -1,7 +1,9 @@ -use std::path::{Path, PathBuf}; +//! Image builder module +use std::path::{Path, PathBuf}; use vfs::{FileSystem, OverlayFS, PhysicalFS, VfsPath}; +/// Builds a new initramfs from path blobs and places it into a given destination folder pub fn build_new_image(blob_paths: &Vec, output_folder: &Path) { let virtual_paths = blob_paths .iter() diff --git a/src/fs-gen/src/main.rs b/src/fs-gen/src/main.rs index c827c2c..2656f93 100644 --- a/src/fs-gen/src/main.rs +++ b/src/fs-gen/src/main.rs @@ -1,10 +1,10 @@ +//! Main module for the initramfs tarball generation + use std::{ - path::{Path, PathBuf}, + path::PathBuf, str::FromStr, }; - use clap::Parser; - use crate::{cli_args::CliArgs, image_builder::build_new_image}; mod cli_args; @@ -12,7 +12,6 @@ mod image_builder; fn main() { let args = CliArgs::get_args(); - println!("Hello, world!, {:?}", args); let paths: Vec = vec![PathBuf::from_str("../../image-gen/blobs/sha256/layer_1").unwrap()];