Skip to content

Commit c6976c3

Browse files
committed
refactor: improve helmChart version handling and exclude templates chart
- Refactor the loop that sets helmChart versions to fix path issues - Exclude the templates chart from package step - Add better variable exports and improve command structure
1 parent 9491fc8 commit c6976c3

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

applications/wg-easy/Taskfile.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,23 +233,24 @@ tasks:
233233
- find ./replicated -name '*.yaml' -not -name 'config.yaml' -exec cp {} ./release/ \; 2>/dev/null || true
234234

235235
# extract namespaces from helmChart files
236+
- echo "Extracting namespaces from helmChart files..."
236237
- yq ea '[.spec.namespace] | unique' ./charts/*/replicated/helmChart-*.yaml | yq '.spec.additionalNamespaces *= load("/dev/stdin") | .spec.additionalNamespaces += "*" ' replicated/application.yaml > release/application.yaml.new
238+
- cat release/application.yaml.new
237239
- mv release/application.yaml.new release/application.yaml
238240

239241
# set helmChart versions from associated helm Chart.yaml
240242
- echo "Setting helmChart versions..."
241243
- |
242-
while read directory; do
243-
244-
echo $directory
245-
parent=$(basename $(dirname $directory))
246-
244+
# Find all replicated directories and update helmChart files in one loop
245+
find ./charts -maxdepth 2 -mindepth 2 -type d -name replicated | while read chartDir; do
246+
echo $chartDir
247+
parent=$(basename $(dirname $chartDir))
248+
247249
helmChartName="helmChart-$parent.yaml"
248-
export version=$(yq -r '.version' $parent/Chart.yaml )
249-
250-
yq '.spec.chart.chartVersion = strenv(version) | .spec.chart.chartVersion style="single"' $directory/$helmChartName | tee release/$helmChartName
251-
252-
done < <(find . -maxdepth 2 -mindepth 2 -type d -name replicated)
250+
export version=$(yq -r '.version' $chartDir/../Chart.yaml )
251+
252+
yq '.spec.chart.chartVersion = strenv(version) | .spec.chart.chartVersion style="single"' $chartDir/$helmChartName | tee release/$helmChartName
253+
done
253254
254255
# Merge config.yaml files
255256
- echo "Merging config.yaml files..."
@@ -274,8 +275,8 @@ tasks:
274275
# Package Helm charts
275276
- echo "Packaging Helm charts..."
276277
- |
277-
# Find top-level directories containing Chart.yaml files
278-
for chart_dir in $(find charts/ -maxdepth 2 -name "Chart.yaml" | xargs dirname); do
278+
# Find top-level directories containing Chart.yaml files, excluding the templates chart
279+
for chart_dir in $(find charts/ -maxdepth 2 -name "Chart.yaml" | grep -v "charts/templates" | xargs dirname); do
279280
echo "Packaging chart: $chart_dir"
280281
# Navigate to chart directory, package it, and move the resulting .tgz to release folder
281282
(cd "$chart_dir" && helm package . && mv *.tgz ../../release/)

0 commit comments

Comments
 (0)