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
|
|
|
|
|
2023-06-26 04:13:28 -04:00
|
|
|
if ! command -v yq &> /dev/null; then
|
|
|
|
echo "yq could not be found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-11-18 04:05:02 -05:00
|
|
|
# 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-06-26 04:13:28 -04:00
|
|
|
csi_chart_path="charts/edgeless/csi"
|
|
|
|
chart_base_path="${csi_chart_path}/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
|
|
|
|
2023-06-26 04:13:28 -04:00
|
|
|
# get new version from Chart.yaml
|
|
|
|
new_version=$(yq '.version' "${chart_base_path}/${chart_name}/Chart.yaml")
|
|
|
|
|
|
|
|
# update dependency version in parent Chart.yaml
|
|
|
|
yq -i "(.dependencies[] | select( .name== \"${chart_name}\").version) = \"${new_version}\"" "${csi_chart_path}/Chart.yaml"
|
|
|
|
|
2022-11-18 04:05:02 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-06-30 02:46:32 -04:00
|
|
|
## AWS CSI Driver
|
2023-07-03 10:26:42 -04:00
|
|
|
download_chart "https://github.com/edgelesssys/constellation-aws-ebs-csi-driver" "v1.1.1" "charts/aws-ebs-csi-driver" "aws-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
|
|
|
|
2023-06-30 02:46:32 -04:00
|
|
|
## GCP CSI Driver
|
|
|
|
download_chart "https://github.com/edgelesssys/constellation-gcp-compute-persistent-disk-csi-driver" "v1.2.0" "charts" "gcp-compute-persistent-disk-csi-driver"
|
|
|
|
|
2023-06-26 04:13:28 -04:00
|
|
|
## OpenStack CSI Driver (cinder)
|
|
|
|
download_chart "https://github.com/edgelesssys/constellation-cloud-provider-openstack" "v1.0.0" "charts/cinder-csi-plugin" "openstack-cinder-csi"
|
|
|
|
|
2023-03-29 07:58:37 -04:00
|
|
|
echo # final newline
|