-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-functions
More file actions
57 lines (49 loc) · 1.72 KB
/
deploy-functions
File metadata and controls
57 lines (49 loc) · 1.72 KB
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
require_env_vars() {
declare env_ok=true
for var in "$@"; do
if [ -z "${!var:-}" ]; then
echo "ERROR: Environment variable not set: ${var}"
env_ok=false
fi
done
[ "${env_ok}" = true ] || exit 1
}
fetch_ml_modules() {
declare version="${1}"
declare credentials="${2}"
declare local_artifact="${3}"
declare repo_url="https://springernature.jfrog.io/springernature/libs-release-local/com/springer/ml-modules/ml-modules-${version}.zip"
echo "Downloading ml-modules artifact ${repo_url} to ${local_artifact}"
curl -q -L -fsS -u "${credentials}" -o ${local_artifact} ${repo_url}
echo
}
deploy_to_marklogic() {
declare hosts="${1}"
declare app_name="${2}"
declare app_version="${3}"
declare modules_zip="${4}"
for host in $(echo $hosts | tr -d '[:space:]' | tr ',' ' '); do
declare ml_url="http://${host}:7654/apps/${app_name}/${app_version}"
# delete first if the version is "LOCAL" or "v1" in order to replace existing modules
if [[ "${app_version}" == "LOCAL" || "${app_version}" == "v1" ]]; then
echo "Deleting existing version at ${ml_url}"
kurl -X DELETE ${ml_url}
echo
fi
echo "Deploying ${modules_zip} to ${ml_url}"
kurl --upload-file ${modules_zip} ${ml_url}
echo
echo "Finished successfully. New modules available at: ${ml_url}"
echo
done
}
# falls back to default credentials if those provided in env don't work
kurl() {
declare default_username="deployer"
declare default_password="DeployMe"
declare prefix='curl -q -fsS --digest -u'
$prefix ${MARKLOGIC_USERNAME:-$default_username}:${MARKLOGIC_PASSWORD:-$default_password} $@ || (
echo "Retrying with default creds"
$prefix ${default_username}:${default_password} $@
)
}