Skip to content

Commit

Permalink
Update single chart test to work with helm 2 and fix regexp to match …
Browse files Browse the repository at this point in the history
…exact name and regardless of number of whitespaces or presence of quotes
  • Loading branch information
hwo411 committed Feb 9, 2025
1 parent ea80f2b commit 2a119a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion helm-git-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ main() {
chart_search_root="$git_sub_path"

if [ "$helm_chart_name" != "index.yaml" ] && [ "$cache_charts_enabled" = "1" ] && [ "$cache_charts_strategy" = "chart" ]; then
chart_search=$(find "$chart_search_root" -maxdepth 2 -name "Chart.yaml" -exec grep -l "name:\s$helm_chart_name" {} +)
chart_search=$(find "$chart_search_root" -maxdepth 2 -name "Chart.yaml" -exec grep -lE "name:\s*('|\")?${helm_chart_name}('|\")?(\s+|$)" {} +)
else
chart_search=$(find "$chart_search_root" -maxdepth 2 -name "Chart.yaml" -print)
fi
Expand Down
8 changes: 4 additions & 4 deletions tests/06-helm-git-cache.bats
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ load 'test-helper'
[ $status = 0 ]
run "$HELM_BIN" plugin install "$HELM_GIT_DIRNAME"
[ $status = 0 ]
run "$HELM_BIN" fetch -d "$HELM_GIT_OUTPUT" "git+https://github.com/istio/istio@manifests/charts/gateway-1.0.0.tgz?ref=1.24.2"
run "$HELM_BIN" fetch -d "$HELM_GIT_OUTPUT" "git+https://github.com/istio/istio@install/kubernetes/helm/istio-1.1.0.tgz?ref=1.1.0"
[ $status = 0 ]
echo "$output" | grep "Helm request not found in cache"
run stat "$HELM_GIT_OUTPUT/gateway-1.0.0.tgz"
run stat "$HELM_GIT_OUTPUT/istio-1.1.0.tgz"
[ $status = 0 ]
run bats_pipe ls -1 "$HELM_GIT_CHART_CACHE"/*/* \| grep -v index.yaml \| wc -l \| awk '{print $1}'
[ "$output" -gt "1" ]
run rm -rf "$HELM_GIT_CHART_CACHE"/*/*
set_chart_cache_strategy "chart"
run "$HELM_BIN" fetch -d "$HELM_GIT_OUTPUT" "git+https://github.com/istio/istio@manifests/charts/gateway-1.0.0.tgz?ref=1.24.2"
run "$HELM_BIN" fetch -d "$HELM_GIT_OUTPUT" "git+https://github.com/istio/istio@install/kubernetes/helm/istio-1.1.0.tgz?ref=1.1.0"
[ $status = 0 ]
echo "$output" | grep "Helm request not found in cache"
run stat "$HELM_GIT_OUTPUT/gateway-1.0.0.tgz"
run stat "$HELM_GIT_OUTPUT/istio-1.1.0.tgz"
[ $status = 0 ]
run bats_pipe ls -1 "$HELM_GIT_CHART_CACHE"/*/* \| grep -v index.yaml \| wc -l \| awk '{print $1}'
[ "$output" = "1" ]
Expand Down

0 comments on commit 2a119a3

Please sign in to comment.