Skip to content

🐛 Fix GetAddOnConfigRef selection order#388

Open
KevinFCormier wants to merge 2 commits into
open-cluster-management-io:mainfrom
KevinFCormier:fix-GetAddOnConfigRef-selection-order
Open

🐛 Fix GetAddOnConfigRef selection order#388
KevinFCormier wants to merge 2 commits into
open-cluster-management-io:mainfrom
KevinFCormier:fix-GetAddOnConfigRef-selection-order

Conversation

@KevinFCormier

@KevinFCormier KevinFCormier commented Jun 26, 2026

Copy link
Copy Markdown

Summary

Corrects precedence of selection when there are multiple config references of the same group-kind. (Should be last in list instead of first.)

Related issue(s)

Fixes #387

Summary by CodeRabbit

  • Bug Fixes

    • When multiple matching config references exist, the app now uses the latest matching entry instead of the first one.
    • Improved handling when no matching reference is found, returning a clear “not found” result.
  • Tests

    • Added coverage for single, missing, mixed, and duplicate match scenarios to verify the updated selection behavior.

…he first

Generated-by: Cursor (Claude Opus 4.6 High)
Signed-off-by: Kevin Cormier <kcormier@redhat.com>
Generated-by: Cursor (Claude Opus 4.6 High)
Signed-off-by: Kevin Cormier <kcormier@redhat.com>
@openshift-ci openshift-ci Bot requested review from deads2k and zhiweiyin318 June 26, 2026 17:11
@openshift-ci

openshift-ci Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: KevinFCormier
Once this PR has been reviewed and has the lgtm label, please assign deads2k for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a13bb9ab-7e44-4ffa-ae7a-09ea6a081f49

📥 Commits

Reviewing files that changed from the base of the PR and between a8d54fe and 068aeb5.

📒 Files selected for processing (2)
  • pkg/utils/addon_config.go
  • pkg/utils/addon_config_test.go

Walkthrough

GetAddOnConfigRef now scans all matching config references and returns the last match instead of the first. A new table-driven test covers empty, unmatched, single-match, multiple-match, and interleaved-match cases.

Changes

Config reference precedence

Layer / File(s) Summary
Last-match selection
pkg/utils/addon_config.go
GetAddOnConfigRef now records the last ConfigReference whose Group and Resource match before returning.
Behavior tests
pkg/utils/addon_config_test.go
TestGetAddOnConfigRef adds table-driven coverage for empty, unmatched, single-match, multiple-match, and interleaved-match cases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing GetAddOnConfigRef selection order.
Description check ✅ Passed The description includes a summary and a related issue reference, matching the template’s required sections.
Linked Issues check ✅ Passed The code now returns the last matching ConfigReference and the new test covers the reported precedence bug in #387.
Out of Scope Changes check ✅ Passed The changes are limited to the bug fix and its tests, with no unrelated additions detected.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

GetAddOnConfigRef returns first matching ConfigReference instead of last

1 participant