Add variables and template mirror url

This commit is contained in:
2024-01-10 15:50:56 +01:00
parent b36bde0b83
commit 0f936a645c
8 changed files with 64 additions and 25 deletions

View File

@ -1,4 +1,4 @@
use std::fs::{self, rename};
use std::{fs::{self, rename}, collections::HashMap};
use crate::helpers::cli::{cli_exec, cli_exec_from_dir};
use base64::{engine::general_purpose, Engine as _};
@ -24,7 +24,7 @@ impl From<crate::config::Chart> for Git {
}
impl Repo for Git {
fn pull(&self, workdir_path: String) -> Result<ChartLocal, Box<dyn std::error::Error>> {
fn pull(&self, workdir_path: String, vars: HashMap<String, String>) -> Result<ChartLocal, Box<dyn std::error::Error>> {
let repo_local_name = general_purpose::STANDARD_NO_PAD.encode(self.git_url.clone());
let cmd = format!(
"git clone {} {}/{}",
@ -64,6 +64,7 @@ impl Repo for Git {
version,
path: new_dir_name,
repo_url: self.git_url.clone(),
vars,
})
}
}

View File

@ -1,7 +1,7 @@
use super::{ChartLocal, Repo};
use crate::helpers::cli::{cli_exec, cli_exec_from_dir};
use base64::{engine::general_purpose, Engine as _};
use std::fs::rename;
use std::{fs::rename, collections::HashMap};
pub(crate) enum RepoKind {
Default,
@ -46,7 +46,7 @@ impl Helm {
}
}
fn pull_default(&self, workdir_path: String) -> Result<ChartLocal, Box<dyn std::error::Error>> {
fn pull_default(&self, workdir_path: String, vars: HashMap<String, String>) -> Result<ChartLocal, Box<dyn std::error::Error>> {
// Add repo and update
let repo_local_name = general_purpose::STANDARD_NO_PAD.encode(self.repository_url.clone());
let cmd = format!("helm repo add {} {}", repo_local_name, self.repository_url);
@ -87,15 +87,16 @@ impl Helm {
version,
path: new_dir_name,
repo_url: self.repository_url.clone(),
vars,
})
}
}
impl Repo for Helm {
fn pull(&self, workdir_path: String) -> Result<ChartLocal, Box<dyn std::error::Error>> {
fn pull(&self, workdir_path: String, vars: HashMap<String, String>) -> Result<ChartLocal, Box<dyn std::error::Error>> {
let repository_kind = self.repo_kind_from_url()?;
let path = match repository_kind {
RepoKind::Default => self.pull_default(workdir_path)?,
RepoKind::Default => self.pull_default(workdir_path, vars)?,
RepoKind::Oci => {
todo!()
}

View File

@ -1,3 +1,5 @@
use std::collections::HashMap;
use crate::config::Chart;
use serde::{Deserialize, Serialize};
@ -10,6 +12,7 @@ pub(crate) struct ChartLocal {
pub(crate) version: String,
pub(crate) path: String,
pub(crate) repo_url: String,
pub(crate) vars: HashMap<String, String>
}
impl ChartLocal {
@ -19,7 +22,7 @@ impl ChartLocal {
}
pub(crate) trait Repo {
fn pull(&self, workdir_path: String) -> Result<ChartLocal, Box<dyn std::error::Error>>;
fn pull(&self, workdir_path: String, vars: HashMap<String, String>) -> Result<ChartLocal, Box<dyn std::error::Error>>;
}
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]