Skip to content

Commit

Permalink
Add addon version check with the repo
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Wang <jian.wang@suse.com>
  • Loading branch information
w13915984028 committed Jun 3, 2024
1 parent 1432c99 commit 6fc7ada
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions scripts/build-bundle
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,47 @@ tar zxvf ${CHARTS_DIR}/nvidia-driver-runtime-${NVIDIA_DRIVER_RUNTIME_CHART_VERSI
# Create Helm repo index after charts are ready
helm repo index ${CHARTS_DIR}

# Check the matching of addon chart version and repo chart version
check_addon_chart_version_matching() {
echo "charts packed in Harvester repo"
ls -alht ${CHARTS_DIR}

echo "addon template files"
ls -alht ${addons_path}/pkg/templates

for filename in ${addons_path}/pkg/templates/*.yaml; do
local tmpfile=/tmp/$(basename ${filename})
grep -v "{{" ${filename} > ${tmpfile}
local cnt=$(yq '.resources | length' ${tmpfile})

local i=0
while [[ $i -lt $cnt ]] ; do
local chart=$(idx=$i yq '.resources[env(idx)].spec.chart' ${tmpfile})
local version=$(idx=$i yq '.resources[env(idx)].spec.version' ${tmpfile})
echo addon: "$chart" version: $version

local EXIT_CODE=0
local repover=$(chart=$chart yq '.entries[strenv(chart)][0].version' < ${CHARTS_DIR}/index.yaml) || EXIT_CODE=$?
if [ $EXIT_CODE != 0 ]; then
echo WARNING: addon $chart is defined, but the chart is not packed into repo / repo struct is changed
continue
fi

# some charts are not packed into arm64 ISO, the above yq will return `null`
if [[ $repover == "null" ]] && [[ ${ARCH} == "arm64" ]]; then
echo WARNING: addon "$chart" is defined with version "$version" but the chart is not packed into repo in ${ARCH}
elif [[ $repover != $version ]]; then
echo addon "$chart" has version mis-matching: in chart repo is "$repover" but in addon is "$version"
return 1
fi
(( i += 1 ))
done
done
echo "all addons have matched version with the repo"
}

check_addon_chart_version_matching

# Use offline bundle cache
if [ -n "$HARVESTER_INSTALLER_OFFLINE_BUILD" -a -e /bundle ]; then
cp -rf /bundle/* ${BUNDLE_DIR}/
Expand Down

0 comments on commit 6fc7ada

Please sign in to comment.