From 495fae404451d458de56b84b57b7662cbb69eb4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Steinh=C3=A4user?= <42437185+leonsteinhaeuser@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:53:53 +0100 Subject: [PATCH] feat: allow value files and value object properties (#16) * feat: implemented values file handling for applications Signed-off-by: leonsteinhaeuser * docs: added instructions how to use values.yaml files Signed-off-by: leonsteinhaeuser --------- Signed-off-by: leonsteinhaeuser --- README.md | 11 +++++++++++ main.tf | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 1b00645..dd3a351 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,17 @@ module "namespace-management" { } ``` +### With values.yaml + +From module version `v1.4.0` we also support the usage of a `values.yaml` file. By default, if you configured the git generator, we will look for a `values.yaml` inside the `values` folder next to the configured argocd application configuration. The `values.yaml` file will be named after the Helm release name (dashes are replaced by underscores). + +```txt +|--- argo +| |--- values +| | |--- argocd.yaml +| |--- argocd.yaml (chart.release_name: argocd) +``` + ## Cluster selection The cluster selection is based on the `` diff --git a/main.tf b/main.tf index 3b817d6..948532f 100644 --- a/main.tf +++ b/main.tf @@ -90,6 +90,9 @@ resource "argocd_application_set" "this" { helm { release_name = "{{ default \"${var.manifest_source.helm.release_name}\" .chart.release_name }}" values = "{{ .values }}" + // optional properties only if the git generator is not null + value_files = var.generator.git != null ? ["$values/{{ .path.path }}/values/{{ default \"${var.manifest_source.helm.release_name}\" .chart.release_name | replace \"-\" \"_\"}}.yaml"] : [] + ignore_missing_value_files = var.generator.git != null ? true : false } } } @@ -105,6 +108,14 @@ resource "argocd_application_set" "this" { } } } + dynamic "source" { + for_each = var.generator.git != null ? [var.generator.git] : [] + content { + repo_url = var.generator.git.repo_url + target_revision = var.generator.git.revision + ref = "values" + } + } dynamic "ignore_difference" { // to protect against null values, we need to check if the ignore_difference block is not null