feat: TUI does not require Topology to implement Debug anymore
This commit is contained in:
parent
0857aba039
commit
45668638e1
@ -17,7 +17,7 @@ async fn main() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let maestro = Maestro::<K8sAnywhereTopology>::load_from_env();
|
let mut maestro = Maestro::<K8sAnywhereTopology>::load_from_env();
|
||||||
maestro.register_all(vec![Box::new(lamp_stack)]);
|
maestro.register_all(vec![Box::new(lamp_stack)]);
|
||||||
harmony_tui::init(maestro).await.unwrap();
|
harmony_tui::init(maestro).await.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ async fn main() {
|
|||||||
let topology = HAClusterTopology::autoload();
|
let topology = HAClusterTopology::autoload();
|
||||||
let mut maestro = Maestro::new(inventory, topology);
|
let mut maestro = Maestro::new(inventory, topology);
|
||||||
|
|
||||||
|
|
||||||
maestro.register_all(vec![
|
maestro.register_all(vec![
|
||||||
Box::new(SuccessScore {}),
|
Box::new(SuccessScore {}),
|
||||||
Box::new(ErrorScore {}),
|
Box::new(ErrorScore {}),
|
||||||
|
@ -67,10 +67,10 @@ enum HarmonyTuiEvent<T: Topology> {
|
|||||||
LaunchScore(Box<dyn Score<T>>),
|
LaunchScore(Box<dyn Score<T>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <T: Topology> std::fmt::Display for HarmonyTuiEvent<T> {
|
impl<T: Topology> std::fmt::Display for HarmonyTuiEvent<T> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
let output = match self {
|
let output = match self {
|
||||||
HarmonyTuiEvent::LaunchScore(score) => format!("LaunchScore({})",score.name()),
|
HarmonyTuiEvent::LaunchScore(score) => format!("LaunchScore({})", score.name()),
|
||||||
};
|
};
|
||||||
|
|
||||||
f.write_str(&output)
|
f.write_str(&output)
|
||||||
|
@ -19,13 +19,21 @@ enum ExecutionState {
|
|||||||
CANCELED,
|
CANCELED,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct Execution<T: Topology> {
|
struct Execution<T: Topology> {
|
||||||
state: ExecutionState,
|
state: ExecutionState,
|
||||||
score: Box<dyn Score<T>>,
|
score: Box<dyn Score<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
impl<T: Topology> std::fmt::Display for Execution<T> {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.write_fmt(format_args!(
|
||||||
|
"Execution of {} status {:?}",
|
||||||
|
self.score.name(),
|
||||||
|
self.state
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) struct ScoreListWidget<T: Topology> {
|
pub(crate) struct ScoreListWidget<T: Topology> {
|
||||||
list_state: Arc<RwLock<ListState>>,
|
list_state: Arc<RwLock<ListState>>,
|
||||||
scores: Vec<Box<dyn Score<T>>>,
|
scores: Vec<Box<dyn Score<T>>>,
|
||||||
@ -34,7 +42,7 @@ pub(crate) struct ScoreListWidget<T: Topology> {
|
|||||||
sender: mpsc::Sender<HarmonyTuiEvent<T>>,
|
sender: mpsc::Sender<HarmonyTuiEvent<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Topology + std::fmt::Debug> ScoreListWidget<T> {
|
impl<T: Topology> ScoreListWidget<T> {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
scores: Vec<Box<dyn Score<T>>>,
|
scores: Vec<Box<dyn Score<T>>>,
|
||||||
sender: mpsc::Sender<HarmonyTuiEvent<T>>,
|
sender: mpsc::Sender<HarmonyTuiEvent<T>>,
|
||||||
@ -99,7 +107,7 @@ impl<T: Topology + std::fmt::Debug> ScoreListWidget<T> {
|
|||||||
match confirm {
|
match confirm {
|
||||||
true => {
|
true => {
|
||||||
execution.state = ExecutionState::RUNNING;
|
execution.state = ExecutionState::RUNNING;
|
||||||
info!("Launch execution {:?}", execution);
|
info!("Launch execution {execution}");
|
||||||
self.sender
|
self.sender
|
||||||
.send(HarmonyTuiEvent::LaunchScore(execution.score.clone_box()))
|
.send(HarmonyTuiEvent::LaunchScore(execution.score.clone_box()))
|
||||||
.await
|
.await
|
||||||
|
Loading…
Reference in New Issue
Block a user