Commit ba73475d authored by Hordur Freyr Yngvason's avatar Hordur Freyr Yngvason
Browse files

Merge branch 'delete_postgresql_chart' into 'master'

Delete new postgresql chart

See merge request gitlab-org/cluster-integration/auto-deploy-image!58
parents 268fbc9c 320b8091
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -298,3 +298,40 @@ test-create-application-secret:
    - auto-deploy create_application_secret "stable"
    - kubectl get secrets -n $KUBE_NAMESPACE
    - kubectl get secrets production-secret -n $KUBE_NAMESPACE

test-delete:
  extends: test-deploy
  script:
    - auto-deploy initialize_tiller
    - auto-deploy download_chart
    - auto-deploy deploy
    - helm get production
    - auto-deploy delete
    - helm get production && expected_error || failed_as_expected

test-delete-postgresql-beta:
  extends: test-deploy-postgresql-beta
  script:
    - auto-deploy initialize_tiller
    - auto-deploy download_chart
    - auto-deploy deploy
    - helm get production
    - helm get production-postgresql
    - auto-deploy delete
    - helm get production && expected_error || failed_as_expected
    - helm get production-postgresql && expected_error || failed_as_expected

test-delete-canary-postgresql-beta:
  extends: test-deploy-postgresql-beta
  script:
    - auto-deploy initialize_tiller
    - auto-deploy download_chart
    - auto-deploy deploy canary
    - helm get production-canary
    - auto-deploy deploy
    - helm get production
    - helm get production-postgresql
    - auto-deploy delete canary
    - helm get production-canary && expected_error || failed_as_expected
    - helm get production
    - helm get production-postgresql
+15 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
export TILLER_NAMESPACE=$KUBE_NAMESPACE
export HELM_HOST="localhost:44134"
export RELEASE_NAME=${HELM_RELEASE_NAME:-$CI_ENVIRONMENT_SLUG}
export POSTGRESQL_RELEASE_NAME="${RELEASE_NAME}-postgresql"
export AUTO_DEVOPS_POSTGRES_CHANNEL=${AUTO_DEVOPS_POSTGRES_CHANNEL:-"1"}

function check_kube_domain() {
@@ -89,7 +90,7 @@ function persist_environment_url() {
function auto_database_url() {
  local auto_database_url
  if [[ "$AUTO_DEVOPS_POSTGRES_CHANNEL" == "2" ]]; then
    auto_database_url="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${RELEASE_NAME}-postgresql:5432/${POSTGRES_DB}"
    auto_database_url="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRESQL_RELEASE_NAME}:5432/${POSTGRES_DB}"
  elif [[ "$AUTO_DEVOPS_POSTGRES_CHANNEL" == "1" ]]; then
    auto_database_url="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${RELEASE_NAME}-postgres:5432/${POSTGRES_DB}"
  fi
@@ -104,7 +105,7 @@ function install_postgresql() {
    exit 1
  fi

  local name="${RELEASE_NAME}-postgresql"
  local name="$POSTGRESQL_RELEASE_NAME"

  helm upgrade --install \
    --atomic \
@@ -306,6 +307,14 @@ function scale() {
  fi
}

function delete_postgresql() {
  local name="$POSTGRESQL_RELEASE_NAME"

  if [[ -n "$(helm ls -q "^$name$")" ]]; then
    helm delete --purge "$name"
  fi
}

function delete() {
  local track="${1-stable}"
  local name
@@ -315,6 +324,10 @@ function delete() {
    helm delete --purge "$name"
  fi

  if [[ "$track" == "stable" ]]; then
    delete_postgresql
  fi

  local secret_name
  secret_name=$(application_secret_name "$track")