Skip to content

Commit

Permalink
Add safeguards to sync script
Browse files Browse the repository at this point in the history
It's scary to run script with "rm -rf" without options:
- exit on error
- exit on pipe error
- exit on unbound variable
  • Loading branch information
kravciak committed Jun 6, 2024
1 parent b0ff960 commit 4c3c8bc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/sync-charts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
BASE_DIR="$( cd $SCRIPT_DIR && cd .. & pwd)"
Expand Down Expand Up @@ -89,7 +90,7 @@ do
mkdir -p ./charts/${NAME}
mkdir -p ./extensions/${NAME}

# Get repository name, branch, and versions
# Get repository name, branch, and versions
REPO=$(jq -r ".extensions.\"${NAME}\".repo" manifest.json)
EXT_BRANCH=$(jq -r ".extensions.\"${NAME}\".branch" manifest.json)
VERSIONS=$(jq -r ".extensions.\"${NAME}\".versions[]" manifest.json)
Expand Down Expand Up @@ -134,7 +135,7 @@ do
CHART_FILE=./charts/${NAME}/${VERSION}/Chart.yaml

ICON=$(yq eval '.icon' ${CHART_FILE})

if [ -n "${ICON}" ]; then
# Downloading icon
ICON_FILE=$(basename $ICON)
Expand All @@ -154,7 +155,7 @@ do
else
sed -i.bak -e 's@icon:.*@icon: '"${NEW_ICON}"'@' ${CHART_FILE}
fi

rm -rf ${CHART_FILE}.bak

PKG_FILE=${BASE_DIR}/extensions/${NAME}/${VERSION}/plugin/package.json
Expand All @@ -168,7 +169,7 @@ do
echo " + Updating Helm index"

# --------------------------------------------------------------------------------
# Update the helm index just for this chart
# Update the helm index just for this chart
# --------------------------------------------------------------------------------
if [ -f "${HELM_INDEX}" ]; then
UPDATE="--merge ${HELM_INDEX}"
Expand Down

0 comments on commit 4c3c8bc

Please sign in to comment.