Flux Autodiscovery Doesn't discover some HelmRelease #6200#7641
Flux Autodiscovery Doesn't discover some HelmRelease #6200#7641josill wants to merge 6 commits intoupdatecli:mainfrom
Conversation
df7c946 to
30e9565
Compare
30e9565 to
a93a823
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes Flux autodiscovery to properly handle multi-document YAML files containing multiple HelmRelease resources. Previously, only the first HelmRelease in a multi-document file would be discovered, causing subsequent resources to be ignored.
Changes:
- Refactored HelmRelease manifest discovery to process each document in multi-document YAML files separately
- Added tracking flags to prevent duplicate file paths when multiple resources exist in one file
- Added comprehensive test coverage for multi-document YAML files
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/plugins/autodiscovery/flux/helmreleaseManifests.go | Refactored to read files once, split by YAML document separator, and process each HelmRelease document individually |
| pkg/plugins/autodiscovery/flux/helmrelease.go | Removed unused loadHelmRelease() function that only handled single documents |
| pkg/plugins/autodiscovery/flux/utils.go | Added tracking flags to prevent adding the same file path multiple times when multiple HelmRelease or OCIRepository documents exist in one file |
| pkg/plugins/autodiscovery/flux/testdata/helmrelease/multi-release/multi-helmrelease.yaml | Test data with three documents: two HelmRelease resources and one HelmRepository |
| pkg/plugins/autodiscovery/flux/main_test.go | Added test case validating that two separate manifests are generated for the multi-document file |
| pkg/plugins/autodiscovery/flux/utils_test.go | Updated to include the new multi-release test file in expected results |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| name: 'deps(flux): bump Helmrelease "udash"' | ||
| kind: 'yaml' | ||
| spec: | ||
| file: 'multi-helmrelease.yaml' |
There was a problem hiding this comment.
The target is missing the parameter documentindex to define where document Updatecli should update
|
Thank you for the pull request, while reviewing it, I realize that important parts were missing and some broader refactoring were needed, so I open this pull request #8056. |
Fix #6200
This PR fixes Flux autodiscovery to properly handle multi-document YAML files containing multiple HelmRelease resources. Previously,
discoverHelmreleaseManifests()would only process the first document in a multi-document YAML file, causing subsequent HelmRelease resources to be ignored.Changes
Refactored
discoverHelmreleaseManifests()(pkg/plugins/autodiscovery/flux/helmreleaseManifests.go):bytes.Split()loadHelmReleaseFromBytes()Fixed duplicate file path issue in
searchFluxFiles()(pkg/plugins/autodiscovery/flux/utils.go):Added comprehensive test case (
pkg/plugins/autodiscovery/flux/testdata/helmrelease/multi-release/):TestSearchFluxFilesto include the new test fileTest
To test this pull request, you can run the following commands:
Or to run the specific multi-document test case:
Additional Information
Checklist
Tradeoff
Potential improvement
searchFluxFiles()anddiscoverHelmreleaseManifests()now use the same pattern