Change include type to struct

This commit is contained in:
Nikolai Rodionov 2024-01-11 18:27:52 +01:00
parent 2ca5e7394b
commit 77f1d0dcb9
Signed by: allanger
GPG Key ID: 0AA46A90E25592AD
4 changed files with 68 additions and 7 deletions

View File

@ -0,0 +1,54 @@
- name: vaultwarden
repository: badhouseplants
version: latest
extensions:
- name: Add virtual service to the chartc
target_dir: templates/extensions
source_dir: ./examples/extensions/vaultwarden
patches:
- name: Git patch 1
git:
path: ./examples/patches/git/patch.diff
- name: Git patch 2
git:
path: ./examples/patches/git/patch-2.diff
- name: yaml-fmt
custom_command:
commands:
- |-
cat <<EOT >> .yamlfmt
formatter:
pad_line_comments: 2
EOT
- yamlfmt values.yaml --conf ./yamlfmt.yaml
- rm -f yamlfmt.yaml
mirrors:
- badhouseplants-git
- custom-command
- name: vaultwarden
repository: badhouseplants
version: latest
extensions:
- name: Add virtual service to the chartc
target_dir: templates/extensions
source_dir: ./examples/extensions/vaultwarden
patches:
- name: Git patch 1
git:
path: ./examples/patches/git/patch.diff
- name: Git patch 2
git:
path: ./examples/patches/git/patch-2.diff
- name: yaml-fmt
custom_command:
commands:
- |-
cat <<EOT >> .yamlfmt
formatter:
pad_line_comments: 2
EOT
- yamlfmt values.yaml --conf ./yamlfmt.yaml
- rm -f yamlfmt.yaml
mirrors:
- badhouseplants-git
- custom-command

View File

@ -1,6 +1,7 @@
# mirror charts # mirror charts
include: include:
Charts: ./examples/use/charts/vaultwarden.yaml - kind: Charts
path: ./examples/use/charts/vaultwardens.yaml
repositories: repositories:
- name: metrics-server - name: metrics-server
helm: helm:

View File

@ -8,11 +8,17 @@ pub(crate) enum IncludeTypes {
Repositories, Repositories,
} }
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
pub(crate) struct Include {
kind: IncludeTypes,
path: String,
}
pub(crate) fn apply_includes(config: &mut super::Config) -> Result<(), Box<dyn std::error::Error>> { pub(crate) fn apply_includes(config: &mut super::Config) -> Result<(), Box<dyn std::error::Error>> {
for (kind, path) in config.include.clone().unwrap() { for include in config.include.clone().unwrap() {
match kind { match include.kind {
IncludeTypes::Charts => { IncludeTypes::Charts => {
let mut charts = include_chart(path)?; let mut charts = include_chart(include.path)?;
let extended_charts = match config.charts.clone() { let extended_charts = match config.charts.clone() {
Some(mut existing_charts) => { Some(mut existing_charts) => {
existing_charts.append(&mut charts); existing_charts.append(&mut charts);
@ -23,7 +29,7 @@ pub(crate) fn apply_includes(config: &mut super::Config) -> Result<(), Box<dyn s
config.charts = Some(extended_charts); config.charts = Some(extended_charts);
}, },
IncludeTypes::Mirrors => { IncludeTypes::Mirrors => {
let mut mirrors = include_mirrors(path)?; let mut mirrors = include_mirrors(include.path)?;
let extended_mirrors = match config.mirrors.clone() { let extended_mirrors = match config.mirrors.clone() {
Some(mut existing_mirrors) => { Some(mut existing_mirrors) => {
existing_mirrors.append(&mut mirrors); existing_mirrors.append(&mut mirrors);
@ -34,7 +40,7 @@ pub(crate) fn apply_includes(config: &mut super::Config) -> Result<(), Box<dyn s
config.mirrors = Some(extended_mirrors); config.mirrors = Some(extended_mirrors);
}, },
IncludeTypes::Repositories => { IncludeTypes::Repositories => {
let mut repositories = include_repositories(path)?; let mut repositories = include_repositories(include.path)?;
let extended_repositories = match config.repositories.clone() { let extended_repositories = match config.repositories.clone() {
Some(mut existing_repositories) => { Some(mut existing_repositories) => {
existing_repositories.append(&mut repositories); existing_repositories.append(&mut repositories);

View File

@ -8,7 +8,7 @@ pub(crate) mod include;
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
pub(crate) struct Config { pub(crate) struct Config {
pub(crate) include: Option<HashMap::<include::IncludeTypes, String>>, pub(crate) include: Option<Vec<include::Include>>,
pub(crate) variables: Option<HashMap<String, String>>, pub(crate) variables: Option<HashMap<String, String>>,
pub(crate) repositories: Option<Vec<Repository>>, pub(crate) repositories: Option<Vec<Repository>>,
pub(crate) charts: Option<Vec<Chart>>, pub(crate) charts: Option<Vec<Chart>>,