feat: Use inquire::Confirm instead of raw std::io::Read for K8sAnywhere installation confirmation prompt
This commit is contained in:
parent
45668638e1
commit
213fb25686
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1344,6 +1344,7 @@ dependencies = [
|
|||||||
"harmony_macros",
|
"harmony_macros",
|
||||||
"harmony_types",
|
"harmony_types",
|
||||||
"http 1.3.1",
|
"http 1.3.1",
|
||||||
|
"inquire",
|
||||||
"k8s-openapi",
|
"k8s-openapi",
|
||||||
"kube",
|
"kube",
|
||||||
"libredfish",
|
"libredfish",
|
||||||
|
@ -34,6 +34,7 @@ k8s-openapi = { version = "0.24.0", features = ["v1_30"] }
|
|||||||
serde_yaml = "0.9.34"
|
serde_yaml = "0.9.34"
|
||||||
serde-value = "0.7.0"
|
serde-value = "0.7.0"
|
||||||
http = "1.2.0"
|
http = "1.2.0"
|
||||||
|
inquire = "0.7.5"
|
||||||
|
|
||||||
[workspace.dependencies.uuid]
|
[workspace.dependencies.uuid]
|
||||||
version = "1.11.0"
|
version = "1.11.0"
|
||||||
|
@ -30,3 +30,4 @@ k8s-openapi = { workspace = true }
|
|||||||
serde_yaml = { workspace = true }
|
serde_yaml = { workspace = true }
|
||||||
http = { workspace = true }
|
http = { workspace = true }
|
||||||
serde-value = { workspace = true }
|
serde-value = { workspace = true }
|
||||||
|
inquire.workspace = true
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
use inquire::Confirm;
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use tokio::sync::OnceCell;
|
use tokio::sync::OnceCell;
|
||||||
|
|
||||||
@ -76,18 +77,12 @@ impl K8sAnywhereTopology {
|
|||||||
info!("No kubernetes configuration found");
|
info!("No kubernetes configuration found");
|
||||||
|
|
||||||
if !k8s_anywhere_config.autoinstall {
|
if !k8s_anywhere_config.autoinstall {
|
||||||
info!(
|
let confirmation = Confirm::new( "Harmony autoinstallation is not activated, do you wish to launch autoinstallation? : ")
|
||||||
"Harmony autoinstallation is not activated, do you wish to launch autoinstallation? (y/N) : "
|
.with_default(false)
|
||||||
);
|
.prompt()
|
||||||
let mut input = String::new();
|
.expect("Unexpected prompt error");
|
||||||
|
|
||||||
io::stdin()
|
if !confirmation {
|
||||||
.read_line(&mut input)
|
|
||||||
.expect("Failed to read line");
|
|
||||||
|
|
||||||
let input = input.trim();
|
|
||||||
|
|
||||||
if !input.eq_ignore_ascii_case("y") {
|
|
||||||
warn!(
|
warn!(
|
||||||
"Installation cancelled, K8sAnywhere could not initialize a valid Kubernetes client"
|
"Installation cancelled, K8sAnywhere could not initialize a valid Kubernetes client"
|
||||||
);
|
);
|
||||||
|
@ -10,7 +10,7 @@ assert_cmd = "2.0.17"
|
|||||||
clap = { version = "4.5.35", features = ["derive"] }
|
clap = { version = "4.5.35", features = ["derive"] }
|
||||||
harmony = { path = "../harmony" }
|
harmony = { path = "../harmony" }
|
||||||
harmony_tui = { path = "../harmony_tui", optional = true }
|
harmony_tui = { path = "../harmony_tui", optional = true }
|
||||||
inquire = "0.7.5"
|
inquire.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user