From 3fe079ee465f9a701634b1ffd4e940a9af5c602f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Steinh=C3=A4user?= <42437185+leonsteinhaeuser@users.noreply.github.com> Date: Fri, 27 Oct 2023 14:34:30 +0200 Subject: [PATCH] feat: environment context based annotations (#8) * feat: added environment based context annotations * chore: updated example config --------- Signed-off-by: leonsteinhaeuser --- README.md | 1 + examples/main.tf | 13 +++++++++++++ main.tf | 5 +++++ variables.tf | 6 ++++++ 4 files changed, 25 insertions(+) diff --git a/README.md b/README.md index 2f30d84..47c5d4d 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ No modules. |------|-------------|------|---------|:--------:| | [annotations](#input\_annotations) | Annotations to apply to the application set | `map(string)` | `{}` | no | | [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 | +| [env\_context\_annotations](#input\_env\_context\_annotations) | A map of annotations that are rendered via go template. Available variables are cluster, resourceName and applicationName. You can access the variables using go templating. e.g. {{ $cluster }}, {{ $resourceName }}, {{ $applicationName }} | `map(string)` | `{}` | 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 | diff --git a/examples/main.tf b/examples/main.tf index 3721cdd..4de597e 100644 --- a/examples/main.tf +++ b/examples/main.tf @@ -34,4 +34,17 @@ module "example" { self_heal = true allow_empty = true } + env_context_annotations = { + "argocd-image-updater.argoproj.io/image-list" = "xyz=tagesspiegel/xyz" + "argocd-image-updater.argoproj.io/xyz.update-strategy" = "latest" + "argocd-image-updater.argoproj.io/xyz.allow-tags" = < "{{ $applicationName := \"${var.name}\" }}{{ $resourceName := \"${local.resource_name}\" }}{{ $cluster := \"\" }}{{ if eq (index .Path.Segments 1) \"general-purpose\" }}{{ $cluster = \"in-cluster\" }}{{ else }}{{ $cluster = (index .Path.Segments 1) }}{{ end }}${v}" + } ) labels = merge( var.labels, diff --git a/variables.tf b/variables.tf index 52c1069..1d4d9c7 100644 --- a/variables.tf +++ b/variables.tf @@ -168,3 +168,9 @@ variable "ignore_difference" { 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 } + +variable "env_context_annotations" { + type = map(string) + description = "A map of annotations that are rendered via go template. Available variables are cluster, resourceName and applicationName. You can access the variables using go templating. e.g. {{ $cluster }}, {{ $resourceName }}, {{ $applicationName }}" + default = {} +}