-
Notifications
You must be signed in to change notification settings - Fork 134
/
helmdiff.sh
executable file
·78 lines (65 loc) · 2.58 KB
/
helmdiff.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
#!/bin/bash
set -euo pipefail
DEV_TOOLS_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROXCTL="$DEV_TOOLS_ROOT/roxctl.sh"
CHARTS="central-services secured-cluster-services"
TMP_ROOT=$(mktemp -d -t helm_diff_)
WORKING_BRANCH=$(git branch --show-current)
echo "Generating temporary files in ${TMP_ROOT}"
echo "Rendering from metatemplates to helm charts:"
for CHART in ${CHARTS}; do
$ROXCTL helm output --debug --remove "${CHART}" --output-dir="${TMP_ROOT}/${CHART}-new"
done
REPO_STAT="$(git diff --stat)"
# TODO(ebensh): Use smart branch root (if present) instead of master.
if [[ -n $REPO_STAT ]]; then
echo "Saving uncommitted changes with 'git stash push'."
git stash push
fi
git switch master
for CHART in ${CHARTS}; do
$ROXCTL helm output --debug --remove "${CHART}" --output-dir="${TMP_ROOT}/${CHART}-old"
done
git switch "${WORKING_BRANCH}"
if [[ -n $REPO_STAT ]]; then
echo "Restoring uncommitted changes with 'git stash pop'."
git stash pop
fi
echo "Rendering a dry run installation of the stackrox-central-services helm charts as Kubernetes manifests:"
for VERSION in "old" "new"; do
helm install --debug --dry-run \
-n stackrox \
--disable-openapi-validation \
--set central.persistence.none=true \
stackrox-central-services \
"${TMP_ROOT}"/central-services-${VERSION} \
> "${TMP_ROOT}"/central-services-${VERSION}-installation.yaml
done
echo "Rendering a dry run installation of the stackrox-secured-cluster-services helm charts as Kubernetes manifests:"
for VERSION in "old" "new"; do
helm install --debug --dry-run \
-n stackrox \
--disable-openapi-validation \
--set clusterName=mergers-and-acquisitions \
--set ca.cert=a1 \
--set serviceTLS.cert=b2 \
--set serviceTLS.key=c3 \
--set createSecrets=false \
stackrox-secured-cluster-services \
"${TMP_ROOT}"/secured-cluster-services-${VERSION} \
> "${TMP_ROOT}"/secured-cluster-services-${VERSION}-installation.yaml
done
cat <<EOF
=== ${TMP_ROOT} ===
To compare helm charts:
diff -ruN "${TMP_ROOT}/central-services-old" "${TMP_ROOT}/central-services-new"
diff -ruN "${TMP_ROOT}/secured-cluster-services-old" "${TMP_ROOT}/secured-cluster-services-new"
To compare stackrox-central-services chart installation (Kubernetes manifests):"
diff -ruN \
${TMP_ROOT}/central-services-old-installation.yaml \
${TMP_ROOT}/central-services-new-installation.yaml
To compare secured-cluster-services chart installation (Kubernetes manifests):"
diff -ruN \
${TMP_ROOT}/secured-cluster-services-old-installation.yaml \
${TMP_ROOT}/secured-cluster-services-new-installation.yaml
EOF