forked from liquibase/liquibase-github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.sh
executable file
·221 lines (197 loc) · 8.63 KB
/
entry.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
OPERATION=$1
CLASSPATH=$2
CHANGELOGFILE=$3
USERNAME=$4
PASSWORD=$5
URL=$6
COUNT=$7
TAG=$8
DATE=$9
REFERENCEURL=${10}
CHECKSSETTINGSFILE=${11}
PROLICENSEKEY=${12}
HUBAPIKEY=${13}
LICENSEKEY=${14}
DATABASECHANGELOGTABLENAME=${15}
DATABASECHANGELOGLOCKTABLENAME=${16}
PARAMS=()
VALUES=()
# Liquibase requires some parameters to come after the command name, those parameters should be added to this list.
SECONDPARAMS=()
function check_required_param() {
local OP=$1
local KEY=$2
local VAL=$3
local IsVALUE=${4:-false}
local IsSecondParam=${5:-false}
if [ -z "$VAL" ]
then
echo "$OP requires $KEY to not be empty"
exit 1
fi
check_optional_param "$OP" "$KEY" "$VAL" "$IsVALUE" "$IsSecondParam"
}
function check_optional_param() {
local OP=$1
local KEY=$2
local VAL=$3
local IsVALUE=${4:-false}
local IsSecondParam=${5:-false}
if [ -z "$VAL" ]
then
echo "$KEY is empty"
else
if [ "$IsVALUE" = true ]
then
VALUES+=($VAL)
else
if [ "$IsSecondParam" = true ]
then
SECONDPARAMS+=(--$KEY=$VAL)
else
PARAMS+=(--$KEY=$VAL)
fi
fi
fi
}
function validate_operation() {
case $OPERATION in
update)
check_required_param update username $USERNAME
check_required_param update password $PASSWORD
check_required_param update classpath $CLASSPATH
check_required_param update changeLogFile $CHANGELOGFILE
check_required_param update url $URL
check_optional_param update databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param update databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
updateCount)
check_required_param updateCount username $USERNAME
check_required_param updateCount password $PASSWORD
check_required_param updateCount classpath $CLASSPATH
check_required_param updateCount changeLogFile $CHANGELOGFILE
check_required_param updateCount url $URL
check_required_param updateCount count $COUNT true
check_optional_param updateCount databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param updateCount databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
tag)
check_required_param tag username $USERNAME
check_required_param tag password $PASSWORD
check_required_param tag url $URL
check_required_param tag tag $TAG true
check_optional_param tag databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param tag databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
updateToTag)
check_required_param updateToTag username $USERNAME
check_required_param updateToTag password $PASSWORD
check_required_param updateToTag classpath $CLASSPATH
check_required_param updateToTag changeLogFile $CHANGELOGFILE
check_required_param updateToTag url $URL
check_required_param updateToTag tag $TAG true
check_optional_param updateToTag databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param updateToTag databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
updateTestingRollback)
check_required_param updateTestingRollback username $USERNAME
check_required_param updateTestingRollback password $PASSWORD
check_required_param updateTestingRollback classpath $CLASSPATH
check_required_param updateTestingRollback changeLogFile $CHANGELOGFILE
check_required_param updateTestingRollback url $URL
;;
rollback)
check_required_param rollback username $USERNAME
check_required_param rollback password $PASSWORD
check_required_param rollback classpath $CLASSPATH
check_required_param rollback changeLogFile $CHANGELOGFILE
check_required_param rollback url $URL
check_required_param rollback tag $TAG true
check_optional_param rollback databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param rollback databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
rollbackCount)
check_required_param rollbackCount username $USERNAME
check_required_param rollbackCount password $PASSWORD
check_required_param rollbackCount classpath $CLASSPATH
check_required_param rollbackCount changeLogFile $CHANGELOGFILE
check_required_param rollbackCount url $URL
check_required_param rollbackCount count $COUNT true
check_optional_param rollbackCount databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param rollbackCount databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
rollbackToDate)
check_required_param rollbackToDate username $USERNAME
check_required_param rollbackToDate password $PASSWORD
check_required_param rollbackToDate classpath $CLASSPATH
check_required_param rollbackToDate changeLogFile $CHANGELOGFILE
check_required_param rollbackToDate url $URL
check_required_param rollbackToDate date $DATE true
check_optional_param rollbackToDate databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param rollbackToDate databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
updateSQL)
check_required_param updateSQL username $USERNAME
check_required_param updateSQL password $PASSWORD
check_required_param updateSQL classpath $CLASSPATH
check_required_param updateSQL changeLogFile $CHANGELOGFILE
check_required_param updateSQL url $URL
check_optional_param updateSQL databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param updateSQL databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
futureRollbackSQL)
check_required_param futureRollbackSQL username $USERNAME
check_required_param futureRollbackSQL password $PASSWORD
check_required_param futureRollbackSQL classpath $CLASSPATH
check_required_param futureRollbackSQL changeLogFile $CHANGELOGFILE
check_required_param futureRollbackSQL url $URL true
check_optional_param futureRollbackSQL databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param futureRollbackSQL databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
status)
check_required_param status username $USERNAME
check_required_param status password $PASSWORD
check_required_param status classpath $CLASSPATH
check_required_param status changeLogFile $CHANGELOGFILE
check_required_param status url $URL
check_optional_param status databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param status databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
history)
check_required_param history username $USERNAME
check_required_param history password $PASSWORD
check_required_param history url $URL
check_optional_param history databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param history databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
diff)
check_required_param diff username $USERNAME
check_required_param diff password $PASSWORD
check_required_param diff url $URL
check_required_param diff referenceUrl $REFERENCEURL true
check_optional_param diff databaseChangeLogTableName $DATABASECHANGELOGTABLENAME
check_optional_param diff databaseChangeLogLockTableName $DATABASECHANGELOGLOCKTABLENAME
;;
validate)
check_required_param validate username $USERNAME
check_required_param validate password $PASSWORD
check_required_param validate url $URL
check_required_param validate changeLogFile $CHANGELOGFILE
check_optional_param validate classpath $CLASSPATH
;;
"checks run")
check_required_param "checks run" changeLogFile $CHANGELOGFILE
check_required_param "checks run" checksSettingsFile $CHECKSSETTINGSFILE false true
;;
*)
echo "$OPERATION is not a valid operation"
exit 1
;;
esac
}
check_optional_param "$OPERATION" proLicenseKey $PROLICENSEKEY
check_optional_param "$OPERATION" hubApiKey $HUBAPIKEY
check_optional_param "$OPERATION" licenseKey $LICENSEKEY
validate_operation
docker-entrypoint.sh "${PARAMS[@]}" --log-level=FINE $OPERATION "${VALUES[@]}" "${SECONDPARAMS[@]}"