-
Notifications
You must be signed in to change notification settings - Fork 0
/
pull-exactly.sh
executable file
·52 lines (42 loc) · 1.18 KB
/
pull-exactly.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
#!/usr/bin/env bash
TEMP_DIR=$(mktemp -d)
ARGS=("$HELM_BIN" "pull")
MY_ARGS=("$HELM_BIN" "pull" "--untar" "--untardir" "$TEMP_DIR")
VERSION=""
function debug {
[[ "$HELM_DEBUG" == "true" ]] && echo "helm pull-exactly: $*"
}
while [[ $# -gt 0 ]]; do
case $1 in
--version)
VERSION="$2"
ARGS+=("$1")
MY_ARGS+=("$1")
shift
ARGS+=("$1")
MY_ARGS+=("$1")
shift
;;
-h|--help)
echo "Mimics the helm pull arguments but asserts the version is exactly as specified"
exit 0
;;
-d|--destination|--untar|--untardir|--prov)
# ignore these flags
ARGS+=("$1")
shift
;;
*)
MY_ARGS+=("$1")
ARGS+=("$1")
shift
;;
esac
done
[[ -z "$VERSION" ]] && debug "No version specified" && exit 1
eval "${MY_ARGS[@]}"
CHART_NAME=$(ls "$TEMP_DIR")
[[ -z "$CHART_NAME" ]] && debug "Failed to pull down chart with command" "${MY_ARGS[@]}" && exit 1
CHART_VERSION=$(grep ^version "${TEMP_DIR}"/"${CHART_NAME}"/Chart.yaml | sed 's/version: //g')
[[ "$CHART_VERSION" != "$VERSION" ]] && debug "Versions do not match: given version=${VERSION} found version=${CHART_VERSION}" && exit 1
eval "${ARGS[@]}"