github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docker/custom-scripts/fetch-all-helm-charts.sh (about) 1 #!/usr/bin/env bash 2 # 3 # This script will fetch all dependent helm charts. 4 # 5 # Syntax: ./fetch-all-helm-charts.sh KB_CHART_DIR TARGET_DIR 6 7 set -e 8 9 if [ $# -ne 2 ]; then 10 echo "Syntax: ./fetch-all-helm-charts.sh KB_CHART_DIR TARGET_DIR" 11 exit 1 12 fi 13 14 KB_CHART_DIR=${1} 15 TARGET_DIR=${2:-"charts"} 16 MANIFESTS_DIR="/tmp/manifests" 17 GITHUB_HELM_CHARTS_URL=https://github.com/apecloud/helm-charts/releases/download 18 19 # make directories 20 mkdir -p "${TARGET_DIR}" 21 mkdir -p "${MANIFESTS_DIR}" 22 23 # get all manifests 24 helm version 25 helm template "${KB_CHART_DIR}" --output-dir "${MANIFESTS_DIR}" --set addonChartLocationBase=$GITHUB_HELM_CHARTS_URL 26 27 # travel all addon manifests and get the helm charts 28 for f in "${MANIFESTS_DIR}/kubeblocks/templates/addons"/*; do 29 if [ -d "${f}" ]; then 30 continue 31 fi 32 33 kind=$(yq eval '.kind' "${f}") 34 if [ "${kind}" != "Addon" ]; then 35 continue 36 fi 37 38 # get helm chart location 39 chartURL=$(yq eval '.spec.helm.chartLocationURL' "${f}") 40 if [ -z "${chartURL}" ]; then 41 echo "chartLocationURL is empty in ${f}" 42 exit 1 43 fi 44 45 # fetch the helm chart 46 echo "fetching helm chart from ${chartURL}" 47 helm fetch "$chartURL" -d "${TARGET_DIR}" 48 done