Skip to content

Commit

Permalink
feat: define ca and default issuers on locals and transmit to chart
Browse files Browse the repository at this point in the history
  • Loading branch information
lconsuegra authored and lentidas committed Nov 10, 2023
1 parent 4d23fe3 commit 0979d46
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions charts/cert-manager/templates/clusterissuer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: selfsigned-issuer
name: {{ $.Values.issuers.default.name | quote }}
annotations:
argocd.argoproj.io/sync-wave: "5"
spec:
Expand All @@ -13,7 +13,7 @@ spec:
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: ca-issuer
name: {{ $.Values.issuers.ca.name | quote }}
annotations:
argocd.argoproj.io/sync-wave: "5"
spec:
Expand All @@ -23,7 +23,7 @@ spec:
{{- if index $.Values "cert-manager" "clusterIssuers" }}
{{- if index $.Values "cert-manager" "clusterIssuers" "letsencrypt" }}
{{- if index $.Values "cert-manager" "clusterIssuers" "letsencrypt" "enabled" }}
{{- range $name, $issuer := index $.Values "letsencrypt" "issuers" }}
{{- range $name, $issuer := index $.Values "issuers" "letsencrypt" }}
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
Expand Down
12 changes: 10 additions & 2 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
locals {
issuers = {
default = {
name = "selfsigned-issuer"
}
ca = { # This value is only used when using the self-signed variant.
name = "ca-issuer"
}
letsencrypt = {
production = {
name = "letsencrypt-prod"
Expand All @@ -26,8 +32,10 @@ locals {
}
}
}
letsencrypt = {
issuers = { for issuer_id, issuer in local.issuers.letsencrypt :
issuers = {
default = local.issuers.default
ca = local.issuers.ca
letsencrypt = { for issuer_id, issuer in local.issuers.letsencrypt :
issuer.name => {
email = issuer.email
server = issuer.server
Expand Down
4 changes: 2 additions & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ output "id" {
output "cluster_issuers" {
description = "List of cluster issuers created by cert-manager."
value = merge({
default = "selfsigned-issuer"
default = local.issuers.default.name
}, {
for issuer_id, issuer in { ca = "ca-issuer" } : issuer_id => issuer
for issuer_id, issuer in { ca = local.issuers.ca.name } : issuer_id => issuer
if can(var.helm_values[0].cert-manager.tlsCrt) && can(var.helm_values[0].cert-manager.tlsKey)
}, {
for issuer_id, issuer in local.issuers.letsencrypt : issuer_id => issuer.name
Expand Down

0 comments on commit 0979d46

Please sign in to comment.