platz-chart-ext 0.7.0

Platz Helm chart extensions
Documentation
use super::v0::{ChartExtCardinality, ChartExtStatusFeature};
use crate::versions::{ChartExtKindFeatures, ChartExtVersionV1Beta2};
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct ChartExtFeaturesV1Beta2 {
    pub api_version: ChartExtVersionV1Beta2,
    pub kind: ChartExtKindFeatures,
    pub spec: ChartExtFeaturesSpec,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ChartExtFeaturesSpec {
    /// When true, values.yaml is injected with an `ingress` section
    /// that matches the structure generated by `helm create`. This
    /// generates the hostname and sets TLS correctly.
    #[serde(default)]
    pub ingress: ChartExtIngress,

    /// Sets an HTTP endpoint that returns a platz_sdk::PlatzStatus
    /// and displayed as part of the deployment page.
    pub status: Option<ChartExtStatusFeature>,

    /// Allow deploying OnePerCluster or Many.
    #[serde(default)]
    pub cardinality: ChartExtCardinality,

    /// Should dependent deployments be reinstalled when this deployment
    /// config/values are updated. This doesn't apply to renames or
    /// moving between clusters which always reinstalls dependencies.
    #[serde(default = "yes")]
    pub reinstall_dependencies: bool,

    /// Paths to inject the node selector to. Node selector is always
    /// added at the values top level `nodeSelector`.
    #[serde(default)]
    pub node_selector_paths: Vec<Vec<String>>,

    /// Same for tolerations
    #[serde(default)]
    pub tolerations_paths: Vec<Vec<String>>,

    /// Control how the deployment is displayed
    #[serde(default)]
    pub display: ChartExtDeploymentDisplay,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ChartExtIngress {
    pub enabled: bool,
    #[serde(default)]
    pub hostname_format: ChartExtIngressHostnameFormat,
}

fn yes() -> bool {
    true
}

impl From<bool> for ChartExtIngress {
    fn from(standard_ingress: bool) -> Self {
        Self {
            enabled: standard_ingress,
            hostname_format: Default::default(),
        }
    }
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum ChartExtIngressHostnameFormat {
    Name,
    #[default]
    KindAndName,
}

#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde(deny_unknown_fields)]
pub struct ChartExtDeploymentDisplay {
    pub name: Option<ChartExtDeploymentDisplayName>,
    pub icon: Option<ChartExtDeploymentDisplayIcon>,
}

#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum ChartExtDeploymentDisplayName {
    DeploymentName,
    InputField(ChartExtDeploymentDisplayNameInputField),
}

#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde(deny_unknown_fields)]
pub struct ChartExtDeploymentDisplayNameInputField {
    pub name: String,
}

#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde(deny_unknown_fields)]
pub struct ChartExtDeploymentDisplayIcon {
    pub font_awesome: String,
}