From f82f4cd9901d8ab0d18acec3840434e11921d840 Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Thu, 14 Sep 2023 13:32:06 +0200 Subject: [PATCH] chore: removed hard coded properties and replaced them with variables --- main.tf | 13 ++++++++----- variables.tf | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/main.tf b/main.tf index 3616f6f..9eb4ee3 100644 --- a/main.tf +++ b/main.tf @@ -5,7 +5,7 @@ locals { resource "argocd_application_set" "this" { metadata { name = "${var.project_name}-${var.name}" - namespace = "argo-system" + namespace = var.namespace } spec { @@ -112,10 +112,13 @@ resource "argocd_application_set" "this" { namespace = var.target_namespace_overwrite != "" ? var.target_namespace_overwrite : "{{ if not .namespace_overwrite }}${var.project_name}-{{ ${local.generator_selector} }}{{ else }}${var.project_name}-{{ .namespace_overwrite }}{{ end }}" } sync_policy { - automated { - prune = true - self_heal = true - allow_empty = true + dynamic "automated" { + for_each = var.sync_policy.automated != null ? [var.sync_policy.automated] : [] + content { + prune = var.sync_policy.automated.prune + self_heal = var.sync_policy.automated.self_heal + allow_empty = var.sync_policy.automated.allow_empty + } } managed_namespace_metadata { annotations = merge( diff --git a/variables.tf b/variables.tf index 8b760fc..1703310 100644 --- a/variables.tf +++ b/variables.tf @@ -3,6 +3,12 @@ variable "name" { description = "The name of the application set" } +variable "namespace" { + type = string + description = "The namespace the application set should be deployed to." + default = "argo-system" +} + variable "project_name" { type = string description = "The name of the ArgoCD project to use for this application set. If not set, this application set is special. Special application sets are managed by the platform team and therefore the ArgoCD project reference is handled differently to normal application sets. A major difference is that the ArgoCD project is not statically defined as reference but dynamically via the config directory name." @@ -133,3 +139,13 @@ variable "generator_segment_index_overwrite" { description = "Optional generator setting to override the index path segment during path selection. This option should only be set if generator.git.directories is used. Otherwise it should be left empty as it may affect the behavior. If this option is set in combination with generator.git.directories and your repository contains the cluster folder name in its root directory, this option should be set to 0. In all other cases, this option should reflect the index segment level to the directory corresponding to the cluster name." default = null } + +variable "sync_policy" { + type = object({ + prune = bool + self_heal = bool + allow_empty = bool + }) + description = "ArgoCD sync policy configuration" + default = null +}