diff --git a/helmule/examples/giantswarm/charts/zot.yaml b/helmule/examples/giantswarm/charts/zot.yaml index a8a6f9a..3b17f9b 100644 --- a/helmule/examples/giantswarm/charts/zot.yaml +++ b/helmule/examples/giantswarm/charts/zot.yaml @@ -21,5 +21,4 @@ patches: git: path: ../patches/git/zot.patch mirrors: - # - apps-git - - custom-command + - apps-git diff --git a/helmule/examples/giantswarm/helmule.yaml b/helmule/examples/giantswarm/helmule.yaml index d0533ba..3bd26c2 100644 --- a/helmule/examples/giantswarm/helmule.yaml +++ b/helmule/examples/giantswarm/helmule.yaml @@ -4,6 +4,10 @@ variables: include: - kind: Charts path: ./charts/zot.yaml + - kind: Charts + path: ./charts/gitops-server.yaml + - kind: Charts + path: ./charts/external-secrets-operator.yaml patches: - name: yamlfmt custom_command: @@ -52,10 +56,3 @@ mirrors: commit: |- chore: mirror {{ name }}-{{ version }} upstream_repo: {{ repo_url }} - - name: custom-commands - custom_command: - package: - - helm package -d package . - upload: - - helm push ./package/{{ name }}-{{ version }}.tgz oci://registry.badhouseplants.net - - rm -rf ./package diff --git a/helmule/src/config.rs b/helmule/src/config.rs index 4ac0545..8a21e65 100644 --- a/helmule/src/config.rs +++ b/helmule/src/config.rs @@ -18,12 +18,6 @@ pub(crate) enum SupportedIncludes { Charts, } - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Default)] -pub(crate) struct Hooks{ - pre_hooks: Option>, - post_hooks: Option> -} #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Default)] pub(crate) struct ChartExtended { #[serde(flatten)] @@ -58,7 +52,6 @@ pub(crate) struct Config { pub(crate) patches: Option>, #[serde(default = "empty_vec")] pub(crate) mirrors: Vec, - pub(crate) hooks: Hooks, } fn empty_vec() -> Vec { diff --git a/helmule/src/main.rs b/helmule/src/main.rs index 44ee561..0f9f147 100644 --- a/helmule/src/main.rs +++ b/helmule/src/main.rs @@ -61,7 +61,6 @@ fn exec(args: Args) -> Result<(), Box> { // First step is to pull the chart to the working dir let current_repo = chart.chart.find_repo(config.repositories.clone())?; let chart_path = current_repo.pull_chart(chart.chart.clone(), workdir_path.clone())?; - chart.chart.version = current_repo.get_version(chart_path.clone())?; if let Some(extensions) = chart.extensions.clone() { extensions .into_iter() @@ -90,7 +89,7 @@ fn exec(args: Args) -> Result<(), Box> { message_empty(&format!("{}", chart.chart.name)); Ok(()) })?; - Ok(()) + todo!() } fn main() { diff --git a/helmule/src/mirror/custom_command.rs b/helmule/src/mirror/custom_command.rs index c11ef17..e01f426 100644 --- a/helmule/src/mirror/custom_command.rs +++ b/helmule/src/mirror/custom_command.rs @@ -12,7 +12,7 @@ pub(crate) struct CustomCommands { impl Target for CustomCommands { fn push( &self, - _: String, + workdir_path: String, chart_path: String, chart_local: ChartExtended, dry_run: bool, @@ -21,14 +21,14 @@ impl Target for CustomCommands { let mut reg = helmzoo_lib::template::register_handlebars(); reg.register_template_string("cmd", cmd_tmpl)?; let cmd = reg.render("cmd", &chart_local)?; - cli_exec_from_dir(cmd, chart_path.clone())?; + cli_exec_from_dir(cmd, workdir_path.clone())?; } if !dry_run { for cmd_tmpl in self.upload.clone() { let mut reg = template::register_handlebars(); reg.register_template_string("cmd", cmd_tmpl)?; let cmd = reg.render("cmd", &chart_local)?; - cli_exec_from_dir(cmd, chart_path.clone())?; + cli_exec_from_dir(cmd, workdir_path.clone())?; } } Ok(()) diff --git a/helmule/src/patches.rs b/helmule/src/patches.rs index 13e7155..251fc55 100644 --- a/helmule/src/patches.rs +++ b/helmule/src/patches.rs @@ -1,4 +1,4 @@ - use std::{ +use std::{ fs::{self, read_dir, remove_dir_all, File, OpenOptions}, io::Write, path::{Path, PathBuf}, diff --git a/lib/src/helm/git_repository.rs b/lib/src/helm/git_repository.rs index 156fcee..66637ad 100644 --- a/lib/src/helm/git_repository.rs +++ b/lib/src/helm/git_repository.rs @@ -73,10 +73,4 @@ impl RepositoryImpl for GitRepo { fn get_url(&self) -> String { self.url.clone() } - - fn get_version(&self, chart_path: String) -> Result> { - let cmd = "helm show chart . | yq '.version'".to_string(); - let version = cli_exec_from_dir(cmd, chart_path.clone())?; - Ok(version) - } } diff --git a/lib/src/helm/helm_repository.rs b/lib/src/helm/helm_repository.rs index 81fe1d0..764d67c 100644 --- a/lib/src/helm/helm_repository.rs +++ b/lib/src/helm/helm_repository.rs @@ -30,12 +30,6 @@ impl RepositoryImpl for HelmRepo { fn get_url(&self) -> String { self.url.clone() } - - fn get_version(&self, chart_path: String) -> Result> { - let cmd = "helm show chart . | yq '.version'".to_string(); - let version = cli_exec_from_dir(cmd, chart_path.clone())?; - Ok(version) - } } pub(crate) enum RepoKind { @@ -60,7 +54,7 @@ impl HelmRepo { } } - fn pull_oci(&self, mut chart: Chart, workdir_path: String) -> Result> { + fn pull_oci(&self, chart: Chart, workdir_path: String) -> Result> { let args = match chart.version.as_str() { LATEST_VERSION => "".to_string(), _ => format!("--version {}", chart.version.clone()), @@ -91,11 +85,13 @@ impl HelmRepo { Err(err) => return Err(Box::from(err)), }; + // TODO: Do we really need it? + let cmd = "helm show chart . | yq '.version'".to_string(); + let _version = cli_exec_from_dir(cmd, new_dir_name.clone())?; Ok(new_dir_name) } - - fn pull_default(&self, mut chart: Chart, workdir_path: String) -> Result> { + fn pull_default(&self, chart: Chart, workdir_path: String) -> Result> { // Add repo and update let repo_local_name = general_purpose::STANDARD_NO_PAD.encode(self.get_url()); let cmd = format!("helm repo add {} {}", repo_local_name, self.get_url()); @@ -129,6 +125,9 @@ impl HelmRepo { let cmd = format!("helm repo remove {}", repo_local_name); cli_exec(cmd)?; + // TODO: Do we really need it? + let cmd = "helm show chart . | yq '.version'".to_string(); + let _version = cli_exec_from_dir(cmd, new_dir_name.clone())?; Ok(new_dir_name) } } diff --git a/lib/src/helm/repository.rs b/lib/src/helm/repository.rs index ca36a1b..ec0eebf 100644 --- a/lib/src/helm/repository.rs +++ b/lib/src/helm/repository.rs @@ -27,7 +27,6 @@ pub(crate) enum RepositoryKind { pub trait RepositoryImpl { fn pull_chart(&self, chart: Chart, workdir_path: String) -> Result>; - fn get_version(&self, chart_path: String) -> Result>; fn get_url(&self) -> String; }