Skip to content

Commit

Permalink
Adjust chart packaging script...
Browse files Browse the repository at this point in the history
This ensures we have methods to edit/update charts properly.
Removes publishing helm-project-operator charts
  • Loading branch information
mallardduck committed Jan 28, 2025
1 parent 9925e37 commit 89019d4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 29 deletions.
49 changes: 22 additions & 27 deletions scripts/package-helm
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
set -e
set -x

if ! hash helm 2>/dev/null; then
echo "Helm is not installed"
Expand All @@ -13,36 +12,32 @@ source "$(dirname "$0")/util-team-charts"

cd "$(dirname "$0")/.."

# We don't do the full process for prometheus-federator
if [[ "${BUILD_TARGET}" == "prometheus-federator" ]]; then
# Fetch asset from github OB charts repo
fetch-team-chart "rancher-project-monitoring" "$RANCHER_PROJECT_MONITORING"

rm -rf build/charts
cp -rf charts build/

if [[ "$REPO" != "rancher" ]]; then
echo "Using custom repo: $REPO to build chart"
edit-chart ./build/charts/prometheus-federator/Chart.yaml "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}" "${REPO}"
else
edit-chart ./build/charts/prometheus-federator/Chart.yaml "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}"
fi
if ! package-chart ./build/charts/prometheus-federator ./build/charts ; then
echo "package-chart failed..."
exit 1
fi
exit
if [ "$BUILD_TARGET" == "helm-project-operator" ]; then
echo "$BUILD_TARGET is not a valid target for this script"
exit 1
fi

# TODO: get to the point where this can be removed
if [ "$BUILD_TARGET" == "helm-project-operator" ]; then
DEFAULT_CHART_SOURCE="./packages/$BUILD_TARGET/charts"
elif [ "$BUILD_TARGET" == "helm-locker" ]; then
if [ "$BUILD_TARGET" == "helm-locker" ]; then
echo "Preparing helm-locker dev chart"
DEFAULT_CHART_SOURCE="./examples/$BUILD_TARGET/helm-locker-chart-example"
clean-old-charts "$BUILD_TARGET"
cp -rf "${DEFAULT_CHART_SOURCE}" "./build/charts/${BUILD_TARGET}"
hl-edit-chart "./build/charts/${BUILD_TARGET}/Chart.yaml" "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}"
package-chart "./build/charts/${BUILD_TARGET}"
exit 0
fi

echo "Preparing Prometheus Federator release chart"
clean-old-charts "$BUILD_TARGET"
cp -rf "${DEFAULT_CHART_SOURCE}" "./build/charts/${BUILD_TARGET}"
cp -rf charts build/

edit-chart "./build/charts/${BUILD_TARGET}/Chart.yaml" "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}"
package-chart "./build/charts/${BUILD_TARGET}"
if [[ "$REPO" != "rancher" ]]; then
echo "Using custom repo: $REPO to build chart"
edit-chart ./build/charts/prometheus-federator/Chart.yaml "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}" "${REPO}"
else
edit-chart ./build/charts/prometheus-federator/Chart.yaml "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}"
fi
if ! package-chart ./build/charts/prometheus-federator ./build/charts ; then
echo "package-chart failed..."
exit 1
fi
19 changes: 17 additions & 2 deletions scripts/util-chart
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ function sed_i_wrapper(){

function edit-chart() {
sed_i_wrapper -i \
-e 's/^version:.*/version: '${2}'/' \
-e 's/^appVersion:.*/appVersion: '${3}'/' \
-e "s/^version:.*/version: ${2}/" \
-e "s/^appVersion:.*/appVersion: ${3}/" \
"${1}"
sed_i_wrapper -i \
-e "s/tag: ''/tag: ${3}/" \
"${1/Chart.yaml/values.yaml}"


if [ $# -ge 4 ]; then # Check if at least 4 arguments were passed
sed_i_wrapper -i \
Expand All @@ -29,6 +33,17 @@ function edit-chart() {
fi
}

function hl-edit-chart() {
sed_i_wrapper -i \
-e "s/^version:.*/version: ${2}/" \
-e "s/^appVersion:.*/appVersion: ${3}/" \
"${1}"
sed_i_wrapper -i \
-e "s/tag: head/tag: ${3}/" \
"${1/Chart.yaml/values.yaml}"
}


function package-chart() {
helm package --debug "${1:-"./build/charts/helm-project-operator"}" -d "${2:-"./build/charts"}"
}
Expand Down

0 comments on commit 89019d4

Please sign in to comment.