Skip to content

Commit

Permalink
Remove progress spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
Techassi committed Nov 20, 2023
1 parent 97f6874 commit 558affd
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 86 deletions.
40 changes: 0 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ serde_json = "1.0"
serde_yaml = "0.9"
sha2 = "0.10"
snafu = "0.7"
spinoff = "0.8.0"
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.55.0" }
tera = "1.18"
tokio = { version = "1.29.0", features = ["rt-multi-thread", "macros", "fs", "process"] }
Expand Down
2 changes: 0 additions & 2 deletions rust/stackable-cockpit/src/engine/kind/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ impl Cluster {
.args(["create", "cluster"])
.args(["--name", self.name.as_str()])
.args(["--config", "-"])
.stdout(Stdio::null())
.stderr(Stdio::null())
.stdin(Stdio::piped())
.spawn()
.context(CommandFailedToStartSnafu)?;
Expand Down
1 change: 0 additions & 1 deletion rust/stackablectl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ serde_json.workspace = true
serde_yaml.workspace = true
serde.workspace = true
snafu.workspace = true
spinoff.workspace = true
tera.workspace = true
tokio.workspace = true
tracing-subscriber.workspace = true
Expand Down
6 changes: 0 additions & 6 deletions rust/stackablectl/src/cmds/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ async fn install_cmd(

// Init result output and progress output
let mut output = cli.result();
output.enable_progress(format!("Installing demo '{}'", args.demo_name));

let demo_spec = list.get(&args.demo_name).ok_or(CmdError::NoSuchDemo {
name: args.demo_name.clone(),
Expand All @@ -286,7 +285,6 @@ async fn install_cmd(
.context(ListSnafu)?;

// Install local cluster if needed
output.set_progress_message("Creating local cluster");
args.local_cluster
.install_if_needed(None)
.await
Expand All @@ -305,22 +303,19 @@ async fn install_cmd(
.unwrap_or(DEFAULT_PRODUCT_NAMESPACE.into());

if !args.skip_release {
output.set_progress_message("Creating operator namespace");
namespace::create_if_needed(operator_namespace.clone())
.await
.context(NamespaceSnafu {
namespace: operator_namespace.clone(),
})?;
}

output.set_progress_message("Creating product namespace");
namespace::create_if_needed(product_namespace.clone())
.await
.context(NamespaceSnafu {
namespace: product_namespace.clone(),
})?;

output.set_progress_message("Installing demo manifests");
demo_spec
.install(
stack_list,
Expand Down Expand Up @@ -358,6 +353,5 @@ async fn install_cmd(
.with_command_hint(stacklet_cmd, "display the installed stacklets")
.with_output(format!("Installed demo '{}'", args.demo_name));

output.finish_progress("Done");
Ok(output.render())
}
5 changes: 0 additions & 5 deletions rust/stackablectl/src/cmds/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,24 +267,20 @@ async fn install_cmd(
match release_list.get(&args.release) {
Some(release) => {
let mut output = cli.result();
output.enable_progress(format!("Installing release '{}'", args.release));

// Install local cluster if needed
output.set_progress_message("Installing local cluster");
args.local_cluster
.install_if_needed(None)
.await
.context(CommonClusterArgsSnafu)?;

// Create operator namespace if needed
output.set_progress_message("Creating operator namespace");
namespace::create_if_needed(args.operator_namespace.clone())
.await
.context(NamespaceSnafu {
namespace: args.operator_namespace.clone(),
})?;

output.set_progress_message("Installing release manifests");
release
.install(
&args.included_products,
Expand All @@ -300,7 +296,6 @@ async fn install_cmd(
)
.with_output(format!("Installed release '{}'", args.release));

output.finish_progress("Done");
Ok(output.render())
}
None => Ok("No such release".into()),
Expand Down
7 changes: 0 additions & 7 deletions rust/stackablectl/src/cmds/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,8 @@ async fn install_cmd(
match stack_list.get(&args.stack_name) {
Some(stack_spec) => {
let mut output = cli.result();
output.enable_progress(format!("Installing stack '{}'", args.stack_name));

// Install local cluster if needed
output.set_progress_message("Creating local cluster");
args.local_cluster
.install_if_needed(None)
.await
Expand All @@ -295,14 +293,12 @@ async fn install_cmd(

// Install release if not opted out
if !args.skip_release {
output.set_progress_message("Creating operator namespace");
namespace::create_if_needed(operator_namespace.clone())
.await
.context(NamespaceSnafu {
namespace: operator_namespace.clone(),
})?;

output.set_progress_message("Installing release manifests");
stack_spec
.install_release(release_list, &operator_namespace, &product_namespace)
.await
Expand All @@ -312,15 +308,13 @@ async fn install_cmd(
}

// Create product namespace if needed
output.set_progress_message("Creating product namespace");
namespace::create_if_needed(product_namespace.clone())
.await
.context(NamespaceSnafu {
namespace: product_namespace.clone(),
})?;

// Install stack
output.set_progress_message("Installing stack manifests");
stack_spec
.install_stack_manifests(
&args.stack_parameters,
Expand Down Expand Up @@ -353,7 +347,6 @@ async fn install_cmd(
.with_command_hint(stacklet_cmd, "display the installed stacklets")
.with_output(format!("Installed stack '{}'", args.stack_name));

output.finish_progress("Done");
Ok(output.render())
}
None => Ok("No such stack".into()),
Expand Down
25 changes: 1 addition & 24 deletions rust/stackablectl/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::{
};

use snafu::{ResultExt, Snafu};
use spinoff::{spinners, Color, Spinner};
use tera::Tera;

mod error;
Expand Down Expand Up @@ -93,7 +92,6 @@ pub struct Output<C>
where
C: ContextExt,
{
progress: Option<Spinner>,
renderer: Tera,
context: C,
}
Expand All @@ -107,28 +105,7 @@ where
let no_color = use_colored_output(!no_color);
context.set_no_color(no_color);

Ok(Self {
progress: None,
renderer,
context,
})
}

pub fn enable_progress(&mut self, initial_message: String) {
self.progress
.get_or_insert(Spinner::new(spinners::Dots, initial_message, Color::Green));
}

pub fn set_progress_message(&mut self, message: impl Into<String>) {
if let Some(progress) = self.progress.as_mut() {
progress.update_text(message.into())
}
}

pub fn finish_progress(&mut self, message: impl AsRef<str>) {
if let Some(progress) = self.progress.as_mut() {
progress.success(message.as_ref())
}
Ok(Self { renderer, context })
}

pub fn render(self) -> String {
Expand Down

0 comments on commit 558affd

Please sign in to comment.