From 3a7cb2083d4ac0fbd71b702b8126d00b5ad6be05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Steinh=C3=A4user?= <42437185+leonsteinhaeuser@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:08:54 +0200 Subject: [PATCH] feat: TPLAT-287 added feature to ignore differences in spec (#7) * feat: implemented ignore_difference option --------- Signed-off-by: leonsteinhaeuser --- README.md | 1 + main.tf | 13 +++++++++++++ variables.tf | 13 +++++++++++++ 3 files changed, 27 insertions(+) diff --git a/README.md b/README.md index 9f4b0cf..2f30d84 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ No modules. | [application\_name\_suffix](#input\_application\_name\_suffix) | Optional suffix to add to the application name. This is useful if you want to deploy the same application multiple times to the same cluster. The suffix is added to the application name after the cluster name. e.g. prometheus-staging-. ArgoCD based gotemplating is supported. e.g. {{ index .path.segments 2 }} | `string` | `null` | no | | [generator](#input\_generator) | The generator configuration. Only one generator can be used at a time. |
object({
git = optional(object({
repo_url = string
revision = string
files = optional(list(string))
directories = optional(list(object({
path = string
exclude = bool
})))
}))
pull_request = optional(list(object({
requeue_after_seconds = number
repo = string
labels = list(string)
})))
})
| n/a | yes | | [generator\_segment\_index\_overwrite](#input\_generator\_segment\_index\_overwrite) | 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. | `number` | `null` | no | +| [ignore\_difference](#input\_ignore\_difference) | A list of object kinds to ignore during the diff process. This is useful if you want to ignore certain differences between the application set and the cluster. e.g. if you want to ignore differences in the namespace labels. |
list(object({
group = optional(string)
jq_path_expressions = optional(list(string))
json_pointers = optional(list(string))
kind = optional(string)
name = optional(string)
namespace = optional(string)
}))
| `null` | no | | [labels](#input\_labels) | Labels to apply to the application set | `map(string)` | `{}` | no | | [manifest\_source](#input\_manifest\_source) | n/a |
object({
helm = optional(object({
chart = string
repo_url = string
target_revision = string
release_name = string
}))
directory = optional(object({
repo = object({
url = string
revision = string
path = string
})
glob_path = optional(string)
}))
})
| n/a | yes | | [name](#input\_name) | The name of the application set | `string` | n/a | yes | diff --git a/main.tf b/main.tf index a83ba98..2004e4b 100644 --- a/main.tf +++ b/main.tf @@ -101,6 +101,19 @@ resource "argocd_application_set" "this" { } } + dynamic "ignore_difference" { + // to protect against null values, we need to check if the ignore_difference block is not null + for_each = var.ignore_difference != null ? var.ignore_difference : [] + content { + group = ignore_difference.value.group + jq_path_expressions = ignore_difference.value.jq_path_expressions + json_pointers = ignore_difference.value.json_pointers + kind = ignore_difference.value.kind + name = ignore_difference.value.name + namespace = ignore_difference.value.namespace + } + } + destination { name = "{{ if (eq ${local.cluster_identifier} \"general-purpose\") }}in-cluster{{ else }}{{ ${local.cluster_identifier} }}{{ end }}" // if the target_namespace_overwrite is not empty, then we want to use it as the namespace diff --git a/variables.tf b/variables.tf index a18f3e5..52c1069 100644 --- a/variables.tf +++ b/variables.tf @@ -155,3 +155,16 @@ variable "sync_policy" { description = "ArgoCD sync policy configuration" default = null } + +variable "ignore_difference" { + type = list(object({ + group = optional(string) + jq_path_expressions = optional(list(string)) + json_pointers = optional(list(string)) + kind = optional(string) + name = optional(string) + namespace = optional(string) + })) + description = "A list of object kinds to ignore during the diff process. This is useful if you want to ignore certain differences between the application set and the cluster. e.g. if you want to ignore differences in the namespace labels." + default = null +}