forked from infinyon/fluvio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
infinyon#2427 allowing delete of multiple connectors, smart modules a…
…nd topics. (infinyon#2518) Solves infinyon#2427 Allows delete of multiple: - connectors, - smart modules - topics Left out the cluster delete. Does not seem suitable to be able to delete multiple clusters at once. To be fixed: - [x] continue-on-error instead of ignore-error - [x] changelog entry - [x] update on subcommand description - [x] friendly error message with `CliError::from(error)` - [x] split `CliError::print` - [x] separate error type for multi delete fail Co-authored-by: tomuxmon <tomas.sql@protonmail.com>
- Loading branch information
Showing
10 changed files
with
124 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,52 @@ | ||
use clap::Parser; | ||
use crate::Result; | ||
use crate::error::CliError; | ||
use fluvio::Fluvio; | ||
use fluvio::metadata::smartmodule::SmartModuleSpec; | ||
use tracing::debug; | ||
|
||
/// Delete an existing SmartModule with the given name | ||
#[derive(Debug, Parser)] | ||
pub struct DeleteSmartModuleOpt { | ||
name: String, | ||
/// Continue deleting in case of an error | ||
#[clap(short, long, action, required = false)] | ||
continue_on_error: bool, | ||
/// One or more name(s) of the smart module(s) to be deleted | ||
#[clap(value_name = "name", required = true)] | ||
names: Vec<String>, | ||
} | ||
|
||
impl DeleteSmartModuleOpt { | ||
pub async fn process(self, fluvio: &Fluvio) -> Result<()> { | ||
let admin = fluvio.admin().await; | ||
admin.delete::<SmartModuleSpec, _>(&self.name).await?; | ||
Ok(()) | ||
let mut err_happened = false; | ||
for name in self.names.iter() { | ||
debug!(name, "deleting smart module"); | ||
if let Err(error) = admin.delete::<SmartModuleSpec, _>(name).await { | ||
let error = CliError::from(error); | ||
err_happened = true; | ||
if self.continue_on_error { | ||
let user_error = match error.get_user_error() { | ||
Ok(usr_err) => usr_err.to_string(), | ||
Err(err) => format!("{}", err), | ||
}; | ||
println!( | ||
"smart module \"{}\" delete failed with: {}", | ||
name, user_error | ||
); | ||
} else { | ||
return Err(error); | ||
} | ||
} else { | ||
println!("smart module \"{}\" deleted", name); | ||
} | ||
} | ||
if err_happened { | ||
Err(CliError::CollectedError( | ||
"Failed deleting smart module(s). Check previous errors.".to_string(), | ||
)) | ||
} else { | ||
Ok(()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters