use std::time::Duration;
use super::{DryRun, Force, ServerSide, WaitStrategy};
use crate::backend::Command;
use crate::command::builder_collections;
use crate::release::Revision;
#[derive(Debug, Clone, PartialEq, Eq, bon::Builder)]
#[builder(on(String, into), on(bool, default))]
pub struct Rollback {
#[builder(start_fn)]
pub release: String,
pub revision: Option<Revision>,
pub cleanup_on_fail: bool,
pub description: Option<String>,
pub dry_run: Option<DryRun>,
pub force: Option<Force>,
pub history_max: Option<u32>,
pub no_hooks: bool,
pub server_side: Option<ServerSide>,
pub timeout: Option<Duration>,
pub wait: Option<WaitStrategy>,
pub wait_for_jobs: bool,
}
impl Rollback {
#[must_use]
pub fn new(release: impl Into<String>) -> Self {
Self::builder(release).build()
}
}
impl Command for Rollback {
type Output = ();
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Cascade {
Background,
Orphan,
Foreground,
}
impl Cascade {
#[must_use]
pub fn as_str(self) -> &'static str {
match self {
Self::Background => "background",
Self::Orphan => "orphan",
Self::Foreground => "foreground",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, bon::Builder)]
#[builder(start_fn(name = start, vis = ""), on(String, into), on(bool, default))]
#[allow(clippy::struct_excessive_bools, reason = "one field per Helm flag")]
pub struct Uninstall {
#[builder(field)]
pub releases: Vec<String>,
pub cascade: Option<Cascade>,
pub description: Option<String>,
pub dry_run: bool,
pub ignore_not_found: bool,
pub keep_history: bool,
pub no_hooks: bool,
pub timeout: Option<Duration>,
pub wait: Option<WaitStrategy>,
}
builder_collections! {
UninstallBuilder, uninstall_builder;
vec releases / release: String, "`RELEASE_NAME` arguments", "the releases to uninstall";
}
impl Uninstall {
pub fn builder(release: impl Into<String>) -> UninstallBuilder {
Self::start().release(release)
}
#[must_use]
pub fn new(release: impl Into<String>) -> Self {
Self::builder(release).build()
}
}
impl Command for Uninstall {
type Output = ();
}
#[derive(Debug, Clone, PartialEq, Eq, bon::Builder)]
#[builder(on(String, into), on(bool, default))]
pub struct Test {
#[builder(start_fn)]
pub release: String,
#[builder(field)]
pub filter: Vec<String>,
pub logs: bool,
pub timeout: Option<Duration>,
}
builder_collections! {
TestBuilder, test_builder;
vec filter / add_filter: String, "repeated flag `--filter`",
"`name=value` to include or `!name=value` to exclude a test";
}
impl Test {
#[must_use]
pub fn new(release: impl Into<String>) -> Self {
Self::builder(release).build()
}
}
impl Command for Test {
type Output = String;
}