platz_chart_ext/
metadata.rs1use crate::versions::HelmChartV2;
2use serde::{Deserialize, Serialize};
3use url::Url;
4
5#[derive(Clone, Debug, Deserialize, Serialize)]
6#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7#[serde(from = "HelmChart")]
8pub struct ChartMetadata {
9 pub version: String,
10 pub git_commit: Option<String>,
11 pub git_branch: Option<String>,
12 pub git_repo: Option<Url>,
13 pub git_provider: Option<String>,
14}
15
16impl From<HelmChart> for ChartMetadata {
17 fn from(chart: HelmChart) -> Self {
18 let annotations = chart.annotations.as_ref();
19 Self {
20 version: chart.version,
21 git_commit: annotations.and_then(|a| a.git_commit.to_owned()),
22 git_branch: annotations.and_then(|a| a.git_branch.to_owned()),
23 git_repo: annotations.and_then(|a| a.git_repo.to_owned()),
24 git_provider: annotations.and_then(|a| a.git_provider.to_owned()),
25 }
26 }
27}
28
29#[derive(Deserialize)]
31#[serde(rename_all = "camelCase")]
32struct HelmChart {
33 #[allow(dead_code)]
34 api_version: HelmChartV2,
35 version: String,
36 annotations: Option<HelmChartAnnotations>,
37}
38
39#[derive(Deserialize)]
40struct HelmChartAnnotations {
41 #[serde(rename = "platz.io/git/commit")]
42 git_commit: Option<String>,
43 #[serde(rename = "platz.io/git/branch")]
44 git_branch: Option<String>,
45 #[serde(rename = "platz.io/git/repo")]
46 git_repo: Option<Url>,
47 #[serde(rename = "platz.io/git/provider")]
48 git_provider: Option<String>,
49}