-
Notifications
You must be signed in to change notification settings - Fork 8
libvirt-run: Add --update-from-host #142
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
Conversation
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.
Code Review
This pull request introduces an --update-from-host flag to libvirt-run to streamline upgrading from a local build. The changes are well-structured, adding a new target_transport option and propagating it through the system, including metadata and documentation. My review includes suggestions to improve command-line argument handling for robustness and consistency, and a minor point on code maintainability by avoiding a magic string.
crates/kit/src/install_options.rs
Outdated
| if let Some(t) = self.target_transport.as_deref() { | ||
| args.push(format!("--target-transport={t}")); | ||
| } |
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.
The argument for target_transport is being formatted as a single string "--target-transport={t}". This is inconsistent with how filesystem and root_size arguments are handled, which are pushed as two separate strings ("--filesystem", filesystem.clone()). For consistency and to avoid potential issues with how bootc parses arguments, it would be better to follow the existing pattern for options with values.
| if let Some(t) = self.target_transport.as_deref() { | |
| args.push(format!("--target-transport={t}")); | |
| } | |
| if let Some(ref t) = self.target_transport { | |
| args.push("--target-transport".to_string()); | |
| args.push(t.clone()); | |
| } |
crates/kit/src/libvirt/run.rs
Outdated
| #[clap(long)] | ||
| pub update_from_host: bool, |
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.
The --update-from-host flag implicitly sets --target-transport to containers-storage. If a user specifies both --update-from-host and a different --target-transport, the user-provided transport will be silently overridden. This could be confusing.
To prevent this, you can make the arguments mutually exclusive using clap's conflicts_with attribute. This will cause clap to error out if both are provided, making the behavior clearer to the user.
| #[clap(long)] | |
| pub update_from_host: bool, | |
| #[clap(long, conflicts_with = "target-transport")] | |
| pub update_from_host: bool, |
crates/kit/src/libvirt/run.rs
Outdated
|
|
||
| if opts.update_from_host { | ||
| opts.bind_storage_ro = true; | ||
| opts.install.target_transport = Some("containers-storage".to_owned()); |
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.
This streamlines the UX of upgrading from a local build; it's part of the idea of bootc-dev#86 but this is a lot smaller than that. Signed-off-by: Colin Walters <[email protected]>
d0c785b to
82f8284
Compare
This streamlines the UX of upgrading from a local build; it's part of the idea of #86 but this is a lot smaller than that.