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: fluvio profile add w/ no config file #3874

Merged
merged 1 commit into from
Feb 21, 2024
Merged
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
28 changes: 13 additions & 15 deletions crates/fluvio-cli/src/profile/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,23 @@ pub struct ManualAddOpt {
/// Installation type of cluster, e.g. local, local-k8, k8
installation_type: Option<InstallationType>,
}
// todo: p2 add tls config, p1 is default disabled for manual add

impl ManualAddOpt {
pub fn process(self) -> Result<()> {
match ConfigFile::load(None) {
Ok(mut config_file) => {
let def_tls = TlsPolicy::Disabled;
config_file.add_or_replace_profile(
&self.profile_name,
&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()?;
println!("Switched to profile {}", &self.profile_name);
let mut config_file = match ConfigFile::load(None) {
Ok(config_file) => config_file,
Err(_) => {
println!("Creating default fluvio config file");
ConfigFile::default_config()?
}
Err(_) => println!("no profile can be found"),
}
};

let def_tls = TlsPolicy::Disabled;
config_file.add_or_replace_profile(&self.profile_name, &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()?;
println!("Switched to profile {}", &self.profile_name);

Ok(())
}
Expand Down
Loading