Skip to content

Commit

Permalink
fix missing util funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
mallardduck committed Oct 11, 2024
1 parent 6422a29 commit 541f76d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
10 changes: 8 additions & 2 deletions scripts/build-chart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ if [ "$BUILD_TARGET" == "prometheus-federator" ]; then
base64 -i "build/charts/${CHART}-${CHART_VERSION}.tgz" > "cmd/${BUILD_TARGET}/fs/${CHART}.tgz.base64"
rm "build/charts/${CHART}-${CHART_VERSION}.tgz"
elif [ "$BUILD_TARGET" == "helm-project-operator" ]; then
# Prepare base chart for build
rm -rf build/charts
mkdir -p build/charts
cp -rf "examples/helm-project-operator/${CHART}" build/charts/


# Update the chart placeholders
edit-charts "examples/helm-project-operator/${CHART}/Chart.yaml" "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}"
package-charts "./examples/helm-project-operator/${CHART}" ./build/charts
edit-charts "build/charts/${CHART}/Chart.yaml" "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}"
package-charts "./build/charts/${CHART}" ./build/charts

# Prepare chart for embedding location
base64 -i "./build/charts/${CHART}-${HELM_CHART_VERSION}.tgz" > "cmd/${BUILD_TARGET}/fs/${CHART}.tgz.base64"
Expand Down
18 changes: 17 additions & 1 deletion scripts/util-chart
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
#!/usr/bin/env bash

function is_gnu_sed(){
sed --version >/dev/null 2>&1
}

function sed_i_wrapper(){
if is_gnu_sed; then
$(which sed) "$@"
else
a=()
for b in "$@"; do
[[ $b == '-i' ]] && a=("${a[@]}" "$b" "") || a=("${a[@]}" "$b")
done
$(which sed) "${a[@]}"
fi
}

function edit-charts() {
sed -i \
sed_i_wrapper -i \
-e 's/^version:.*/version: '${2}'/' \
-e 's/^appVersion:.*/appVersion: '${3}'/' \
"${1}"
Expand Down

0 comments on commit 541f76d

Please sign in to comment.