|
1 |
| -#!/bin/bash |
| 1 | +#!/usr/bin/env bash |
2 | 2 |
|
3 |
| -environment=prd |
4 |
| -ocEnvironment=prod |
5 |
| -license="d027a8" |
6 |
| -helmCommand=upgrade |
| 3 | +# Deploys changes to a PPM API environment's infrastructure in OpenShift |
| 4 | +# |
| 5 | +# Usage: |
| 6 | +# deploy.sh COMMAND ENVIRONMENT |
| 7 | +# |
| 8 | +# Substitute COMMAND for the Helm command to be applied. |
| 9 | +# Substitute ENVIRONMENT for the three-letter name of the PPM API environment to be deployed. The environments are dev, tr1, vs1, vc1, vc2, and prd. |
| 10 | +# |
| 11 | +# Author: Arlo Watts |
| 12 | +# Date: 2023-30-11 |
| 13 | + |
| 14 | +helmCommand=$1 |
| 15 | +environment=$2 |
| 16 | + |
| 17 | +# Set the namespace according to the environment |
| 18 | +if [ "$environment" = "dev" ]; then |
| 19 | + namespace="2f77cb-dev" |
| 20 | + |
| 21 | +elif [ "$environment" = "tr1" ]; then |
| 22 | + namespace="2f77cb-test" |
| 23 | + |
| 24 | +elif [ "$environment" = "vs1" ]; then |
| 25 | + namespace="2f77cb-test" |
| 26 | + |
| 27 | +elif [ "$environment" = "vc2" ]; then |
| 28 | + namespace="2f77cb-test" |
| 29 | + |
| 30 | +elif [ "$environment" = "vc1" ]; then |
| 31 | + namespace="d027a8-test" |
| 32 | + |
| 33 | +elif [ "$environment" = "prd" ]; then |
| 34 | + namespace="d027a8-prod" |
| 35 | + echo "You are making changes to the live production environment of a critical health application. Type DEPLOY TO PRODUCTION to proceed." |
| 36 | + read confirm && [ "$confirm" = "DEPLOY TO PRODUCTION" ] || exit 1 |
| 37 | + |
| 38 | +else |
| 39 | + echo "\"${environment}\" is not a recognized environment." |
| 40 | + echo |
| 41 | + echo "Usage:" |
| 42 | + echo " deploy.sh COMMAND ENVIRONMENT" |
| 43 | + echo |
| 44 | + echo "Substitute COMMAND for the Helm command to be applied." |
| 45 | + echo "Substitute ENVIRONMENT for the three-letter name of the PPM API environment to be deployed. The environments are dev, tr1, vs1, vc1, vc2, and prd." |
| 46 | + exit 1 |
| 47 | +fi |
7 | 48 |
|
8 | 49 | # Points to tools/helm
|
9 |
| -BASEDIR=$(dirname $0) |
| 50 | +basedir=$(dirname $0) |
10 | 51 |
|
11 |
| -services=('common' 'claimservice' 'consentservice' 'locationservice' 'medicationdispenseservice' 'medicationrequestservice' 'medicationservice' 'medicationstatementservice' 'patientservice' 'practitionerservice') |
| 52 | +# The list of services |
| 53 | +services=("claim" "consent" "location" "medicationdispense" "medicationrequest" "medication" "medicationstatement" "patient" "practitioner") |
12 | 54 |
|
13 |
| -helmScripts=('common' 'ppmservice' 'ppmservice' 'ppmservice' 'ppmservice' 'ppmservice' 'ppmservice' 'ppmservice' 'ppmservice' 'ppmservice') |
| 55 | +# Deploy the common secrets that each PPM API service references |
| 56 | +helm $helmCommand -n $namespace -f ${basedir}/config/common/${environment}-values.yaml common-${environment} ${basedir}/common |
14 | 57 |
|
15 |
| -for i in "${!services[@]}"; do |
16 |
| - service=${services[$i]} |
17 |
| - helmScript=${helmScripts[$i]} |
18 |
| - helm ${helmCommand} -n ${license}-${ocEnvironment} -f ${BASEDIR}/config/${service}/${environment}-values.yaml ${service}-${environment} ${BASEDIR}/${helmScript} |
| 58 | +# Deploy the PPM API services |
| 59 | +for service in ${services[@]}; do |
| 60 | + helm $helmCommand -n $namespace -f ${basedir}/config/${service}service/${environment}-values.yaml ${service}service-${environment} ${basedir}/ppmservice |
19 | 61 | done
|
0 commit comments