-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathchart-updates
executable file
·43 lines (34 loc) · 1.07 KB
/
chart-updates
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
#!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")/.."
. bin/util.sh
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Usage: $0 [-h|--help]"
echo "List helm charts in the current repository that are outdated."
exit
fi
check_command_exists helm version
check_command_exists helmfile
check_command_exists yq
# Add repository indexes
helmfile repos
index=$(helm search repo -o yaml | yq -r '.[] as $item ireduce ({}; . * {($item.name): $item.version})')
ok=""
warn=""
err=""
while read chart
do
name=$(echo "$chart" | cut -d $'\t' -f 1)
version=$(echo "$chart" | cut -d $'\t' -f 2)
listed_version=$(echo "$index" | yq ".\"$name\"")
if [ "$listed_version" != "$version" ]; then
if [[ "$name" == *"radar/"* ]]; then
err+="$name ERROR $version $listed_version\n"
else
warn+="$name WARNING $version $listed_version\n"
fi
else
ok+="$name OK $version $listed_version\n"
fi
done < <(helmfile list --output json | yq ".[] | [.chart, .version] | @tsv")
printf "NAME STATUS VERSION LATEST\n$ok$warn$err" | column -t
exit $(printf "$err" | wc -l)