2022-11-18 04:05:02 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# update-csi-charts updates the Helm charts for the CSI drivers in the CLI.
|
|
|
|
|
|
|
|
set -euo pipefail
|
2023-03-29 07:58:37 -04:00
|
|
|
set -o errtrace
|
2022-11-18 04:05:02 -05:00
|
|
|
shopt -s inherit_errexit
|
|
|
|
|
2023-03-29 07:58:37 -04:00
|
|
|
echo "Updating CSI Helm charts..."
|
|
|
|
|
2022-11-18 04:05:02 -05:00
|
|
|
# Required tools
|
|
|
|
if ! command -v git &> /dev/null; then
|
|
|
|
echo "git could not be found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# download_chart downloads the Helm chart for the given CSI driver and version.
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# $1: URL of the git repo containing the Helm chart
|
|
|
|
# $2: branch or tag of the git repo
|
|
|
|
# $3: path to the Helm chart in the git repo
|
|
|
|
# $4: name of the Helm chart
|
|
|
|
download_chart() {
|
2023-03-29 07:58:37 -04:00
|
|
|
cleanup() {
|
|
|
|
rm -r "${repo_tmp_dir}"
|
|
|
|
}
|
2022-11-18 04:05:02 -05:00
|
|
|
chart_url=$1
|
|
|
|
branch=$2
|
|
|
|
chart_dir=$3
|
|
|
|
chart_name=$4
|
|
|
|
|
2023-03-29 07:58:37 -04:00
|
|
|
callDir=$(pwd)
|
2022-11-18 04:05:02 -05:00
|
|
|
repo_tmp_dir=$(mktemp -d)
|
|
|
|
|
2023-03-29 07:58:37 -04:00
|
|
|
chart_base_path="charts/edgeless/constellation-services/charts"
|
2022-11-18 04:05:02 -05:00
|
|
|
|
2023-03-29 07:58:37 -04:00
|
|
|
cd "${repo_tmp_dir}"
|
|
|
|
git clone \
|
|
|
|
--filter=blob:none \
|
|
|
|
--no-checkout \
|
|
|
|
--sparse \
|
|
|
|
--depth 1 \
|
|
|
|
--branch="${branch}" \
|
|
|
|
"${chart_url}" "${repo_tmp_dir}"
|
2022-11-18 04:05:02 -05:00
|
|
|
|
|
|
|
git sparse-checkout add "${chart_dir}"
|
|
|
|
git checkout
|
2023-03-29 07:58:37 -04:00
|
|
|
cd "${callDir}"
|
2022-11-18 04:05:02 -05:00
|
|
|
|
|
|
|
# remove old chart
|
2023-03-29 07:58:37 -04:00
|
|
|
rm -r "${chart_base_path:?}/${chart_name}"
|
2022-11-18 04:05:02 -05:00
|
|
|
|
|
|
|
# move new chart
|
|
|
|
mkdir -p "${chart_base_path}/${chart_name}"
|
2023-03-29 07:58:37 -04:00
|
|
|
cp -r "${repo_tmp_dir}/${chart_dir}"/* "${chart_base_path}/${chart_name}"
|
2022-11-18 04:05:02 -05:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
## GCP CSI Driver
|
2023-04-21 05:03:35 -04:00
|
|
|
download_chart "https://github.com/edgelesssys/constellation-gcp-compute-persistent-disk-csi-driver" "v1.2.0" "charts" "gcp-compute-persistent-disk-csi-driver"
|
2022-11-18 04:05:02 -05:00
|
|
|
|
|
|
|
## Azure CSI Driver
|
2023-04-21 05:03:35 -04:00
|
|
|
download_chart "https://github.com/edgelesssys/constellation-azuredisk-csi-driver" "v1.2.0" "charts/edgeless" "azuredisk-csi-driver"
|
2023-03-29 07:58:37 -04:00
|
|
|
|
|
|
|
echo # final newline
|