Skip to content

fix: skip the upcoming must-gather chart from the gather_helm detection#87

Merged
rm3l merged 1 commit intoredhat-developer:mainfrom
rm3l:fix/skip_must-gather-helm-charts-from_gather_helm
Mar 13, 2026
Merged

fix: skip the upcoming must-gather chart from the gather_helm detection#87
rm3l merged 1 commit intoredhat-developer:mainfrom
rm3l:fix/skip_must-gather-helm-charts-from_gather_helm

Conversation

@rm3l
Copy link
Member

@rm3l rm3l commented Mar 13, 2026

Description

Which issue(s) does this PR fix or relate to

  • Fixes #issue_number

PR acceptance criteria

  • Tests
  • Documentation

How to test changes / Special notes to the reviewer

@rhdh-qodo-merge
Copy link

Review Summary by Qodo

Add tests and exclude must-gather from helm detection

🐞 Bug fix 🧪 Tests

Grey Divider

Walkthroughs

Description
• Add comprehensive test suite for gather_helm script functionality
• Exclude must-gather chart from all three detection phases
  - Native Helm releases via grep and jq filters
  - Standalone Deployments with jq filter
  - Standalone StatefulSets with jq filter
• Implement case-insensitive must-gather exclusion pattern
Diagram
flowchart LR
  A["gather_helm script"] -->|Phase 1: Native Helm| B["Filter with grep -v must-gather"]
  A -->|Phase 1: Native Helm JSON| C["Filter with jq must-gather exclusion"]
  A -->|Phase 2: Standalone Deployments| D["Filter with jq must-gather exclusion"]
  A -->|Phase 2: Standalone StatefulSets| E["Filter with jq must-gather exclusion"]
  B --> F["Excluded releases"]
  C --> F
  D --> F
  E --> F
  G["Test Suite"] -->|Validates| A
Loading

Grey Divider

File Changes

1. tests/helm.bats 🧪 Tests +203/-0

Add comprehensive test suite for gather_helm script

• Created comprehensive BATS test suite with 203 lines covering gather_helm script
• Tests verify script existence, sourcing of dependencies, and pattern definitions
• Validates must-gather exclusion in all three detection phases
• Includes functional jq filter tests with sample JSON data
• Tests case-insensitive matching for must-gather exclusion

tests/helm.bats


2. collection-scripts/gather_helm 🐞 Bug fix +4/-3

Exclude must-gather from all helm detection phases

• Add grep -v 'must-gather' filter to Phase 1 text output detection
• Add jq select(.chart | test("must-gather"; "i") | not) filter to Phase 1 JSON output
• Add jq select(.metadata.name | test("must-gather"; "i") | not) filter to standalone Deployments
 detection
• Add jq select(.metadata.name | test("must-gather"; "i") | not) filter to standalone StatefulSets
 detection
• Remove unnecessary cleanup of all-rhdh-releases.json file

collection-scripts/gather_helm


Grey Divider

Qodo Logo

@rhdh-qodo-merge
Copy link

rhdh-qodo-merge bot commented Mar 13, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Must-gather case bypass 🐞 Bug ✓ Correctness
Description
In gather_helm Phase 1 text output, the must-gather exclusion uses case-sensitive `grep -v
'must-gather', so releases containing Must-Gather` (or other case variants) will still be written
to all-rhdh-releases.txt. This makes filtering inconsistent with the JSON and standalone detection
paths, which use case-insensitive matching.
Code

collection-scripts/gather_helm[49]

+helm list $namespace_args | grep -E 'REVISION|backstage|rhdh|developer-hub' | grep -v 'must-gather' > "$helm_dir/all-rhdh-releases.txt" || true
Evidence
The text-path exclusion is case-sensitive, while the JSON-path and standalone-path exclusions
explicitly use case-insensitive matching ("i"), so a case-variant can slip through only in the
text output path.

collection-scripts/gather_helm[48-52]
collection-scripts/gather_helm[189-205]
collection-scripts/gather_helm[215-226]
tests/helm.bats[195-203]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`collection-scripts/gather_helm` excludes must-gather releases in Phase 1 text output using a case-sensitive `grep -v`, but uses case-insensitive matching for JSON and standalone paths. This can allow `Must-Gather` (or other case variants) to remain in `all-rhdh-releases.txt`.

### Issue Context
Filtering should behave consistently across all detection paths; the jq paths already use `test("must-gather"; "i")`.

### Fix Focus Areas
- collection-scripts/gather_helm[48-52]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Intermediate JSON not cleaned 🐞 Bug ⛯ Reliability
Description
gather_helm no longer removes $helm_dir/all-rhdh-releases.json after parsing it, leaving an
intermediate artifact in the collected output. This increases bundle contents and diverges from the
documented helm/ output structure, while the file is not used after computing releases/namespaces.
Code

collection-scripts/gather_helm[56]

-rm -rf "$helm_dir/all-rhdh-releases.json"
Evidence
The script writes all-rhdh-releases.json and only reads it to compute
releases/release_namespaces, but does not otherwise consume it; the README’s documented output
structure for helm/ does not include this JSON file.

collection-scripts/gather_helm[49-56]
README.md[311-314]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`collection-scripts/gather_helm` creates `$helm_dir/all-rhdh-releases.json` as an intermediate parsing artifact and now leaves it in the final collected output.

### Issue Context
The file is read immediately to compute `releases` and `release_namespaces` and is not referenced elsewhere in the script. The README helm/ output structure also does not list this JSON file.

### Fix Focus Areas
- collection-scripts/gather_helm[49-57]
- README.md[311-314]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@github-actions
Copy link

PR images are available (for 1 week):

  1. https://quay.io/rhdh-community/rhdh-must-gather:pr-87
  2. https://quay.io/rhdh-community/rhdh-must-gather:pr-87-5ce943c1f
  3. https://quay.io/rhdh-community/rhdh-must-gather:0.0.0-5ce943c1f-pr-87

@rm3l rm3l force-pushed the fix/skip_must-gather-helm-charts-from_gather_helm branch from 55b4401 to 2720ee3 Compare March 13, 2026 16:55
@github-actions
Copy link

PR images are available (for 1 week):

  1. https://quay.io/rhdh-community/rhdh-must-gather:pr-87
  2. https://quay.io/rhdh-community/rhdh-must-gather:pr-87-4949c14ce
  3. https://quay.io/rhdh-community/rhdh-must-gather:0.0.0-4949c14ce-pr-87

@rm3l rm3l force-pushed the fix/skip_must-gather-helm-charts-from_gather_helm branch from 2720ee3 to 767af83 Compare March 13, 2026 17:00
@github-actions
Copy link

PR images are available (for 1 week):

  1. https://quay.io/rhdh-community/rhdh-must-gather:pr-87
  2. https://quay.io/rhdh-community/rhdh-must-gather:pr-87-18c80bccd
  3. https://quay.io/rhdh-community/rhdh-must-gather:0.0.0-18c80bccd-pr-87

@rm3l rm3l merged commit 1ba7203 into redhat-developer:main Mar 13, 2026
5 checks passed
@rm3l rm3l deleted the fix/skip_must-gather-helm-charts-from_gather_helm branch March 13, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant