use super::{ChartPathOptions, ChartRef};
use crate::backend::Command;
use crate::chart::Metadata;
use crate::manifest::Manifest;
macro_rules! show_command {
($(#[$meta:meta])* $name:ident => $output:ty) => {
$(#[$meta])*
#[derive(Debug, Clone, PartialEq, bon::Builder)]
#[builder(on(bool, default))]
pub struct $name {
/// The chart to inspect (`[CHART]`).
#[builder(start_fn)]
pub chart: ChartRef,
#[builder(default)]
pub chart_path: ChartPathOptions,
pub devel: bool,
}
impl $name {
#[must_use]
pub fn new(chart: ChartRef) -> Self {
Self::builder(chart).build()
}
}
impl Command for $name {
type Output = $output;
}
};
}
show_command! {
ShowChart => Metadata
}
show_command! {
ShowReadme => Option<String>
}
show_command! {
ShowCrds => Manifest
}
show_command! {
ShowAll => ChartInfo
}
#[derive(Debug, Clone, PartialEq, bon::Builder)]
#[builder(on(String, into), on(bool, default))]
pub struct ShowValues {
#[builder(start_fn)]
pub chart: ChartRef,
#[builder(default)]
pub chart_path: ChartPathOptions,
pub devel: bool,
pub jsonpath: Option<String>,
}
impl ShowValues {
#[must_use]
pub fn new(chart: ChartRef) -> Self {
Self::builder(chart).build()
}
}
impl Command for ShowValues {
type Output = Option<String>;
}
#[derive(Debug, Clone, PartialEq)]
pub struct ChartInfo {
pub metadata: Metadata,
pub values: Option<String>,
pub readme: Option<String>,
pub crds: Manifest,
}