This repository was archived by the owner on Aug 13, 2025. It is now read-only.
add watch external cm and secret from values and addd list of hr in same cm#1
Merged
add watch external cm and secret from values and addd list of hr in same cm#1
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements autodiscovery of external ConfigMaps and Secrets referenced by HelmReleases, tracks those references via annotations, and triggers reconciliations when such resources are created.
- Introduces watches for ConfigMaps and Secrets in the HRAutodiscover controller and replaces the old
ReconcileResourcecall withReconcileHRSecretOrConfigMap. - Refactors
BaseReconcilerto handle multiple HelmRelease references per resource, adds helpers (GetOrGenerateAnnotations,RemoveHRNameFromAnnotations), and updatesReconcileResourceaccordingly. - Replaces Ginkgo-based tests with standard Go tests using
testifycovering the new annotation and label utilities. - Adds an indexer in
cmd/main.goto mapspec.valuesFromnames to HelmReleases.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/controller/hrautodiscovercontroller.go | Added handler import, watches for external Secrets and ConfigMaps, and new ReconcileHRSecretOrConfigMap. |
| internal/controller/basecontroller.go | Refactored annotation handling, updated ReconcileResource for multiple HRs, and added helper methods. |
| internal/controller/basecontroller_test.go | Converted Ginkgo tests to Go’s testing + testify, covering annotation and label functions. |
| cmd/main.go | Added a field index on spec.valuesFrom to link ConfigMaps/Secrets to HelmReleases. |
| go.mod | Added dependencies: testify and go-difflib for testing. |
Comments suppressed due to low confidence (6)
cmd/main.go:320
- [nitpick] The variable name
helmReleaseis misleading for a slice; consider renaming tohelmReleaseNamesorvaluesFromNamesto clarify it holds multiple values.
var helmRelease []string
internal/controller/basecontroller_test.go:399
- There are no tests covering the new
ReconcileHRSecretOrConfigMapfunction or the watch-triggered mapping infindHelmReleasesFor*. Consider adding tests to validate that Secrets and ConfigMaps enqueue the correct HelmRelease reconcile requests.
}
internal/controller/hrautodiscovercontroller.go:15
- Add missing imports for fmt and k8s.io/apimachinery/pkg/types to support fmt.Errorf and types.NamespacedName in ReconcileHRSecretOrConfigMap.
"sigs.k8s.io/controller-runtime/pkg/handler"
internal/controller/basecontroller.go:84
- Checking only len(listHRName)==0 will never skip an empty-string entry (Split yields [""]). You should instead check if the first element is empty or filter out empty names before processing.
if len(listHRName) == 0 {
internal/controller/basecontroller.go:366
- Missing import of "sigs.k8s.io/controller-runtime/pkg/reconcile" for reconcile.Request, resulting in an unresolved identifier.
func (r *BaseReconciler) findHelmReleasesForConfigMap(ctx context.Context, obj client.Object) []reconcile.Request {
internal/controller/basecontroller.go:404
- [nitpick] The two methods
findHelmReleasesForConfigMapandfindHelmReleasesForSecretshare nearly identical logic. Extract common listing and filtering into a shared helper to reduce duplication.
func (r *BaseReconciler) findHelmReleasesForSecret(ctx context.Context, obj client.Object) []reconcile.Request {
d76410b to
9235368
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.