use std::path::PathBuf;
use crate::backend::Command;
use crate::command::builder_collections;
use crate::values::Values;
#[derive(Debug, Clone, PartialEq, 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 Lint {
#[builder(field)]
pub paths: Vec<PathBuf>,
#[builder(default)]
pub values: Values,
pub kube_version: Option<String>,
pub quiet: bool,
pub skip_schema_validation: bool,
pub strict: bool,
pub with_subcharts: bool,
}
builder_collections! {
LintBuilder, lint_builder;
vec paths / path: PathBuf, "`PATH` arguments", "the chart directories or `.tgz` archives";
}
impl Lint {
pub fn builder(path: impl Into<PathBuf>) -> LintBuilder {
Self::start().path(path)
}
#[must_use]
pub fn new(path: impl Into<PathBuf>) -> Self {
Self::builder(path).build()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum Severity {
Unknown,
Info,
Warning,
Error,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LintMessage {
pub severity: Severity,
pub path: String,
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LintedChart {
pub path: String,
pub messages: Vec<LintMessage>,
pub errors: Vec<String>,
pub failed: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct LintSummary {
pub linted: usize,
pub failed: usize,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LintReport {
pub charts: Vec<LintedChart>,
pub summary: Option<LintSummary>,
}
impl LintReport {
#[must_use]
pub fn passed(&self) -> bool {
self.charts.iter().all(|chart| !chart.failed)
}
}
impl Command for Lint {
type Output = LintReport;
}