Skip to content
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
Uburro merged 1 commit intomainfrom
add-multiple-hrname
Jul 3, 2025
Merged

add watch external cm and secret from values and addd list of hr in same cm#1
Uburro merged 1 commit intomainfrom
add-multiple-hrname

Conversation

@Uburro
Copy link
Copy Markdown
Owner

@Uburro Uburro commented Jul 3, 2025

No description provided.

@Uburro Uburro requested a review from Copilot July 3, 2025 11:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ReconcileResource call with ReconcileHRSecretOrConfigMap.
  • Refactors BaseReconciler to handle multiple HelmRelease references per resource, adds helpers (GetOrGenerateAnnotations, RemoveHRNameFromAnnotations), and updates ReconcileResource accordingly.
  • Replaces Ginkgo-based tests with standard Go tests using testify covering the new annotation and label utilities.
  • Adds an indexer in cmd/main.go to map spec.valuesFrom names 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 helmRelease is misleading for a slice; consider renaming to helmReleaseNames or valuesFromNames to clarify it holds multiple values.
			var helmRelease []string

internal/controller/basecontroller_test.go:399

  • There are no tests covering the new ReconcileHRSecretOrConfigMap function or the watch-triggered mapping in findHelmReleasesFor*. 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 findHelmReleasesForConfigMap and findHelmReleasesForSecret share 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 {

@Uburro Uburro force-pushed the add-multiple-hrname branch from d76410b to 9235368 Compare July 3, 2025 11:45
@Uburro Uburro merged commit 60600bd into main Jul 3, 2025
6 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants