feat: Report execution outcome #151
@ -18,7 +18,7 @@ async fn main() {
|
|||||||
name: "harmony-example-tryrust".to_string(),
|
name: "harmony-example-tryrust".to_string(),
|
||||||
project_root: PathBuf::from("./tryrust.org"),
|
project_root: PathBuf::from("./tryrust.org"),
|
||||||
framework: Some(RustWebFramework::Leptos),
|
framework: Some(RustWebFramework::Leptos),
|
||||||
service_port: 8080,
|
service_port: 3000,
|
||||||
});
|
});
|
||||||
|
|
||||||
let discord_receiver = DiscordWebhook {
|
let discord_receiver = DiscordWebhook {
|
||||||
|
@ -88,10 +88,10 @@ pub struct Outcome {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Outcome {
|
impl Outcome {
|
||||||
pub fn noop() -> Self {
|
pub fn noop(message: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
status: InterpretStatus::NOOP,
|
status: InterpretStatus::NOOP,
|
||||||
message: String::new(),
|
message,
|
||||||
details: vec![],
|
details: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,9 @@ impl<T: Topology + PrometheusApplicationMonitoring<CRDPrometheus>> Interpret<T>
|
|||||||
PreparationOutcome::Success { details: _ } => {
|
PreparationOutcome::Success { details: _ } => {
|
||||||
Ok(Outcome::success("Prometheus installed".into()))
|
Ok(Outcome::success("Prometheus installed".into()))
|
||||||
}
|
}
|
||||||
PreparationOutcome::Noop => Ok(Outcome::noop()),
|
PreparationOutcome::Noop => {
|
||||||
|
Ok(Outcome::noop("Prometheus installation skipped".into()))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Err(err) => Err(InterpretError::from(err)),
|
Err(err) => Err(InterpretError::from(err)),
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,9 @@ impl<T: Topology + PrometheusApplicationMonitoring<RHOBObservability>> Interpret
|
|||||||
PreparationOutcome::Success { details: _ } => {
|
PreparationOutcome::Success { details: _ } => {
|
||||||
Ok(Outcome::success("Prometheus installed".into()))
|
Ok(Outcome::success("Prometheus installed".into()))
|
||||||
}
|
}
|
||||||
PreparationOutcome::Noop => Ok(Outcome::noop()),
|
PreparationOutcome::Noop => {
|
||||||
|
Ok(Outcome::noop("Prometheus installation skipped".into()))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Err(err) => Err(InterpretError::from(err)),
|
Err(err) => Err(InterpretError::from(err)),
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,13 @@ impl<T: Topology + HelmCommand + K8sclient + MultiTargetTopology> Interpret<T> f
|
|||||||
.await?;
|
.await?;
|
||||||
info!("user added");
|
info!("user added");
|
||||||
|
|
||||||
Ok(Outcome::success("Ntfy installed".to_string()))
|
Ok(Outcome::success_with_details(
|
||||||
|
"Ntfy installed".to_string(),
|
||||||
|
vec![format!(
|
||||||
|
"Ntfy ({}): http://{}",
|
||||||
|
self.score.namespace, self.score.host
|
||||||
|
)],
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_name(&self) -> InterpretName {
|
fn get_name(&self) -> InterpretName {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use harmony::instrumentation::{self, HarmonyEvent};
|
use harmony::instrumentation::{self, HarmonyEvent};
|
||||||
use log::info;
|
|
||||||
|
use crate::theme;
|
||||||
|
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
let details: Mutex<Vec<String>> = Mutex::new(vec![]);
|
let details: Mutex<Vec<String>> = Mutex::new(vec![]);
|
||||||
@ -21,11 +22,14 @@ pub fn init() {
|
|||||||
if outcome.status == harmony::interpret::InterpretStatus::SUCCESS {
|
if outcome.status == harmony::interpret::InterpretStatus::SUCCESS {
|
||||||
details.extend(outcome.details.clone());
|
details.extend(outcome.details.clone());
|
||||||
}
|
}
|
||||||
} else if let HarmonyEvent::HarmonyFinished = event {
|
} else if let HarmonyEvent::HarmonyFinished = event
|
||||||
info!("Here's a summary of what happened:");
|
&& !details.is_empty()
|
||||||
|
{
|
||||||
|
println!("\n{} All done! What's next for you:", theme::EMOJI_SUMMARY);
|
||||||
for detail in details.iter() {
|
for detail in details.iter() {
|
||||||
println!("{detail}");
|
println!("- {detail}");
|
||||||
}
|
}
|
||||||
|
println!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -9,6 +9,7 @@ pub static EMOJI_ERROR: Emoji<'_, '_> = Emoji("⚠️", "");
|
|||||||
pub static EMOJI_DEPLOY: Emoji<'_, '_> = Emoji("🚀", "");
|
pub static EMOJI_DEPLOY: Emoji<'_, '_> = Emoji("🚀", "");
|
||||||
pub static EMOJI_TOPOLOGY: Emoji<'_, '_> = Emoji("📦", "");
|
pub static EMOJI_TOPOLOGY: Emoji<'_, '_> = Emoji("📦", "");
|
||||||
pub static EMOJI_SCORE: Emoji<'_, '_> = Emoji("🎶", "");
|
pub static EMOJI_SCORE: Emoji<'_, '_> = Emoji("🎶", "");
|
||||||
|
pub static EMOJI_SUMMARY: Emoji<'_, '_> = Emoji("🚀", "");
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref SECTION_STYLE: ProgressStyle = ProgressStyle::default_spinner()
|
pub static ref SECTION_STYLE: ProgressStyle = ProgressStyle::default_spinner()
|
||||||
|
Loading…
Reference in New Issue
Block a user