From 1361a32cf94bb973ca1315eadccbe84420ca00b2 Mon Sep 17 00:00:00 2001 From: Brian Downs Date: Thu, 10 Sep 2020 11:04:20 -0700 Subject: [PATCH] per @dweomer, update build-chart script to fail correctly if specified version does not exist Signed-off-by: Brian Downs --- charts/build-chart.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/charts/build-chart.sh b/charts/build-chart.sh index ebde514e5f..ee9392a0cf 100755 --- a/charts/build-chart.sh +++ b/charts/build-chart.sh @@ -1,15 +1,20 @@ #!/usr/bin/env bash + set -eux -o pipefail + : "${CHART_FILE?required}" +: "${CHART_NAME:="$(basename "${CHART_FILE%%-chart.yml}")"}" +: "${CHART_URL:="${CHART_REPO:="https://rke2-charts.rancher.io"}/assets/${CHART_NAME}/${CHART_NAME}-${CHART_VERSION:="v0.0.0"}.tgz"}" +curl -fsSL "${CHART_URL}" -o "${CHART_TMP:=$(mktemp)}" cat <<-EOF > "${CHART_FILE}" apiVersion: helm.cattle.io/v1 kind: HelmChart metadata: - name: "${CHART_NAME:="$(basename "${CHART_FILE%%-chart.yml}")"}" + name: "${CHART_NAME}" namespace: "${CHART_NAMESPACE:="kube-system"}" annotations: - helm.cattle.io/chart-url: "${CHART_URL:="${CHART_REPO:="https://rke2-charts.rancher.io"}/assets/${CHART_NAME}/${CHART_NAME}-${CHART_VERSION:="v0.0.0"}.tgz"}" + helm.cattle.io/chart-url: "${CHART_URL}" spec: bootstrap: ${CHART_BOOTSTRAP:=false} - chartContent: $(curl -fsSL "${CHART_URL}" | base64 -w0) + chartContent: $(base64 -w0 < "${CHART_TMP}") EOF