-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon-functions.sh
executable file
·49 lines (42 loc) · 1.48 KB
/
common-functions.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
#! /bin/bash
set -e
sedi(){
case $(uname -s) in
*[Dd]arwin* | *BSD* ) sed -i '' "$@";;
*) sed -i "$@";;
esac
}
validateFlags(){
# Use --oss-tag with --weave-mode gitops only!
if [ ${OSS_TAG} ] && [ "${WW_MODE}" != "core" ]
then
echo -e "${ERROR} Can not use [--oss-tag] with --weave-mode "${WW_MODE}". It shoud be used only with [--weave-mode gitops]"
fi
# Prevent using --weave-version and --weave-branch together!
if [ $WEAVE_VERSION ] && [ $WEAVE_BRANCH ]
then
echo -e "${ERROR} --weave-version cannot be used with --weave-branch. You should only use one!"
exit 1
fi
# Prevent using --weave-version or --weave-branch with modes other than enterprise!
if [ $WEAVE_VERSION ] || [ $WEAVE_BRANCH ]
then
if [ "${WW_MODE}" != "enterprise" ]
then
echo -e "${ERROR} [--weave-version|--weave-branch] are supported only with enterprise mode!"
exit 1
fi
fi
# Using --enable-flager with --weave-mode enterprise or leaf only!
if [ "$ENABLE_FLAGGER" == "true" ] && ( [ "${WW_MODE}" != "enterprise" ] && [ "${WW_MODE}" != "leaf" ] )
then
echo -e "${ERROR} --enable-flagger can only be used with --weave-mode=enterprise|leaf."
exit 1
fi
# Using --enable-policies with --weave-mode enterprise or leaf only!
if [ "$ENABLE_POLICIES" == "true" ] && ( [ "${WW_MODE}" != "enterprise" ] && [ "${WW_MODE}" != "leaf" ] )
then
echo -e "${ERROR} --enable-policies can only be used with --weave-mode=enterprise|leaf."
exit 1
fi
}