diff --git a/library/common-test/tests/ingress/homepage_test.yaml b/library/common-test/tests/ingress/homepage_test.yaml index 01f6625c..6746d4aa 100644 --- a/library/common-test/tests/ingress/homepage_test.yaml +++ b/library/common-test/tests/ingress/homepage_test.yaml @@ -21,6 +21,8 @@ tests: global: traefik: addIngressAnnotations: false + certManager: + addIngressAnnotations: false ingress: my-ingress1: enabled: true diff --git a/library/common-test/tests/ingress/metadata_test.yaml b/library/common-test/tests/ingress/metadata_test.yaml index f8202170..4e156665 100644 --- a/library/common-test/tests/ingress/metadata_test.yaml +++ b/library/common-test/tests/ingress/metadata_test.yaml @@ -16,6 +16,8 @@ tests: global: traefik: addIngressAnnotations: false + certManager: + addIngressAnnotations: false labels: g_label1: global_label1 g_label2: "{{ .Values.label2 }}" diff --git a/library/common/templates/class/_ingress.tpl b/library/common/templates/class/_ingress.tpl index fe40ecdd..b17583df 100644 --- a/library/common/templates/class/_ingress.tpl +++ b/library/common/templates/class/_ingress.tpl @@ -20,7 +20,7 @@ objectData: The object data to be used to render the Ingress. {{- $_ := set $objectData "annotations" dict -}} {{- end -}} - {{- /* include "tc.v1.common.lib.ingress.integration.certManager" (dict "rootCtx" $rootCtx "objectData" $objectData) */ -}} + {{- include "tc.v1.common.lib.ingress.integration.certManager" (dict "rootCtx" $rootCtx "objectData" $objectData) -}} {{- include "tc.v1.common.lib.ingress.integration.traefik" (dict "rootCtx" $rootCtx "objectData" $objectData) -}} {{- include "tc.v1.common.lib.ingress.integration.homepage" (dict "rootCtx" $rootCtx "objectData" $objectData) -}} {{/* TODO: fix last - */}} diff --git a/library/common/templates/lib/ingress/integrations/_certManager.tpl b/library/common/templates/lib/ingress/integrations/_certManager.tpl new file mode 100644 index 00000000..0196d9be --- /dev/null +++ b/library/common/templates/lib/ingress/integrations/_certManager.tpl @@ -0,0 +1,33 @@ +{{- define "tc.v1.common.lib.ingress.integration.certManager" -}} + {{- $objectData := .objectData -}} + {{- $rootCtx := .rootCtx -}} + + {{- $certManager := $objectData.integrations.certManager -}} + + {{- $enabled := false -}} + {{- if (hasKey $rootCtx.Values.global "certManager") -}} + {{- $enabled = $rootCtx.Values.global.certManager.addIngressAnnotations -}} + {{- end -}} + + {{- if and $certManager (kindIs "bool" $certManager.enabled) -}} + {{- $enabled = $certManager.enabled -}} + {{- end -}} + + {{- if $enabled -}} + {{- include "tc.v1.common.lib.ingress.integration.certManager.validate" (dict "objectData" $objectData) -}} + + {{- $_ := set $objectData.annotations "cert-manager.io/cluster-issuer" "TODO:" -}} + {{- $_ := set $objectData.annotations "cert-manager.io/private-key-rotation-policy" "Always" -}} + + {{- end -}} +{{- end -}} + +{{- define "tc.v1.common.lib.ingress.integration.certManager.validate" -}} + {{- $objectData := .objectData -}} + + {{- $certManager := $objectData.integrations.certManager -}} + + {{- if $certManager -}} + + {{- end -}} +{{- end -}} diff --git a/library/common/values.yaml b/library/common/values.yaml index 3a1d03b6..641de6f8 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -10,6 +10,9 @@ global: metallb: # -- Adds metalLB annotations to services addServiceAnnotations: true + certManager: + # -- Adds cert-manager annotations to ingresses + addIngressAnnotations: true traefik: # -- Adds traefik annotations to services (when needed) addServiceAnnotations: true