Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -377,17 +377,28 @@ runs:
working-directory: ${{ inputs.overlay_dir }}
run: |
set -euo pipefail

# Auto-detect helmCharts; pass --enable-helm only when present.
HELM_FLAG=()
if command -v yq >/dev/null 2>&1; then
if yq -e '.helmCharts // [] | length > 0' kustomization.yaml >/dev/null 2>&1; then
HELM_FLAG=(--enable-helm --load-restrictor=LoadRestrictionsNone)
fi
elif grep -qE '^helmCharts:[[:space:]]*$' kustomization.yaml 2>/dev/null; then
HELM_FLAG=(--enable-helm --load-restrictor=LoadRestrictionsNone)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grep fallback misses helmCharts with trailing YAML comments

Medium Severity

The grep fallback pattern '^helmCharts:[[:space:]]*$' requires end-of-line immediately after optional whitespace, so it won't match a helmCharts: line that has a trailing YAML comment (e.g. helmCharts: # deploy nginx). Since the yq path handles this correctly, the two detection paths are inconsistent. When yq is unavailable (i.e. version_label is not set), this false negative means --enable-helm is silently omitted, causing kustomize build to fail with no workaround in the action.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6f9b1c4. Configure here.

fi

echo "✅ Validating kustomization..."
if ! kustomize build . > /dev/null 2>&1; then
if ! kustomize build "${HELM_FLAG[@]}" . > /dev/null 2>&1; then
echo "::error::Kustomization validation failed"
kustomize build . 2>&1 | head -20
kustomize build "${HELM_FLAG[@]}" . 2>&1 | head -20
exit 1
fi

# Check that version label is not in selectors (would cause immutable field error)
if [ -n "${{ inputs.version_label }}" ]; then
echo "🔍 Checking selectors don't contain version label..."
MANIFESTS=$(kustomize build .)
MANIFESTS=$(kustomize build "${HELM_FLAG[@]}" .)
# Use yq to check if any selector.matchLabels contains the version label
if echo "$MANIFESTS" | yq -e 'select(.spec.selector.matchLabels."app.kubernetes.io/version")' >/dev/null 2>&1; then
echo "::error::Version label found in selector.matchLabels (immutable field). This would cause deployment to fail."
Expand Down
Loading