-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add progress indicator to fluvio cluster --k8 --setup command
- Loading branch information
Showing
2 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
use crate::{CheckResult, ClusterError, StartStatus, render::ProgressRenderedText}; | ||
|
||
#[derive(Debug)] | ||
pub enum SetupProgressMessage { | ||
PreFlightCheck(u64), | ||
Check(CheckResult), | ||
} | ||
|
||
#[derive(Debug)] | ||
pub enum InstallProgressMessage { | ||
PreFlightCheck(u64), | ||
Check(CheckResult), | ||
ClientLoaded, | ||
CrdChecked, | ||
ClusterError(ClusterError), | ||
Installing, | ||
ScLaunched, | ||
SpuGroupLaunched(u16), | ||
ConfirmSpu, | ||
ProfileSet, | ||
StartStatus(StartStatus), | ||
} | ||
|
||
impl ProgressRenderedText for InstallProgressMessage { | ||
fn text(&self) -> String { | ||
use colored::*; | ||
|
||
match self { | ||
InstallProgressMessage::PreFlightCheck(_n) => { | ||
format!("{}", "Running pre-flight checks".bold()) | ||
} | ||
InstallProgressMessage::Check(check) => check.text(), | ||
|
||
InstallProgressMessage::ClientLoaded => { | ||
format!("{:>13} {}", "Ok: ✅".bold().green(), "Client Loaded") | ||
} | ||
|
||
InstallProgressMessage::Installing => { | ||
format!("{}", "Installing fluvio".bold()) | ||
} | ||
InstallProgressMessage::CrdChecked => { | ||
format!("{:>13} {}", "Ok: ✅".bold().green(), "CRD is ok") | ||
} | ||
InstallProgressMessage::ClusterError(err) => err.to_string(), | ||
InstallProgressMessage::ScLaunched => { | ||
format!("{:>13} {}", "Ok: ✅".bold().green(), "SC Launched") | ||
} | ||
InstallProgressMessage::SpuGroupLaunched(spu_num) => { | ||
format!( | ||
"{:>13} {} ({})", | ||
"Ok: ✅".bold().green(), | ||
"SPU group launched", | ||
spu_num | ||
) | ||
} | ||
InstallProgressMessage::ConfirmSpu => { | ||
format!("{:>13} {}", "Ok: ✅".bold().green(), "SPU confirmed") | ||
} | ||
|
||
InstallProgressMessage::ProfileSet => { | ||
format!("{:>13} {}", "Ok: ✅".bold().green(), "Profile set") | ||
} | ||
|
||
InstallProgressMessage::StartStatus(status) => { | ||
format!( | ||
"{} {}", | ||
"Fluvio installed with address:".bold(), | ||
status.address, | ||
) | ||
} | ||
} | ||
} | ||
fn next_step_text(&self) -> Option<String> { | ||
match self { | ||
InstallProgressMessage::PreFlightCheck(_n) => Some("Running checks".to_string()), | ||
InstallProgressMessage::Check(_check) => None, | ||
InstallProgressMessage::ClientLoaded => Some("Checking CRD".to_string()), | ||
InstallProgressMessage::Installing => Some("Loading client...".to_string()), | ||
InstallProgressMessage::CrdChecked => Some("Launching SC".to_string()), | ||
InstallProgressMessage::ClusterError(_err) => None, | ||
InstallProgressMessage::ScLaunched => Some("Launching SPU Group".to_string()), | ||
InstallProgressMessage::SpuGroupLaunched(_spu_num) => Some("Confirming SPUs".into()), | ||
InstallProgressMessage::ConfirmSpu => Some("Setting profile".to_string()), | ||
InstallProgressMessage::ProfileSet => None, | ||
InstallProgressMessage::StartStatus(_status) => None, | ||
} | ||
} | ||
} | ||
|
||
impl From<SetupProgressMessage> for InstallProgressMessage { | ||
fn from(progress: SetupProgressMessage) -> Self { | ||
match progress { | ||
SetupProgressMessage::PreFlightCheck(n) => InstallProgressMessage::PreFlightCheck(n), | ||
SetupProgressMessage::Check(check_result) => { | ||
InstallProgressMessage::Check(check_result) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters