feat: Use inquire::Confirm instead of raw std::io::Read for K8sAnywhere installation confirmation prompt
This commit is contained in:
@@ -30,3 +30,4 @@ k8s-openapi = { workspace = true }
|
||||
serde_yaml = { workspace = true }
|
||||
http = { workspace = true }
|
||||
serde-value = { workspace = true }
|
||||
inquire.workspace = true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::io;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use inquire::Confirm;
|
||||
use log::{info, warn};
|
||||
use tokio::sync::OnceCell;
|
||||
|
||||
@@ -76,18 +77,12 @@ impl K8sAnywhereTopology {
|
||||
info!("No kubernetes configuration found");
|
||||
|
||||
if !k8s_anywhere_config.autoinstall {
|
||||
info!(
|
||||
"Harmony autoinstallation is not activated, do you wish to launch autoinstallation? (y/N) : "
|
||||
);
|
||||
let mut input = String::new();
|
||||
let confirmation = Confirm::new( "Harmony autoinstallation is not activated, do you wish to launch autoinstallation? : ")
|
||||
.with_default(false)
|
||||
.prompt()
|
||||
.expect("Unexpected prompt error");
|
||||
|
||||
io::stdin()
|
||||
.read_line(&mut input)
|
||||
.expect("Failed to read line");
|
||||
|
||||
let input = input.trim();
|
||||
|
||||
if !input.eq_ignore_ascii_case("y") {
|
||||
if !confirmation {
|
||||
warn!(
|
||||
"Installation cancelled, K8sAnywhere could not initialize a valid Kubernetes client"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user