-
Notifications
You must be signed in to change notification settings - Fork 0
/
validatePrerequisiteTools.sh
executable file
·154 lines (143 loc) · 4.14 KB
/
validatePrerequisiteTools.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
# load in the shared library and validate argument
source ./deploymentArgument.lib
export DEPLOYMENT=$1
validate_deployment_argument $DEPLOYMENT
echo "=============================================================================="
echo "Validating Common pre-requisites"
echo "=============================================================================="
echo -n "helm utility "
command -v helm &> /dev/null
if [ $? -ne 0 ]; then
echo "Error"
echo ">>> Missing 'helm' kubernetes utility"
echo ""
exit 1
fi
echo "ok $(command -v helm)"
echo -n "jq utility "
command -v jq &> /dev/null
if [ $? -ne 0 ]; then
echo "Error"
echo ">>> Missing 'jq' json query utility"
echo ""
exit 1
fi
echo "ok $(command -v jq)"
echo -n "yq utility "
command -v yq &> /dev/null
if [ $? -ne 0 ]; then
echo "Error"
echo ">>> Missing 'yq' json query utility"
echo ""
exit 1
fi
echo "ok $(command -v yq)"
echo -n "hub utility "
command -v hub &> /dev/null
if [ $? -ne 0 ]; then
echo "Error"
echo ">>> Missing git 'hub' utility"
echo ""
exit 1
fi
echo "ok $(command -v hub)"
echo -n "kubectl "
command -v kubectl &> /dev/null
if [ $? -ne 0 ]; then
echo "Error"
echo ">>> Missing 'kubectl'"
echo ""
exit 1
fi
echo "ok $(command -v kubectl)"
case $DEPLOYMENT in
eks)
echo "=============================================================================="
echo "Validating EKS pre-requisites"
echo "=============================================================================="
echo -n "AWS cli "
command -v aws &> /dev/null
if [ $? -ne 0 ]; then
echo "Error"
echo ">>> Missing 'aws CLI'"
echo ""
exit 1
fi
echo "ok $(command -v aws)"
echo -n "eksctl "
command -v eksctl &> /dev/null
if [ $? -ne 0 ]; then
echo "Error"
echo ">>> Missing 'eksctl'"
echo ""
exit 1
fi
echo "ok $(command -v eksctl)"
echo -n "aws-iam-auth "
command -v aws-iam-authenticator &> /dev/null
if [ $? -ne 0 ]; then
echo "Error"
echo ">>> Missing 'aws-iam-authenticator'"
echo ""
exit 1
fi
echo "ok $(command -v aws-iam-authenticator)"
echo -n "AWS cli "
export AWS_STS_USER=$(aws sts get-caller-identity | jq -r '.UserId')
if [ -z $AWS_STS_USER ]; then
echo ">>> aws cli not configured. Configure by running \"aws configure\""
echo ""
exit 1
fi
echo "ok configured with UserId: $AWS_STS_USER"
;;
ocp)
# openshift tools
echo "=============================================================================="
echo "Validating OCP pre-requisites"
echo "=============================================================================="
echo -n "oc "
command -v oc &> /dev/null
if [ $? -ne 0 ]; then
echo "Error"
echo ">>> Missing 'oc'"
echo ""
exit 1
fi
echo "ok $(command -v oc)"
;;
aks)
# Azure
echo "=============================================================================="
echo "Validating Azure pre-requisites"
echo "=============================================================================="
echo -n "az "
command -v az &> /dev/null
if [ $? -ne 0 ]; then
echo "Error"
echo ">>> Missing 'az'"
echo ""
exit 1
fi
echo "ok $(command -v az)"
;;
gke)
# Google Cloud
echo "=============================================================================="
echo "Validating Google Cloud pre-requisites"
echo "=============================================================================="
echo -n "gcloud "
command -v gcloud &> /dev/null
if [ $? -ne 0 ]; then
echo "Error"
echo ">>> Missing 'gcloud'"
echo ""
exit 1
fi
echo "ok $(command -v gcloud)"
;;
esac
echo "=============================================================================="
echo "Validation of pre-requisites complete"
echo "=============================================================================="