-
Notifications
You must be signed in to change notification settings - Fork 2
/
entrypoint
executable file
·53 lines (45 loc) · 1.21 KB
/
entrypoint
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
#!/bin/bash
set -e -x
helm init --client-only
if [ -n "$REPO" ]; then
helm repo add ${NAME%%/*} $REPO
fi
helm repo update
RELEASE_NAME=${NAME##*/}
JQ_CMD='"\(.Releases[0].AppVersion),\(.Releases[0].Status)"'
LINE="$(helm ls --all "^${RELEASE_NAME}\$" --output json | jq -r "$JQ_CMD")"
INSTALLED_VERSION=$(echo $LINE | cut -f1 -d,)
STATUS=$(echo $LINE | cut -f2 -d,)
if [ -e /config/values.yaml ]; then
VALUES="--values /config/values.yaml"
fi
if [ "$1" = "delete" ]; then
if [ -z "$INSTALLED_VERSION" ]; then
exit
fi
helm delete $RELEASE_NAME || true
helm "$@"
exit
fi
if [ -z "$INSTALLED_VERSION" ] && [ -z "$STATUS" ]; then
helm "$@" $VALUES
exit
fi
if [ -z "$VERSION" ] || [ "$INSTALLED_VERSION" = "$VERSION" ]; then
if [ "$STATUS" = "DEPLOYED" ]; then
echo Already installed $NAME, upgrading
# We assume the args are always install --name foo CHART
shift 2
helm upgrade "$@" $VALUES
exit
fi
fi
if [ "$STATUS" = "FAILED" ] || [ "$STATUS" = "DELETED" ]; then
helm delete --purge $RELEASE_NAME
echo Deleted
helm "$@" $VALUES
exit
fi
# We assume the args are always install --name foo CHART
shift 2
helm upgrade "$@" $VALUES