Skip to content

Commit

Permalink
chore: removed hard coded properties and replaced them with variables
Browse files Browse the repository at this point in the history
  • Loading branch information
leonsteinhaeuser committed Sep 14, 2023
1 parent ea2e29c commit f82f4cd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
13 changes: 8 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ locals {
resource "argocd_application_set" "this" {
metadata {
name = "${var.project_name}-${var.name}"
namespace = "argo-system"
namespace = var.namespace
}

spec {
Expand Down Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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
}

0 comments on commit f82f4cd

Please sign in to comment.