Skip to content

Commit

Permalink
Bring back ignore-differences option of argo cd (cloudposse/terraform…
Browse files Browse the repository at this point in the history
…-aws-components#859)

Co-authored-by: cloudpossebot <[email protected]>
  • Loading branch information
max-lobur and cloudpossebot authored Sep 18, 2023
1 parent 30938f1 commit 30ad9e4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ $ terraform import -var "import_profile_name=eg-mgmt-gbl-corp-admin" -var-file="
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
| <a name="input_environments"></a> [environments](#input\_environments) | Environments to populate `applicationset.yaml` files and repository deploy keys (for ArgoCD) for.<br><br>`auto-sync` determines whether or not the ArgoCD application will be automatically synced. | <pre>list(object({<br> tenant = string<br> environment = string<br> stage = string<br> auto-sync = bool<br> }))</pre> | `[]` | no |
| <a name="input_environments"></a> [environments](#input\_environments) | Environments to populate `applicationset.yaml` files and repository deploy keys (for ArgoCD) for.<br><br>`auto-sync` determines whether or not the ArgoCD application will be automatically synced.<br><br>`ignore-differences` determines whether or not the ArgoCD application will ignore the number of<br>replicas in the deployment. Read more on ignore differences here:<br>https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#respect-ignore-difference-configs<br>Example:<pre>tenant: plat<br>environment: use1<br>stage: sandbox<br>auto-sync: true<br>ignore-differences:<br> - group: apps<br> kind: Deployment<br> json-pointers:<br> - /spec/replicas</pre> | <pre>list(object({<br> tenant = string<br> environment = string<br> stage = string<br> auto-sync = bool<br> ignore-differences = list(object({<br> group = string,<br> kind = string,<br> json-pointers = list(string)<br> }))<br> }))</pre> | `[]` | no |
| <a name="input_github_base_url"></a> [github\_base\_url](#input\_github\_base\_url) | This is the target GitHub base API endpoint. Providing a value is a requirement when working with GitHub Enterprise. It is optional to provide this value and it can also be sourced from the `GITHUB_BASE_URL` environment variable. The value must end with a slash, for example: `https://terraformtesting-ghe.westus.cloudapp.azure.com/` | `string` | `null` | no |
| <a name="input_github_codeowner_teams"></a> [github\_codeowner\_teams](#input\_github\_codeowner\_teams) | List of teams to use when populating the CODEOWNERS file.<br><br>For example: `["@ACME/cloud-admins", "@ACME/cloud-developers"]`. | `list(string)` | n/a | yes |
| <a name="input_github_default_notifications_enabled"></a> [github\_default\_notifications\_enabled](#input\_github\_default\_notifications\_enabled) | Enable default GitHub commit statuses notifications (required for CD sync mode) | `bool` | `true` | no |
Expand Down
13 changes: 7 additions & 6 deletions src/applicationset.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ resource "github_repository_file" "application_set" {
branch = join("", github_repository.default.*.default_branch)
file = "${each.value.tenant != null ? format("%s/", each.value.tenant) : ""}${each.value.environment}-${each.value.stage}/${local.manifest_kubernetes_namespace}/applicationset.yaml"
content = templatefile("${path.module}/templates/applicationset.yaml.tpl", {
environment = each.key
auto-sync = each.value.auto-sync
name = module.this.namespace
namespace = local.manifest_kubernetes_namespace
ssh_url = join("", github_repository.default.*.ssh_clone_url)
notifications = var.github_default_notifications_enabled
environment = each.key
auto-sync = each.value.auto-sync
ignore-differences = each.value.ignore-differences
name = module.this.namespace
namespace = local.manifest_kubernetes_namespace
ssh_url = join("", github_repository.default.*.ssh_clone_url)
notifications = var.github_default_notifications_enabled
})
commit_message = "Initialize environment: `${each.key}`."
commit_author = var.github_user
Expand Down
12 changes: 12 additions & 0 deletions src/templates/applicationset.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,15 @@ spec:
%{ endif ~}
syncOptions:
- CreateNamespace=true
%{if length(ignore-differences) > 0 ~}
- RespectIgnoreDifferences=true
ignoreDifferences:
%{for item in ignore-differences ~}
- group: "${item.group}"
kind: "${item.kind}"
jsonPointers:
%{for pointer in item.json-pointers ~}
- ${pointer}
%{ endfor ~}
%{ endfor ~}
%{ endif ~}
21 changes: 21 additions & 0 deletions src/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,32 @@ variable "environments" {
environment = string
stage = string
auto-sync = bool
ignore-differences = list(object({
group = string,
kind = string,
json-pointers = list(string)
}))
}))
description = <<-EOT
Environments to populate `applicationset.yaml` files and repository deploy keys (for ArgoCD) for.
`auto-sync` determines whether or not the ArgoCD application will be automatically synced.
`ignore-differences` determines whether or not the ArgoCD application will ignore the number of
replicas in the deployment. Read more on ignore differences here:
https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#respect-ignore-difference-configs
Example:
```
tenant: plat
environment: use1
stage: sandbox
auto-sync: true
ignore-differences:
- group: apps
kind: Deployment
json-pointers:
- /spec/replicas
```
EOT
default = []
}
Expand Down

0 comments on commit 30ad9e4

Please sign in to comment.