forked from toolforge/buildservice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·54 lines (51 loc) · 1.25 KB
/
deploy.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
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
help() {
cat <<EOH
Usage: $0 [OPTIONS] <ENVIRONMENT>
Options:
-h Show this help.
-v Show verbose output.
EOH
}
deploy_generic() {
local environment="${1?No environment passed}"
if [[ "$environment" = "devel" ]]; then
sed "s/{{HARBOR_IP}}/${HARBOR_IP}/"\
deploy/devel/auth-patch.yaml.template > deploy/devel/auth-patch.yaml
fi
if command -v minikube >/dev/null; then
kubectl="minikube kubectl --"
else
kubectl="kubectl"
fi
$kubectl apply -k "deploy/base-tekton"
$kubectl apply -k "deploy/$environment"
}
main () {
while getopts "hv" option; do
case "${option}" in
h)
help
exit 0
;;
v) set -x;;
*)
echo "Wrong option $option"
help
exit 1
;;
esac
done
shift $((OPTIND-1))
local environment="${1?No environment passed}"
if [[ ! -d "deploy/$environment" || "$environment" =~ ^(base|README)$ ]]; then
echo "Unknown environment $environment, use one of:"
ls deploy/ | egrep -v '^(base|README)'
exit 1
fi
deploy_generic "$environment"
}
main "$@"