Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add feature guards to support minimal cli version #3681

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/fluvio-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ tokio = { workspace = true, features = ["macros"] }
tracing = { workspace = true }
which = { workspace = true }
url = { workspace = true }
cfg-if = { workspace = true }

# Fluvio dependencies
k8-config = { workspace = true, optional = true }
Expand Down
14 changes: 9 additions & 5 deletions crates/fluvio-cli/src/profile/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use clap::Parser;
use anyhow::Result;

use fluvio::config::{ConfigFile, TlsPolicy};
use fluvio_cluster::InstallationType;

#[derive(Debug, Parser)]
pub struct ManualAddOpt {
Expand All @@ -13,7 +12,8 @@ pub struct ManualAddOpt {
cluster_address: String,

/// Installation type of cluster, e.g. local, local-k8, k8
installation_type: Option<InstallationType>,
#[cfg(feature = "k8s")]
matheus-consoli marked this conversation as resolved.
Show resolved Hide resolved
installation_type: Option<fluvio_cluster::InstallationType>,
}
// todo: p2 add tls config, p1 is default disabled for manual add

Expand All @@ -27,9 +27,13 @@ impl ManualAddOpt {
&self.cluster_address,
&def_tls,
)?;
let config = config_file.mut_config().current_cluster_mut()?;
self.installation_type.unwrap_or_default().save_to(config)?;
config_file.save()?;
cfg_if::cfg_if! {
if #[cfg(feature = "k8s")] {
let config = config_file.mut_config().current_cluster_mut()?;
self.installation_type.unwrap_or_default().save_to(config)?;
config_file.save()?;
}
}
println!("Switched to profile {}", &self.profile_name);
}
Err(_) => println!("no profile can be found"),
Expand Down
51 changes: 37 additions & 14 deletions crates/fluvio-cli/src/profile/list.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::sync::Arc;

use fluvio_cluster::InstallationType;
use serde::Serialize;
use comfy_table::Row;
use clap::Parser;
Expand Down Expand Up @@ -50,10 +49,16 @@ fn format_tls(tls: &TlsPolicy) -> &'static str {
}

impl TableOutputHandler for ListConfig<'_> {
#[cfg(feature = "k8s")]
fn header(&self) -> Row {
Row::from(["", "PROFILE", "CLUSTER", "ADDRESS", "TLS", "INSTALLATION"])
}

#[cfg(not(feature = "k8s"))]
fn header(&self) -> Row {
Row::from(["", "PROFILE", "CLUSTER", "ADDRESS", "TLS"])
}

fn content(&self) -> Vec<Row> {
self.0
.profile
Expand All @@ -66,20 +71,38 @@ impl TableOutputHandler for ListConfig<'_> {
.map(|active| if active { "*" } else { "" })
.unwrap_or("");

let (cluster, addr, tls, installation_type) = self
.0
.cluster(&profile.cluster)
.map(|it| {
(
&*profile.cluster,
&*it.endpoint,
format_tls(&it.tls),
InstallationType::load_or_default(it).to_string(),
)
})
.unwrap_or(("", "", "", "".to_string()));
cfg_if::cfg_if! {
if #[cfg(feature = "k8s")] {
let (cluster, addr, tls, installation_type) = self
.0
.cluster(&profile.cluster)
.map(|it| {
(
&*profile.cluster,
&*it.endpoint,
format_tls(&it.tls),
fluvio_cluster::InstallationType::load_or_default(it).to_string(),
)
})
.unwrap_or(("", "", "", "".to_string()));

Row::from([active, profile_name, cluster, addr, tls, &installation_type])
} else {
let (cluster, addr, tls) = self
.0
.cluster(&profile.cluster)
.map(|it| {
(
&*profile.cluster,
&*it.endpoint,
format_tls(&it.tls),
)
})
.unwrap_or(("", "", ""));

Row::from([active, profile_name, cluster, addr, tls, &installation_type])
Row::from([active, profile_name, cluster, addr, tls])
}
}
})
.collect()
}
Expand Down
Loading