Skip to content

Commit

Permalink
Adapt warning API for usage in install
Browse files Browse the repository at this point in the history
The `warning` helper API just became unused by the previous
commit; make it used in another place it should have been.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Feb 2, 2024
1 parent 8702bcc commit e675cbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,9 @@ pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {
.with_context(|| format!("Querying {}", &block_opts.device))?;
if opts.via_loopback {
if !opts.config_opts.generic_image {
eprintln!("Automatically enabling --generic-image when installing via loopback");
std::thread::sleep(std::time::Duration::from_secs(2));
crate::utils::medium_visibility_warning(
"Automatically enabling --generic-image when installing via loopback",
);
opts.config_opts.generic_image = true;
}
if !target_blockdev_meta.file_type().is_file() {
Expand Down
7 changes: 5 additions & 2 deletions lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,16 @@ pub(crate) fn sigpolicy_from_opts(
}
}

/// Output a warning message
pub(crate) fn warning(s: &str) {
/// Output a warning message that we want to be quite visible.
/// The process (thread) execution will be delayed for a short time.
pub(crate) fn medium_visibility_warning(s: &str) {
anstream::eprintln!(
"{}{s}{}",
anstyle::AnsiColor::Red.render_fg(),
anstyle::Reset.render()
);
// When warning, add a sleep to ensure it's seen
std::thread::sleep(std::time::Duration::from_secs(1));
}

/// Given a possibly tagged image like quay.io/foo/bar:latest and a digest 0ab32..., return
Expand Down

0 comments on commit e675cbf

Please sign in to comment.