-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpull-charts-from-values.sh
executable file
·47 lines (37 loc) · 1.73 KB
/
pull-charts-from-values.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
# This script reads the values.yaml of app of apps in kuberise and pulls all the helm charts to the charts directory.
# This is usefull to read or search the source of all charts and see the values of the charts.
# Define the path to the kuberise app of apps values.yaml file
valuesFile="../kuberise/app-of-apps/values.yaml"
# Define directories for compressed charts and extracted charts
compressedDir="./compressed"
chartsDir="./charts"
# Ensure the directories exist
mkdir -p "$compressedDir"
mkdir -p "$chartsDir"
# Function to process each helm chart
processChart() {
local chart=$1
local repoURL=$2
local targetVersion=$3
# Determine if the chart archive already exists and is up-to-date
local chartArchive="$compressedDir/${chart}-${targetVersion}.tgz"
local chartDir="$chartsDir/${chart}"
# Check if the chart is already extracted and up-to-date
if [[ -f "$chartArchive" && -d "$chartDir" ]]; then
# Assuming no need to check the version inside the extracted folder
return # Chart is up-to-date; do nothing
fi
# Download the chart archive if it doesn't exist or isn't up-to-date
echo "Downloading chart $chart version $targetVersion..."
helm pull $chart --version $targetVersion --repo $repoURL --destination "$compressedDir"
# Extract chart to the charts directory
echo "Extracting $chartArchive to $chartDir..."
mkdir -p "$chartDir"
tar -xzf "$chartArchive" -C "$chartDir" --strip-components=1
}
# Iterate over each helm chart in the values file
yq e '.helmCharts[] | .chart + " " + .repoURL + " " + .targetRevision' $valuesFile | while read -r line; do
read chart repoURL targetVersion <<<"$line"
processChart "$chart" "$repoURL" "$targetVersion"
done