From cfcf5226c392de13e7fe678b337bfd2da03dbd30 Mon Sep 17 00:00:00 2001
From: Dominik Hebeler <dominik@suma-ev.de>
Date: Fri, 27 May 2022 11:32:53 +0200
Subject: [PATCH] limited release name to 53 characters

---
 .gitlab-ci.yml                                          | 6 +++---
 .gitlab/deployment_scripts/cleanup_tags_non_revision.sh | 4 ++--
 .gitlab/deployment_scripts/cleanup_tags_revision.sh     | 8 ++++----
 .gitlab/deployment_scripts/update_deployment.sh         | 2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ff896d4ad..98e12e062 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -17,7 +17,7 @@ workflow:
         DOCKER_FPM_IMAGE_TAG: $DOCKER_IMAGE_TAG_PREFIX-$CI_COMMIT_SHA
         DOCKER_NGINX_IMAGE_TAG: $DOCKER_IMAGE_TAG_PREFIX-$CI_COMMIT_SHA
         DOCKER_NODE_IMAGE_TAG: $DOCKER_IMAGE_TAG_PREFIX-$CI_COMMIT_SHA
-        HELM_RELEASE_NAME: review-${DOCKER_IMAGE_TAG_PREFIX:0:46}
+        HELM_RELEASE_NAME: review-$DOCKER_IMAGE_TAG_PREFIX
     - if: $CI_COMMIT_BRANCH == "master"
       variables:
         APP_URL: https://metager.de
@@ -27,7 +27,7 @@ workflow:
         DOCKER_FPM_IMAGE_TAG: $DOCKER_IMAGE_TAG_PREFIX-$CI_COMMIT_SHA
         DOCKER_NGINX_IMAGE_TAG: $DOCKER_IMAGE_TAG_PREFIX-$CI_COMMIT_SHA
         DOCKER_NODE_IMAGE_TAG: $DOCKER_IMAGE_TAG_PREFIX-$CI_COMMIT_SHA
-        HELM_RELEASE_NAME: ${DOCKER_IMAGE_TAG_PREFIX:0:53}
+        HELM_RELEASE_NAME: $DOCKER_IMAGE_TAG_PREFIX
     - if: $CI_COMMIT_BRANCH == "development"
       variables:
         APP_URL: https://metager3.de
@@ -37,7 +37,7 @@ workflow:
         DOCKER_FPM_IMAGE_TAG: $DOCKER_IMAGE_TAG_PREFIX-$CI_COMMIT_SHA
         DOCKER_NGINX_IMAGE_TAG: $DOCKER_IMAGE_TAG_PREFIX-$CI_COMMIT_SHA
         DOCKER_NODE_IMAGE_TAG: $DOCKER_IMAGE_TAG_PREFIX-$CI_COMMIT_SHA
-        HELM_RELEASE_NAME: ${DOCKER_IMAGE_TAG_PREFIX:0:53}
+        HELM_RELEASE_NAME: $DOCKER_IMAGE_TAG_PREFIX
 
 stages:
   - build_dependency_images
diff --git a/.gitlab/deployment_scripts/cleanup_tags_non_revision.sh b/.gitlab/deployment_scripts/cleanup_tags_non_revision.sh
index 0b04bc60e..47858b613 100755
--- a/.gitlab/deployment_scripts/cleanup_tags_non_revision.sh
+++ b/.gitlab/deployment_scripts/cleanup_tags_non_revision.sh
@@ -105,10 +105,10 @@ echo ""
 echo "Fetching Tags from helm revision history to not be deleted..."
 declare -A revision_tags_fpm
 declare -A revision_tags_nginx
-helm_release_revisions=$(helm -n $KUBE_NAMESPACE history $HELM_RELEASE_NAME -o json | jq -r '.[]["revision"]')
+helm_release_revisions=$(helm -n $KUBE_NAMESPACE history ${HELM_RELEASE_NAME:0:53} -o json | jq -r '.[]["revision"]')
 for revision in $helm_release_revisions
 do
-    revision_values=$(helm -n $KUBE_NAMESPACE get values $HELM_RELEASE_NAME --revision=$revision -o json | jq -r '.')
+    revision_values=$(helm -n $KUBE_NAMESPACE get values ${HELM_RELEASE_NAME:0:53} --revision=$revision -o json | jq -r '.')
     revision_tags_fpm[$(echo $revision_values | jq -r '.image.fpm.tag')]=1
     revision_tags_nginx[$(echo $revision_values | jq -r '.image.nginx.tag')]=1
 done
diff --git a/.gitlab/deployment_scripts/cleanup_tags_revision.sh b/.gitlab/deployment_scripts/cleanup_tags_revision.sh
index 7af0024ef..4fdaab279 100755
--- a/.gitlab/deployment_scripts/cleanup_tags_revision.sh
+++ b/.gitlab/deployment_scripts/cleanup_tags_revision.sh
@@ -2,7 +2,7 @@
 
 # Call script with KEEP_N variable set to specify the amount of releases to keep
 
-helm -n $KUBE_NAMESPACE history $HELM_RELEASE_NAME
+helm -n $KUBE_NAMESPACE history ${HELM_RELEASE_NAME:0:53}
 if [ $? -ne 0 ]
 then
   echo "Release does not exist yet. Nothing to cleanup!"
@@ -11,11 +11,11 @@ fi
 
 set -e
 
-revision_count=$(helm -n $KUBE_NAMESPACE history $HELM_RELEASE_NAME -o json | jq -r '. | length')
+revision_count=$(helm -n $KUBE_NAMESPACE history ${HELM_RELEASE_NAME:0:53} -o json | jq -r '. | length')
 
 # Get List of revisions to expire (delete the image tags)
 end_index=$(($KEEP_N > $revision_count ? 0 : $revision_count-$KEEP_N))
-expired_revisions=$(helm -n $KUBE_NAMESPACE history $HELM_RELEASE_NAME -o json | jq -r ".[0:$end_index][][\"revision\"]")
+expired_revisions=$(helm -n $KUBE_NAMESPACE history ${HELM_RELEASE_NAME:0:53} -o json | jq -r ".[0:$end_index][][\"revision\"]")
 
 # Loop through those revisions
 declare -A expired_fpm_tags
@@ -23,7 +23,7 @@ declare -A expired_nginx_tags
 for revision in $expired_revisions
 do
     # Get Values for this revision
-    revision_values=$(helm -n $KUBE_NAMESPACE get values $HELM_RELEASE_NAME --revision=$revision -ojson)
+    revision_values=$(helm -n $KUBE_NAMESPACE get values ${HELM_RELEASE_NAME:0:53} --revision=$revision -ojson)
     # Get Image Tags for this revision
     revision_fpm_tag=$(echo $revision_values | jq -r '.image.fpm.tag')
     revision_nginx_tag=$(echo $revision_values | jq -r '.image.nginx.tag')
diff --git a/.gitlab/deployment_scripts/update_deployment.sh b/.gitlab/deployment_scripts/update_deployment.sh
index cf8e586b7..09d180a08 100755
--- a/.gitlab/deployment_scripts/update_deployment.sh
+++ b/.gitlab/deployment_scripts/update_deployment.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 helm -n $KUBE_NAMESPACE upgrade --install \
-    $HELM_RELEASE_NAME \
+    ${HELM_RELEASE_NAME:0:53} \
     chart/ \
     -f $DEPLOYMENT_HELM_VALUES \
     --set environment=$APP_ENV \
-- 
GitLab