pub struct DeletePipelineUseCase { /* private fields */ }Expand description
Use case for deleting pipelines from the system.
This use case handles pipeline deletion with safety mechanisms to prevent accidental data loss. It supports both interactive mode (with confirmation) and force mode (for automation).
§Responsibilities
- Look up pipeline by name in repository
- Display pipeline details for verification
- Prompt for user confirmation (unless force mode)
- Delete pipeline from repository
- Provide feedback on success or cancellation
§Dependencies
- Pipeline Repository: For retrieving and deleting pipeline data
§Example
ⓘ
let use_case = DeletePipelineUseCase::new(pipeline_repository);
// Interactive mode
match use_case.execute("test-pipeline".to_string(), false).await {
Ok(()) => println!("Pipeline deleted or cancelled"),
Err(e) => eprintln!("Failed to delete pipeline: {}", e),
}Implementations§
Source§impl DeletePipelineUseCase
impl DeletePipelineUseCase
Sourcepub fn new(pipeline_repository: Arc<SqlitePipelineRepository>) -> Self
pub fn new(pipeline_repository: Arc<SqlitePipelineRepository>) -> Self
Sourcepub async fn execute(&self, pipeline_name: String, force: bool) -> Result<()>
pub async fn execute(&self, pipeline_name: String, force: bool) -> Result<()>
Executes the delete pipeline use case.
Deletes a pipeline from the system with optional confirmation prompt. In interactive mode, displays pipeline details and requires user confirmation before deletion. In force mode, deletes immediately without confirmation.
§Parameters
pipeline_name- Name of the pipeline to deleteforce- If true, bypass confirmation prompt (for automation)
§Behavior
Interactive Mode (force = false):
- Look up pipeline by name
- Display pipeline details
- Prompt user for confirmation (y/yes to proceed)
- Delete if confirmed, cancel otherwise
Force Mode (force = true):
- Look up pipeline by name
- Display pipeline details
- Delete immediately without confirmation
§Returns
Ok(())- Pipeline deleted successfully or deletion cancelledErr(anyhow::Error)- Pipeline not found or deletion failed
§Errors
Returns errors for:
- Pipeline not found with given name
- Repository connection failures
- Database deletion errors
- I/O errors reading user input (interactive mode)
§Example Output (Interactive Mode)
=== Pipeline to Delete ===
Name: test-pipeline
ID: 01H2X3Y4Z5A6B7C8D9E0F1G2H3
Stages: 4
Created: 2025-10-05 14:30:00 UTC
Are you sure you want to delete pipeline 'test-pipeline'? [y/N]: y
✅ Pipeline 'test-pipeline' deleted successfully§Example Output (Force Mode)
=== Pipeline to Delete ===
Name: test-pipeline
ID: 01H2X3Y4Z5A6B7C8D9E0F1G2H3
Stages: 4
Created: 2025-10-05 14:30:00 UTC
✅ Pipeline 'test-pipeline' deleted successfullyAuto Trait Implementations§
impl Freeze for DeletePipelineUseCase
impl !RefUnwindSafe for DeletePipelineUseCase
impl Send for DeletePipelineUseCase
impl Sync for DeletePipelineUseCase
impl Unpin for DeletePipelineUseCase
impl !UnwindSafe for DeletePipelineUseCase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more