-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Building quark #10
base: main
Are you sure you want to change the base?
Building quark #10
Conversation
Signed-off-by: JeremyLARDENOIS <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @JeremyLARDENOIS . I have a few comments on the code and an additional one on the PR/commit: Your single commit should explain what it's doing and why it's doing it. Building quark
wont allow anyone going through future git logs to understand what this commit is about.
|
||
if !self.offline { | ||
println!("Online mode is not supported yet."); | ||
return Ok(()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not supported, you should return an error.
.arg(src) | ||
.arg(workdir) | ||
.status() | ||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No unwrap, please propagate the error instead.
Also, you should consider using the https://docs.rs/fs_extra/1.2.0/fs_extra/index.html crate. It's only based on the std crate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to use it, but I didn't achieve it. I will try again I think
} else { | ||
// If the rootfs doesn't exist, display error message | ||
println!("Rootfs doesn't exist."); | ||
return Ok(()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
|
||
// Change the init script to use the kaps bundle | ||
println!("Changing init script to use the kaps bundle"); | ||
let init_script = format!("{}/{}/init", workdir, rootfs_filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A cleaner way to build an actual path is to use the std::path::Path
crate.
let mut init_script_file = std::fs::File::create(init_script.clone())?; | ||
println!("Writing new init script"); | ||
let kaps_name = self.kaps.split('/').last().unwrap(); | ||
let bundle_name = self.bundle.split('/').last().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of unwraps, lots of potential panics. Return an error (through e.g.map_err
).
// Create initramfs ------------------------------------------------------------ | ||
println!("Creating initramfs"); | ||
let rootfs_workdir = format!("{}/{}", workdir, rootfs_filename); | ||
(subprocess::Exec::shell(format!("find {} -print0", rootfs_workdir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not Command
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there is a bash pipe, and I don't know how to do it without make a bash script
Signed-off-by: JeremyLARDENOIS <[email protected]>
Signed-off-by: JeremyLARDENOIS [email protected]
@sameo Can I have a review? 🙂