Commit 0d6047bb authored by Albert Salim's avatar Albert Salim

Cleanup existing MR review-app by helm 2

parent a56414a6
...@@ -148,6 +148,7 @@ review-stop-failed-deployment: ...@@ -148,6 +148,7 @@ review-stop-failed-deployment:
stage: prepare stage: prepare
script: script:
- delete_failed_release - delete_failed_release
- delete_helm2_release
review-stop: review-stop:
extends: extends:
......
...@@ -95,6 +95,36 @@ function delete_failed_release() { ...@@ -95,6 +95,36 @@ function delete_failed_release() {
fi fi
} }
function helm2_deploy_exists() {
local namespace="${1}"
local release="${2}"
local deploy_exists
echoinfo "Checking if Helm 2 ${release} exists in the ${namespace} namespace..." true
kubectl get cm -l OWNER=TILLER -n ${namespace} | grep ${release} 2>&1
deploy_exists=$?
echoinfo "Helm 2 release for ${release} is ${deploy_exists}"
return $deploy_exists
}
function delete_helm2_release() {
local namespace="${KUBE_NAMESPACE}"
local release="${CI_ENVIRONMENT_SLUG}"
if [ -z "${release}" ]; then
echoerr "No release given, aborting the delete!"
return
fi
if ! helm2_deploy_exists "${namespace}" "${release}"; then
echoinfo "No Review App with ${release} is currently deployed by Helm 2."
else
echoinfo "Cleaning up ${release} installed by Helm 2"
kubectl_cleanup_release "${namespace}" "${release}"
fi
}
function get_pod() { function get_pod() {
local namespace="${KUBE_NAMESPACE}" local namespace="${KUBE_NAMESPACE}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment