bootstrap.sh 1.62 KB
Newer Older
1
2
3
4
# Cleanup function
cleanup() {
  echo "Terminating istio sidecar"
  curl -X POST "http://localhost:15020/quitquitquit"
5
  exit
6
7
}

8
trap cleanup EXIT
9
10

if [[ -z "${NAMESPACE}" ]]; then
Akshat  Joshi's avatar
Akshat Joshi committed
11
  NAMESPACE="osdu"
12
13
fi

Akshat  Joshi's avatar
Akshat Joshi committed
14
15
16
17
18
if [[ -z "${AZURE_DNS_NAME}" ]]; then
  AZURE_DNS_NAME="osdu-glab.msft-osdu-test.org"
fi

export AZURE_SCHEMA_URL="https://${AZURE_DNS_NAME}/api/schema-service/v1/schemas/system"
19
20
currentStatus="success"
currentMessage="All schemas uploaded successfully"
21
22
BEARER_TOKEN=`python $AZURE_DEPLOYMENTS_SUBDIR/Token.py`
export BEARER_TOKEN=$BEARER_TOKEN
23
python $AZURE_DEPLOYMENTS_SCRIPTS_SUBDIR/DeploySharedSchemas.py -u $AZURE_SCHEMA_URL
24
25
26
ret=$?
echo "Return value is $ret"
if [[ $ret -ne 0 ]]; then
27
28
29
30
31
32
33
34
	currentStatus="failure"
	currentMessage="Schema loading failed. Please check error logs for more details."
fi
if [ ! -z "$CONFIG_MAP_NAME" -a "$CONFIG_MAP_NAME" != " " ]; then
  az login --identity --username $OSDU_IDENTITY_ID
  ENV_AKS=$(az aks list --resource-group $RESOURCE_GROUP_NAME --query [].name -otsv)
  az aks get-credentials --resource-group $RESOURCE_GROUP_NAME --name $ENV_AKS
  kubectl config set-context $RESOURCE_GROUP_NAME --cluster $ENV_AKS
35

36
37
38
39
40
41
42
43
44
45
  Status=$(kubectl get configmap $CONFIG_MAP_NAME -o jsonpath='{.data.status}')
  Message=$(kubectl get configmap $CONFIG_MAP_NAME -o jsonpath='{.data.message}')

  Message="${Message}Schema load Message: ${currentMessage}. "

  ## Update ConfigMap
  kubectl create configmap $CONFIG_MAP_NAME \
	--from-literal=status="$currentStatus" \
	--from-literal=message="$Message" \
	-o yaml --dry-run=client | kubectl replace -f -
46
47
48
49
50
51
52
fi

if [[ ${currentStatus} == "success" ]]; then
  exit 0
else
  exit 1
fi