-
Notifications
You must be signed in to change notification settings - Fork 3
/
deploy-charts.sh
executable file
·47 lines (37 loc) · 1.26 KB
/
deploy-charts.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
#!/bin/bash
# Deploy Charts
#
# Usage:
# deploy-charts.sh <repo> <folder>
#
# Info
# Packages every chart in the folder as a tarball
# Will do a single pass for requirements which exist locally
repo="$1"
folder="$2"
# build helm charts and dependencies
helm repo add datacube-charts $repo
helm repo add stable https://charts.helm.sh/stable
helm repo update
# Find dependencies in datacube-charts which match $REPO
for chart in $folder/*
do
mkdir -p "${chart}/charts"
# Create local charts, do before remote to allow use of
# freshly updated local charts
helm dependency list "$chart" \
| awk -v r="$repo" 'NR>1 {if (($3 == r) && ($4 != "ok")) print $1;}' \
| xargs -n1 -I'{}' helm package "${folder}/{}" -d "${chart}/charts"
#Manual fetch of remote charts
helm dependency list "$chart" \
| awk -v r="$repo" 'NR>1 {if (($3 != r) && ($4 != "ok")) print $3,$1;}' \
| cut -d' ' -f1,2 \
| xargs -n 2 /bin/bash -c 'helm fetch --repo "$1" --destination "$0/charts" "$2"' "$chart"
helm package "$chart"
done
# copy charts that don't already exist (ignore fail messages if they do)
cp -nv *.tgz charts/ 2>/dev/null || :
# clean up duplicate charts so they don't polute the website
rm *.tgz
# rebuild index
helm repo index charts --url $repo