Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: change namespace overwrite behavior #22

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,20 @@ resource "argocd_application_set" "this" {

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
// (e.g. ingress-controllers (assuming "ingress-controllers" is the target_namespace_overwrite))
// otherwise we check if the configuration provided by the developer has a namespace_overwrite
// if the namespace_overwrite is not set, then we use the namespace based on the project name and git folder name
// (e.g. background-staging (assuming "background" is the project and "staging" the folder name))
// otherwise we use the namespace_overwrite provided by the developer
// (e.g. background-staging-v2 (assuming "background" is the project and "staging-v2" the namespace_overwrite))
namespace = var.target_namespace_overwrite != "" ? var.target_namespace_overwrite : "{{ if not .namespace_overwrite }}${var.project_name}-${local.resource_name}{{ else }}{{ .namespace_overwrite }}{{ end }}"
// if the namespace_overwrite in the values file is not null, then we want to use that value
// Otherwise, if the target_namespace_overwrite terraform variable is not null, then we want to use that value
// Otherwise, we automatically generate the namespace based on the project name and the resource name
namespace = <<EOT
{{- if .namespace_overwrite }}
{{- .namespace_overwrite }}
{{- else }}
{{- if ne \"${var.target_namespace_overwrite}\" \"\" }}
${var.target_namespace_overwrite}
{{- else }}
${var.project_name}-${local.resource_name}
{{- end }}
{{- end }}"
EOT
}
sync_policy {
dynamic "automated" {
Expand Down