Skip to content

Commit

Permalink
feat: TPLAT-287 added feature to ignore differences in spec (#7)
Browse files Browse the repository at this point in the history
* feat: implemented ignore_difference option

---------

Signed-off-by: leonsteinhaeuser <[email protected]>
  • Loading branch information
leonsteinhaeuser authored Oct 26, 2023
1 parent 83ce7ad commit 3a7cb20
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ No modules.
| <a name="input_application_name_suffix"></a> [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-<suffix>. ArgoCD based gotemplating is supported. e.g. {{ index .path.segments 2 }} | `string` | `null` | no |
| <a name="input_generator"></a> [generator](#input\_generator) | The generator configuration. Only one generator can be used at a time. | <pre>object({<br> git = optional(object({<br> repo_url = string<br> revision = string<br> files = optional(list(string))<br> directories = optional(list(object({<br> path = string<br> exclude = bool<br> })))<br> }))<br> pull_request = optional(list(object({<br> requeue_after_seconds = number<br> repo = string<br> labels = list(string)<br> })))<br> })</pre> | n/a | yes |
| <a name="input_generator_segment_index_overwrite"></a> [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 |
| <a name="input_ignore_difference"></a> [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. | <pre>list(object({<br> group = optional(string)<br> jq_path_expressions = optional(list(string))<br> json_pointers = optional(list(string))<br> kind = optional(string)<br> name = optional(string)<br> namespace = optional(string)<br> }))</pre> | `null` | no |
| <a name="input_labels"></a> [labels](#input\_labels) | Labels to apply to the application set | `map(string)` | `{}` | no |
| <a name="input_manifest_source"></a> [manifest\_source](#input\_manifest\_source) | n/a | <pre>object({<br> helm = optional(object({<br> chart = string<br> repo_url = string<br> target_revision = string<br> release_name = string<br> }))<br> directory = optional(object({<br> repo = object({<br> url = string<br> revision = string<br> path = string<br> })<br> glob_path = optional(string)<br> }))<br> })</pre> | n/a | yes |
| <a name="input_name"></a> [name](#input\_name) | The name of the application set | `string` | n/a | yes |
Expand Down
13 changes: 13 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 3a7cb20

Please sign in to comment.