From efc8aa07a53666a88ea7f762bfd6b557e915da8c Mon Sep 17 00:00:00 2001
From: Jan Zickermann <jan.zickermann@dataport.de>
Date: Tue, 10 Dec 2024 16:55:35 +0100
Subject: [PATCH] #2 OZG-7121 helm: Use namespace-ca-issuer

---
 .gitlab-ci.yml                                         | 10 ++++++++--
 src/main/helm/templates/certificate.yaml               |  5 ++---
 src/main/helm/templates/selfsigned_cluster_issuer.yaml |  9 ---------
 3 files changed, 10 insertions(+), 14 deletions(-)
 delete mode 100644 src/main/helm/templates/selfsigned_cluster_issuer.yaml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 574c0ce..c9705af 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -38,6 +38,9 @@ test:
 .helm:
   before_script:
     - apk add --no-cache helm git curl
+  script:
+    - helm package --version=${HELM_CHART_VERSION} src/main/helm
+    - curl -u ${NEXUS_USER}:${NEXUS_PASSWORD} https://nexus.ozg-sh.de/service/rest/v1/components?repository=${NEXUS_HELM_REPO_NAME} -F file=@${PROJECT_ARTIFACTID}-${HELM_CHART_VERSION}.tgz
 
 test-helm:
   stage: test
@@ -83,13 +86,16 @@ push-merge-request-image-nexus:
 
 push-merge-request-helm-nexus:
   stage: publish
+  variables:
+    NEXUS_HELM_REPO_NAME: ozg-base-apps-snapshot
   before_script:
     - !reference [.get-version, before_script]
     - !reference [.helm, before_script]
   script:
     - export HELM_CHART_VERSION=${PROJECT_VERSION}-MR-${CI_MERGE_REQUEST_IID}
-    - helm package --version=${HELM_CHART_VERSION} src/main/helm
-    - curl -u ${NEXUS_USER}:${NEXUS_PASSWORD} https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps-snapshot -F file=@${PROJECT_ARTIFACTID}-${HELM_CHART_VERSION}.tgz
+    - !reference [.helm, script]
+    - export HELM_CHART_VERSION=${PROJECT_VERSION}-MR-${CI_MERGE_REQUEST_IID}-${CI_COMMIT_SHORT_SHA}
+    - !reference [.helm, script]
   rules:
     - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
   when: manual
diff --git a/src/main/helm/templates/certificate.yaml b/src/main/helm/templates/certificate.yaml
index 8d1bf81..434f8b4 100644
--- a/src/main/helm/templates/certificate.yaml
+++ b/src/main/helm/templates/certificate.yaml
@@ -12,9 +12,8 @@ spec:
     algorithm: ECDSA
     size: 256
   issuerRef:
-    name: xta-test-cluster-issuer
-    kind: ClusterIssuer
-    group: cert-manager.io
+    name: {{ include "app.namespace" . }}-ca-issuer
+    kind: Issuer
   duration: 8760h0m0s # 1 Jahr
   renewBefore: 5840h0m0s # 8 Monate
   commonName: {{ .Release.Name }}
diff --git a/src/main/helm/templates/selfsigned_cluster_issuer.yaml b/src/main/helm/templates/selfsigned_cluster_issuer.yaml
deleted file mode 100644
index a988ee3..0000000
--- a/src/main/helm/templates/selfsigned_cluster_issuer.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-apiVersion: cert-manager.io/v1
-kind: ClusterIssuer
-metadata:
-  name: xta-test-cluster-issuer
-  namespace: {{ include "app.namespace" . }}
-  labels:
-    {{- include "app.defaultLabels" . | indent 4 }}
-spec:
-  selfSigned: {}
\ No newline at end of file
-- 
GitLab