-
Notifications
You must be signed in to change notification settings - Fork 1
/
do-more.sh
88 lines (78 loc) · 2.73 KB
/
do-more.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
#!/bin/bash
DO_DEPLOY_CUSTOM_FUNCTION='DO_DEPLOY_more'
# -----------------------------------------------------------------------------
# Internal function, validates whether we have all prerequisites.
# -----------------------------------------------------------------------------
function VALIDATE_MORE_PARAMS
{
if [ -z "$DEPLOY_LIB_NAME" ]; then
FAILURE "There's no DEPLOY_LIB_NAME variable in '$DEPLOY_INFO' file."
fi
if [ -z "$DEPLOY_MORE_TARGETS" ]; then
FAILURE "There's no DEPLOY_MORE_TARGETS variable in '$DEPLOY_INFO' file."
fi
}
# -----------------------------------------------------------------------------
# Deploys build with using multiple do-scripts. Script is executed in ${REPO_DIR}
# Parameters:
# $1 - version
# $2 - deploy command (push | prepare)
#
# Expected global variables:
# DEPLOY_LIB_NAME - name of library
# DEPLOY_MORE_TARGETS - list of "do" script targets
# -----------------------------------------------------------------------------
function DO_DEPLOY_more
{
local VER=$1
local DEPLOY_COMMAND=$2
VALIDATE_MORE_PARAMS
for target in $DEPLOY_MORE_TARGETS
do
if [ "$target" == "more" ]; then
FAILURE "do-more.sh cannot execute itself."
fi
if [ ! -z "$DO_MORE_TARGET" ]; then
if [ "$target" != "$DO_MORE_TARGET" ]; then
LOG "----- Skipping '$target', because only '$DO_MORE_TARGET' is selected for execution..."
continue
fi
fi
local MODE_IMPL="${TOP}/do-${target}.sh"
if [ ! -f "${MODE_IMPL}" ]; then
FAILURE "There's no deployment script for '${target}' mode."
fi
if [ "$DEPLOY_COMMAND" == "prepare" ]; then
LOG "----- Running validate for '$target' ..."
elif [ "$DEPLOY_COMMAND" == "deploy" ]; then
LOG "----- Running deploy for '$target' ..."
fi
# Read do-script
DO_DEPLOY_CUSTOM_FUNCTION=""
source "${MODE_IMPL}"
# Execute "DO_DEPLOY" or custom function
if [ -z "$DO_DEPLOY_CUSTOM_FUNCTION" ]; then
DO_DEPLOY "$@"
else
$DO_DEPLOY_CUSTOM_FUNCTION "$@"
fi
done
# Make sure that DO_DEPLOY_CUSTOM_FUNCTION is still "ours"
DO_DEPLOY_CUSTOM_FUNCTION='DO_DEPLOY_more'
}
# -----------------------------------------------------------------------------
# Prepares tag message for library. Script is executed in ${REPO_DIR}
# Parameters:
# $1 - version
#
# Expected global variables:
# DEPLOY_LIB_NAME - name of pod
#
# Prepares
# DEPLOY_TAG_MESSAGE - Message for adding tag
# -----------------------------------------------------------------------------
function DO_PREPARE_TAG_MESSAGE
{
VALIDATE_MORE_PARAMS
DEPLOY_TAG_MESSAGE="$DEPLOY_LIB_NAME version $1"
}