message: Changed logic how gather projectname
  Set notification channels as an array
diff: @@ -119,7 +119,15 @@ function create_routes_array() {
  # Get the list of namespaces with broker routes, according to REGEX
  for namespace in $(oc get routes --all-namespaces|grep exposer|awk '{print $1}'|sort -u|grep -E "$REGEX")
  do
  - PROJECTNAME=$(oc get project "$namespace" -o json|grep display-name|awk -F'[][]' '{print $2}'|tr "_" "-")
  + # Raw JSON Openshift project output
  + PROJECTJSON="$(oc get project "$namespace" -o json)"
  +
  + # Gather project name based on a label or an annotation
  + if [ $(echo $PROJECTJSON |grep -q 'lagoon.sh/project'; echo $?) -eq 0 ]; then
  + PROJECTNAME=$(echo "${PROJECTJSON}" | grep 'lagoon.sh/project' | awk -F'"' '{print $4}')
  + else
  + PROJECTNAME=$(echo "${PROJECTJSON}" |grep display-name|awk -F'[][]' '{print $2}'|tr "_" "-")
  + fi
  # Get the list of broken unique routes for each namespace
  for routelist in $(oc get -n "$namespace" route|grep exposer|awk -vNAMESPACE="$namespace" -vPROJECTNAME="$PROJECTNAME" '{print $1";"$2";"NAMESPACE";"PROJECTNAME}'|sort -u -k2 -t ";")
  @@ -221,21 +229,27 @@ function notify_customer() {
  echo "No notification set"
  return 0
  fi
  - NOTIFICATION_DATA=$(lagoon list $NOTIFICATION -p "$1" --no-header|head -n1|awk '{print $3";"$4}')
  - CHANNEL=$(echo "$NOTIFICATION_DATA"|cut -f1 -d ";")
  - WEBHOOK=$(echo "$NOTIFICATION_DATA"|cut -f2 -d ";")
  +
  MESSAGE="Your $ROUTE_HOSTNAME route is configured in the \`.lagoon.yml\` file to issue an TLS certificate from Lets Encrypt. Unfortunately Lagoon is unable to issue a certificate as $DNS_ERROR.\nTo be issued correctly, the DNS records for $ROUTE_HOSTNAME should point to $CLUSTER_HOSTNAME with an CNAME record (preferred) or to ${CLUSTER_IPS[*]} via an A record (also possible but not preferred).\nIf you don't need the SSL certificate or you are using a CDN that provides you with an TLS certificate, please update your .lagoon.yml file by setting the tls-acme parameter to false for $ROUTE_HOSTNAME, as described here: https://lagoon.readthedocs.io/en/latest/using_lagoon/lagoon_yml/#ssl-configuration-tls-acme.\nWe have now administratively disabled the issuing of Lets Encrypt certificate for $ROUTE_HOSTNAME in order to protect the cluster, this will be reset during the next deployment, therefore we suggest to resolve this issue as soon as possible. Feel free to reach out to us for further information.\nThanks you.\namazee.io team"
  + NOTIFICATION_DATA=($(lagoon list $NOTIFICATION -p "$1" --no-header|awk '{print $3";"$4}'))
  + for notification in ${NOTIFICATION_DATA[@]}
  + do
  + CHANNEL=$(echo "$notification"|cut -f1 -d ";")
  + WEBHOOK=$(echo "$notification"|cut -f2 -d ";")
  +
  # json Payload
  PAYLOAD="\"channel\": \"$CHANNEL\", \"text\": \"${MESSAGE}\""
  echo -e "Sending notification into ${CHANNEL}"
  +
  # Execute curl to send message into the channel
  if [[ $DRYRUN = true ]]; then
  echo "DRYRUN Sending notification on \"$NOTIFICATION\" curl -X POST -H 'Content-type: application/json' --data '{'"$PAYLOAD"'}' "$WEBHOOK""
  else
  curl -X POST -H 'Content-type: application/json' --data '{'"${PAYLOAD}"'}' ${WEBHOOK}
  fi
  + done
  }
  # Main function
  