use std::path::PathBuf;
use std::time::Duration;
use serde::Deserialize;
use super::builder_collections;
use crate::backend::Command;
use crate::options::Secret;
#[derive(Debug, Clone, PartialEq, bon::Builder)]
#[builder(
on(String, into),
on(PathBuf, into),
on(Secret, into),
on(bool, default)
)]
#[allow(clippy::struct_excessive_bools, reason = "one field per Helm flag")]
pub struct RepoAdd {
#[builder(start_fn)]
pub name: String,
#[builder(start_fn)]
pub url: String,
pub username: Option<String>,
pub password: Option<Secret>,
pub pass_credentials: bool,
pub force_update: bool,
pub allow_deprecated_repos: bool,
pub timeout: Option<Duration>,
pub cert_file: Option<PathBuf>,
pub key_file: Option<PathBuf>,
pub ca_file: Option<PathBuf>,
pub insecure_skip_tls_verify: bool,
}
impl RepoAdd {
#[must_use]
pub fn new(name: impl Into<String>, url: impl Into<String>) -> Self {
Self::builder(name, url).build()
}
}
impl Command for RepoAdd {
type Output = ();
}
#[derive(Debug, Clone, PartialEq, Eq, bon::Builder)]
#[builder(on(String, into), on(PathBuf, into), on(bool, default))]
pub struct RepoIndex {
#[builder(start_fn)]
pub dir: PathBuf,
pub url: Option<String>,
pub merge: Option<PathBuf>,
pub json: bool,
}
impl RepoIndex {
#[must_use]
pub fn new(dir: impl Into<PathBuf>) -> Self {
Self::builder(dir).build()
}
}
impl Command for RepoIndex {
type Output = ();
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct RepoList;
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
pub struct Repository {
pub name: String,
pub url: String,
}
impl Command for RepoList {
type Output = Vec<Repository>;
}
#[derive(Debug, Clone, PartialEq, Eq, bon::Builder)]
#[builder(start_fn(name = start, vis = ""))]
pub struct RepoRemove {
#[builder(field)]
pub names: Vec<String>,
}
builder_collections! {
RepoRemoveBuilder, repo_remove_builder;
vec names / name: String, "`REPO` arguments", "the names of the repositories";
}
impl RepoRemove {
pub fn builder(names: impl IntoIterator<Item = impl Into<String>>) -> RepoRemoveBuilder {
Self::start().names(names)
}
#[must_use]
pub fn new(names: impl IntoIterator<Item = impl Into<String>>) -> Self {
Self::builder(names).build()
}
}
impl Command for RepoRemove {
type Output = ();
}
#[derive(Debug, Clone, Default, PartialEq, Eq, bon::Builder)]
#[builder(on(String, into))]
pub struct RepoUpdate {
#[builder(field)]
pub names: Vec<String>,
pub timeout: Option<Duration>,
}
builder_collections! {
RepoUpdateBuilder, repo_update_builder;
vec names / name: String, "`REPO` arguments", "the names of the repositories";
}
impl Command for RepoUpdate {
type Output = ();
}