-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpull-charts-from-list.sh
executable file
·31 lines (25 loc) · 1.21 KB
/
pull-charts-from-list.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
#!/bin/bash
# This script reads a file called charts.txt with the following format:
# chartName,version,repoURL
# It will pull the chart from the repo and decompress it in the charts directory
# This scripts complements the pull-charts-from-values.sh script and
# is useful to pull charts from a list that are not part of the app of apps values.yaml
compressedDir="./compressed"
chartsDir="./charts"
filename="charts.csv"
while IFS=, read -r chart targetVersion repoURL
do
[[ $chart =~ ^#.*$ ]] && continue # Skip lines starting with #
echo "Pulling chart: $chart, version: $targetVersion from repo: $repoURL"
# Check if the repoURL is an OCI repository
if [[ $repoURL == oci://* ]]; then
# Pull the chart from an OCI repository
helm pull $repoURL/$chart --version $targetVersion --destination "$compressedDir"
helm export $repoURL/$chart --version $targetVersion --destination "$compressedDir"
else
# Pull the chart from a non-OCI repository
helm pull $chart --version $targetVersion --repo $repoURL --destination "$compressedDir"
fi
echo "Decompressing chart: $chart"
tar -xzvf $compressedDir/$chart-$targetVersion.tgz -C "$chartsDir"
done < "$filename"