Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 83 additions & 6 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ directories = "5.0"
dotenvy = "0.15"
futures = "0.3"
indexmap = { version = "2.2", features = ["serde"] }
indicatif = "0.17.11"
k8s-openapi = { version = "0.24", default-features = false, features = ["v1_32"] }
kube = { version = "0.99", default-features = false, features = ["client", "rustls-tls", "ws", "socks5", "http-proxy"] }
lazy_static = "1.5"
Expand All @@ -54,6 +55,7 @@ termion = "4.0"
tokio = { version = "1.38", features = ["rt-multi-thread", "macros", "fs", "process", "io-std"] }
tower-http = { version = "0.5", features = ["validate-request"] }
tracing = "0.1"
tracing-indicatif = "0.3.9"
tracing-subscriber = "0.3"
url = "2.5"
urlencoding = "2.1.3"
Expand Down
2 changes: 2 additions & 0 deletions rust/stackable-cockpit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ stackable-operator.workspace = true
tera.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing-indicatif.workspace = true
url.workspace = true
urlencoding.workspace = true
utoipa = { workspace = true, optional = true }
which.workspace = true
futures.workspace = true
indicatif.workspace = true

[dev-dependencies]
rstest.workspace = true
9 changes: 6 additions & 3 deletions rust/stackable-cockpit/src/engine/kind/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,12 @@ impl Cluster {
.await
.context(CommandFailedToRunSnafu)?;

ensure!(output.status.success(), CommandErroredOutSnafu {
error: String::from_utf8_lossy(&output.stderr)
});
ensure!(
output.status.success(),
CommandErroredOutSnafu {
error: String::from_utf8_lossy(&output.stderr)
}
);

let output = String::from_utf8_lossy(&output.stdout);
Ok(output.lines().any(|name| name == cluster_name))
Expand Down
9 changes: 6 additions & 3 deletions rust/stackable-cockpit/src/oci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,12 @@ pub async fn get_oci_index<'a>() -> Result<HashMap<&'a str, ChartSourceMetadata>
HELM_REPO_NAME_TEST,
HELM_REPO_NAME_DEV,
] {
source_index_files.insert(repo_name, ChartSourceMetadata {
entries: HashMap::new(),
});
source_index_files.insert(
repo_name,
ChartSourceMetadata {
entries: HashMap::new(),
},
);
}
let base_url = format!("https://{HELM_OCI_BASE}/api/v2.0");

Expand Down
5 changes: 4 additions & 1 deletion rust/stackable-cockpit/src/platform/demo/spec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use indicatif::ProgressStyle;
use serde::{Deserialize, Serialize};
use snafu::{OptionExt, ResultExt, Snafu};
use tracing::{debug, info, instrument, warn};
use tracing::{Span, debug, info, instrument, warn};
use tracing_indicatif::span_ext::IndicatifSpanExt as _;
#[cfg(feature = "openapi")]
use utoipa::ToSchema;

Expand Down Expand Up @@ -189,6 +191,7 @@ impl DemoSpec {
transfer_client: &xfer::Client,
) -> Result<(), Error> {
info!("Installing demo manifests");
Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").unwrap());
Comment thread
NickLarsenNZ marked this conversation as resolved.
Outdated

let params = install_params
.parameters
Expand Down
11 changes: 10 additions & 1 deletion rust/stackable-cockpit/src/platform/manifests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use std::collections::HashMap;

use indicatif::ProgressStyle;
use snafu::{ResultExt, Snafu};
use stackable_operator::kvp::Labels;
use tracing::{debug, info, instrument};
use tracing::{Span, debug, info, instrument};
use tracing_indicatif::span_ext::IndicatifSpanExt as _;

use crate::{
common::manifest::ManifestSpec,
Expand Down Expand Up @@ -74,6 +76,11 @@ pub trait InstallManifestsExt {
) -> Result<(), Error> {
debug!("Installing manifests");

Span::current().pb_set_style(
&ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").unwrap(),
);
Span::current().pb_set_length(manifests.len() as u64);

Comment thread
NickLarsenNZ marked this conversation as resolved.
Outdated
let mut parameters = parameters.clone();
// We add the NAMESPACE parameter, so that stacks/demos can use that to render e.g. the
// fqdn service names [which contain the namespace].
Expand Down Expand Up @@ -145,6 +152,8 @@ pub trait InstallManifestsExt {
.context(DeployManifestSnafu)?
}
}

Span::current().pb_inc(1);
}

Ok(())
Expand Down
28 changes: 19 additions & 9 deletions rust/stackable-cockpit/src/platform/operator/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::{fmt::Display, str::FromStr};

use indicatif::ProgressStyle;
use semver::Version;
use serde::Serialize;
use snafu::{ResultExt, Snafu, ensure};
use tracing::{info, instrument};
use tracing::{info, instrument, Span};
use tracing_indicatif::{indicatif_println, span_ext::IndicatifSpanExt};

use crate::{
constants::{
Expand Down Expand Up @@ -61,10 +63,15 @@ pub struct OperatorSpec {

impl Display for OperatorSpec {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}{}", self.name, match &self.version {
Some(v) => format!("={v}"),
None => "".into(),
})
write!(
f,
"{}{}",
self.name,
match &self.version {
Some(v) => format!("={v}"),
None => "".into(),
}
Comment thread
xeniape marked this conversation as resolved.
Outdated
)
}
}

Expand All @@ -86,9 +93,10 @@ impl FromStr for OperatorSpec {
ensure!(len <= 2, InvalidEqualSignCountSnafu);

// Check if the provided operator name is in the list of valid operators
ensure!(VALID_OPERATORS.contains(&parts[0]), InvalidNameSnafu {
name: parts[0]
});
ensure!(
VALID_OPERATORS.contains(&parts[0]),
InvalidNameSnafu { name: parts[0] }
);

// If there is only one part, the input didn't include
// the optional version identifier
Expand Down Expand Up @@ -186,6 +194,8 @@ impl OperatorSpec {
chart_source: &ChartSourceType,
) -> Result<(), helm::Error> {
info!(operator = %self, "Installing operator");
Span::current().pb_set_message(format!("Installing {}-operator", self.name).as_str());
Comment thread
xeniape marked this conversation as resolved.
Outdated
Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").unwrap());

let version = self.version.as_ref().map(|v| v.to_string());
let helm_name = self.helm_name();
Expand Down Expand Up @@ -221,7 +231,7 @@ impl OperatorSpec {
{
match helm::uninstall_release(&self.helm_name(), namespace.as_ref(), true) {
Ok(status) => {
println!("{status}");
indicatif_println!("{}", status);
Comment thread
NickLarsenNZ marked this conversation as resolved.
Outdated
Ok(())
}
Err(err) => Err(err),
Expand Down
Loading
Loading