Skip to content

Conversation

@lexfrei
Copy link
Contributor

@lexfrei lexfrei commented Dec 26, 2025

What this PR does

Adds deterministic alphabetical sorting to all registry resource lists:

  • TenantNamespace (sorted by name)
  • TenantSecret (sorted by namespace/name)
  • TenantModule (sorted by namespace/name)
  • Application (sorted by namespace/name)

Introduces a new pkg/registry/sorting package with generic helper functions
to avoid code duplication.

Also fixes pre-existing linter errors:

  • Unused helmReleaseGVR variables
  • Non-constant format strings in klog.Errorf calls
  • Redundant embedded field selectors

Release note

[platform] Registry resource lists are now returned in alphabetical order

Summary by CodeRabbit

  • New Features

    • Added a reusable alphabetical sorting utility and applied consistent sorting across list endpoints.
  • Bug Fixes

    • Ensured ResourceVersion/UID are sourced correctly for accurate list/table responses.
    • Simplified and improved error logging and table ResourceVersion handling.
    • Made schema defaulting behavior more consistent.
  • Tests

    • Added unit tests validating alphabetical sorting for multiple resource types.

✏️ Tip: You can customize this high-level summary in your review settings.

lexfrei and others added 2 commits December 26, 2025 12:48
Add sorting helper package with generic functions for sorting
resources by name (cluster-scoped) or namespace/name (namespace-scoped).

Apply sorting to:
- TenantNamespace (by name)
- TenantSecret (refactored to use helper)
- TenantModule (new)
- Application (new)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
- Remove unused helmReleaseGVR variables
- Fix non-constant format strings in klog.Errorf calls
- Simplify embedded field selectors (ListMeta, ObjectMeta, Generic)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 26, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Removed hard-coded GVRs, standardized ResourceVersion/UID sourcing from Application/Tenant objects, introduced reusable generic sorting helpers, applied consistent alphabetical sorting across several list endpoints, adjusted table ResourceVersion assignments, tightened some logging/error handling, and added unit tests for sorting and list ordering.

Changes

Cohort / File(s) Summary
Sorting utility
pkg/registry/sorting/sort.go, pkg/registry/sorting/sort_test.go
Added generic sorting helpers: ByName, ByNamespacedName, NameGetter/NamespaceGetter interfaces; unit tests for both sorting behaviors.
Application REST
pkg/registry/apps/application/rest.go, pkg/registry/apps/application/rest_sorting_test.go, pkg/registry/apps/application/rest_defaulting.go
Removed hard-coded HelmRelease GVR; List results post-sorted with ByNamespacedName; ResourceVersion/UID mappings now sourced from Application fields; ConvertToTable uses object/list ResourceVersion; defaulting reads moved from Generic.DefaultDefault; logging/error handling tightened.
TenantModule REST
pkg/registry/core/tenantmodule/rest.go, pkg/registry/core/tenantmodule/rest_test.go
Removed GVR usage; apply ByNamespacedName to lists; ConvertToTable sets ResourceVersion from lists/objects; simplified error logging; added sorting unit test.
TenantNamespace REST
pkg/registry/core/tenantnamespace/rest.go, pkg/registry/core/tenantnamespace/rest_test.go
Added ByName sorting in list construction; ConvertToTable assigns tbl.ResourceVersion from list/object; added test validating alphabetical ordering.
TenantSecret REST
pkg/registry/core/tenantsecret/rest.go
Replaced inline comparator with ByNamespacedName; switched ResourceVersion assignments to object/list fields; removed direct slices usage.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through lists with gentle paws,

Names sorted neat without a single flaw,
GVRs untangled, versions set true,
Helpers hum and tests cheered too,
A carrot for the tidy view.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: adding alphabetical sorting to registry resource lists. It is concise, specific, and clearly summarizes the primary change.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9cad45 and da56c88.

📒 Files selected for processing (1)
  • pkg/registry/sorting/sort.go
🧰 Additional context used
📓 Path-based instructions (2)
pkg/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Follow controller-runtime patterns and kubebuilder style for Go code in pkg directory

Files:

  • pkg/registry/sorting/sort.go
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Do NOT manually edit vendor/ directory or auto-generated files (zz_generated.*.go)

Files:

  • pkg/registry/sorting/sort.go
🔇 Additional comments (3)
pkg/registry/sorting/sort.go (3)

11-20: LGTM! Clean interface design.

The interfaces are minimal, well-documented, and use idiomatic Go composition via embedding. The separation between cluster-scoped and namespace-scoped resources is clear.


22-32: LGTM! Previous feedback addressed.

The implementation now uses strings.Compare, which is idiomatic and efficient. The generic type constraints properly ensure compile-time safety, and the in-place sorting follows standard Go conventions.


34-47: LGTM! Previous feedback addressed.

The implementation now compares namespace first, then name, which avoids unnecessary string allocations and is more efficient than concatenation. The use of strings.Compare with short-circuit evaluation is idiomatic and performant.


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 and usage tips.

@lexfrei lexfrei marked this pull request as ready for review December 26, 2025 09:56
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Dec 26, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lexfrei, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the user experience and consistency across the platform by ensuring that various registry resource lists are always presented in a predictable, alphabetically sorted order. It achieves this by introducing a new, generic sorting utility package and integrating it into the TenantNamespace, TenantSecret, TenantModule, and Application list operations. Additionally, the PR improves code quality by resolving several identified linter errors, making the codebase cleaner and more maintainable.

Highlights

  • Alphabetical Sorting for Registry Resources: Implemented deterministic alphabetical sorting for TenantNamespace (by name), TenantSecret (by namespace/name), TenantModule (by namespace/name), and Application (by namespace/name) lists to improve consistency and user experience.
  • New Generic Sorting Package: Introduced a new package, 'pkg/registry/sorting', which provides generic helper functions like 'ByName' and 'ByNamespacedName' to centralize and reuse sorting logic across different resource types.
  • Linter Error Fixes and Code Quality Improvements: Addressed several pre-existing linter issues, including removing unused 'helmReleaseGVR' variables, correcting 'klog.Errorf' calls to use constant format strings or 'klog.Error', and resolving redundant embedded field selectors in 'rest_defaulting.go'.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable abstraction for sorting registry resources, which greatly improves code reuse and maintainability. The introduction of the pkg/registry/sorting package with generic helpers is a solid approach. The accompanying tests for the new sorting logic are also well-written and appreciated. Additionally, fixing pre-existing linter errors improves the overall code quality. My review includes a couple of suggestions to make the new sorting functions more efficient and idiomatic.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
pkg/registry/core/tenantmodule/rest.go (1)

589-605: Minor inconsistency in ResourceVersion access.

For TenantModuleList, direct field access is used (obj.ResourceVersion), while for TenantModule, the getter method is used (obj.GetResourceVersion()). Both work correctly due to embedded ObjectMeta, but for consistency, consider using the same access pattern.

🔎 Suggested consistency fix
 	case *corev1alpha1.TenantModuleList:
 		table = r.buildTableFromTenantModules(obj.Items)
-		table.ResourceVersion = obj.ResourceVersion
+		table.ResourceVersion = obj.GetResourceVersion()
 	case *corev1alpha1.TenantModule:
 		table = r.buildTableFromTenantModule(*obj)
 		table.ResourceVersion = obj.GetResourceVersion()
pkg/registry/apps/application/rest.go (1)

951-967: Minor inconsistency in ResourceVersion access.

Similar to the TenantModule case, ApplicationList uses direct field access (obj.ResourceVersion) while single Application uses the getter (obj.GetResourceVersion()). Both work correctly, but consistency would improve readability.

🔎 Suggested consistency fix
 	case *appsv1alpha1.ApplicationList:
 		table = r.buildTableFromApplications(obj.Items)
-		table.ResourceVersion = obj.ResourceVersion
+		table.ResourceVersion = obj.GetResourceVersion()
 	case *appsv1alpha1.Application:
 		table = r.buildTableFromApplication(*obj)
 		table.ResourceVersion = obj.GetResourceVersion()
pkg/registry/sorting/sort.go (2)

29-38: Consider using cmp.Compare for cleaner comparison logic.

Go 1.21 introduced cmp.Compare which directly returns -1, 0, or 1 for ordered types, simplifying the comparison logic.

🔎 Proposed refactor
 import (
+	"cmp"
 	"slices"
 
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 func ByName[T any, PT interface {
 	*T
 	NameGetter
 }](items []T) {
 	slices.SortFunc(items, func(a, b T) int {
 		pa, pb := PT(&a), PT(&b)
-		switch {
-		case pa.GetName() < pb.GetName():
-			return -1
-		case pa.GetName() > pb.GetName():
-			return 1
-		}
-		return 0
+		return cmp.Compare(pa.GetName(), pb.GetName())
 	})
 }

47-58: Same simplification applies here with cmp.Compare.

The comparison logic can be simplified using cmp.Compare for consistency with the suggested refactor for ByName.

🔎 Proposed refactor
 func ByNamespacedName[T any, PT interface {
 	*T
 	NamespaceGetter
 }](items []T) {
 	slices.SortFunc(items, func(a, b T) int {
 		pa, pb := PT(&a), PT(&b)
 		aKey := pa.GetNamespace() + "/" + pa.GetName()
 		bKey := pb.GetNamespace() + "/" + pb.GetName()
-		switch {
-		case aKey < bKey:
-			return -1
-		case aKey > bKey:
-			return 1
-		}
-		return 0
+		return cmp.Compare(aKey, bKey)
 	})
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7931fd and 19e06f7.

📒 Files selected for processing (10)
  • pkg/registry/apps/application/rest.go
  • pkg/registry/apps/application/rest_defaulting.go
  • pkg/registry/apps/application/rest_sorting_test.go
  • pkg/registry/core/tenantmodule/rest.go
  • pkg/registry/core/tenantmodule/rest_test.go
  • pkg/registry/core/tenantnamespace/rest.go
  • pkg/registry/core/tenantnamespace/rest_test.go
  • pkg/registry/core/tenantsecret/rest.go
  • pkg/registry/sorting/sort.go
  • pkg/registry/sorting/sort_test.go
🧰 Additional context used
📓 Path-based instructions (2)
pkg/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Follow controller-runtime patterns and kubebuilder style for Go code in pkg directory

Files:

  • pkg/registry/core/tenantmodule/rest.go
  • pkg/registry/sorting/sort_test.go
  • pkg/registry/apps/application/rest_sorting_test.go
  • pkg/registry/core/tenantnamespace/rest.go
  • pkg/registry/sorting/sort.go
  • pkg/registry/core/tenantmodule/rest_test.go
  • pkg/registry/core/tenantnamespace/rest_test.go
  • pkg/registry/core/tenantsecret/rest.go
  • pkg/registry/apps/application/rest_defaulting.go
  • pkg/registry/apps/application/rest.go
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Do NOT manually edit vendor/ directory or auto-generated files (zz_generated.*.go)

Files:

  • pkg/registry/core/tenantmodule/rest.go
  • pkg/registry/sorting/sort_test.go
  • pkg/registry/apps/application/rest_sorting_test.go
  • pkg/registry/core/tenantnamespace/rest.go
  • pkg/registry/sorting/sort.go
  • pkg/registry/core/tenantmodule/rest_test.go
  • pkg/registry/core/tenantnamespace/rest_test.go
  • pkg/registry/core/tenantsecret/rest.go
  • pkg/registry/apps/application/rest_defaulting.go
  • pkg/registry/apps/application/rest.go
🧠 Learnings (1)
📚 Learning: 2025-12-25T09:45:26.524Z
Learnt from: CR
Repo: cozystack/cozystack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-25T09:45:26.524Z
Learning: Applies to pkg/**/*.go : Follow controller-runtime patterns and kubebuilder style for Go code in pkg directory

Applied to files:

  • pkg/registry/core/tenantmodule/rest.go
  • pkg/registry/core/tenantsecret/rest.go
🧬 Code graph analysis (5)
pkg/registry/core/tenantmodule/rest.go (1)
pkg/registry/sorting/sort.go (1)
  • ByNamespacedName (43-59)
pkg/registry/apps/application/rest_sorting_test.go (1)
pkg/registry/sorting/sort.go (1)
  • ByNamespacedName (43-59)
pkg/registry/core/tenantnamespace/rest.go (1)
pkg/registry/sorting/sort.go (1)
  • ByName (25-39)
pkg/registry/core/tenantmodule/rest_test.go (1)
pkg/registry/sorting/sort.go (1)
  • ByNamespacedName (43-59)
pkg/registry/apps/application/rest.go (2)
pkg/registry/sorting/sort.go (1)
  • ByNamespacedName (43-59)
pkg/apis/apps/v1alpha1/types.go (1)
  • Application (66-74)
🔇 Additional comments (21)
pkg/registry/core/tenantnamespace/rest_test.go (1)

12-39: LGTM! Well-structured test for alphabetical sorting.

The test correctly validates that makeList sorts TenantNamespace items alphabetically by name. The test setup with out-of-order input and explicit expected order verification is appropriate.

pkg/registry/core/tenantsecret/rest.go (3)

30-31: LGTM! Import for sorting utility.

The import of the sorting package aligns with the PR's goal of consolidating sorting logic.


278-282: LGTM! Sorting applied correctly after list construction.

The sorting is appropriately applied after all items are collected, ensuring deterministic ordering by namespace/name.


469-481: LGTM! ResourceVersion assignment simplified.

The change from tbl.ListMeta.ResourceVersion to tbl.ResourceVersion is correct. The metav1.Table struct embeds ListMeta, so ResourceVersion is directly accessible and this is the idiomatic way to set it.

pkg/registry/apps/application/rest_sorting_test.go (1)

14-35: LGTM! Comprehensive test for namespace/name sorting.

The test correctly validates the ByNamespacedName sorting behavior for Application items, covering the multi-key sorting scenario (namespace first, then name within namespace).

pkg/registry/sorting/sort_test.go (2)

11-17: LGTM! Test types properly satisfy sorting interfaces.

The test types embed metav1.ObjectMeta which provides GetName() and GetNamespace() methods, correctly satisfying the NameGetter and NamespaceGetter interfaces required by the sorting functions.


19-60: LGTM! Comprehensive unit tests for sorting utilities.

Both TestByName and TestByNamespacedName provide good coverage with clear input/expected-output patterns. The tests validate the core sorting behavior that the rest of the PR depends on.

pkg/registry/core/tenantmodule/rest_test.go (1)

14-35: LGTM! Consistent test pattern for TenantModule sorting.

The test follows the established pattern for validating ByNamespacedName sorting, ensuring consistency across resource types.

pkg/registry/core/tenantmodule/rest.go (3)

43-45: LGTM! Import for sorting utility.

The import is correctly placed and aligns with the PR's consolidation of sorting logic.


283-288: LGTM! Sorting applied after list construction.

The sorting is correctly applied after all items are collected and before returning the list, ensuring deterministic ordering.


509-517: LGTM! Simplified error logging.

The change from klog.Errorf("...: %v", err) to klog.Error(err) is appropriate since the error message is already self-contained and logging the error directly provides the necessary context.

pkg/registry/core/tenantnamespace/rest.go (3)

29-30: LGTM! Import for sorting utility.

The import is correctly placed for the sorting package.


205-217: LGTM! ResourceVersion assignment simplified.

The direct tbl.ResourceVersion assignment is correct and more idiomatic than going through ListMeta.


258-261: LGTM! Correct use of ByName for cluster-scoped resource.

Since TenantNamespace is cluster-scoped (per NamespaceScoped() bool { return false } on line 75), using ByName rather than ByNamespacedName is the correct choice.

pkg/registry/apps/application/rest.go (5)

45-52: LGTM! Import for sorting utility.

The import is correctly placed alongside other internal package imports.


389-394: LGTM! Sorting applied after list construction.

The sorting is correctly applied after all items are collected, ensuring deterministic alphabetical ordering by namespace/name for API responses.


439-443: LGTM! Simplified error handling.

The consolidated error logging and return statement is cleaner and avoids redundant message variable construction.


751-759: LGTM! Simplified error logging.

Using klog.Error(err) directly is appropriate when the error message is self-explanatory.


906-913: LGTM! Direct field access for ResourceVersion and UID.

The change from app.ObjectMeta.ResourceVersion to app.ResourceVersion (and similarly for UID) is functionally equivalent due to Go's embedded struct promotion and is the more idiomatic access pattern.

pkg/registry/sorting/sort.go (1)

61-74: LGTM!

The ObjectMetaWrapper correctly implements NamespaceGetter by wrapping metav1.ObjectMeta. The methods are simple delegations to the embedded struct's fields.

pkg/registry/apps/application/rest_defaulting.go (1)

75-75: No issues found. The field access changes (from s.Generic.Type to s.Type and from s.Generic.Default.Object to s.Default.Object) are compatible with k8s.io/apiextensions-apiserver v0.34.1 and have been successfully applied. The commit message confirms this was an intentional refactoring to simplify embedded field selectors, and the test suite validates that the defaulting logic works correctly.

- Simplify ByName with strings.Compare
- Avoid string allocation in ByNamespacedName by comparing fields separately

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
pkg/registry/sorting/sort.go (1)

51-64: Consider removing redundant method definitions.

metav1.ObjectMeta already implements GetName() and GetNamespace() methods (via the metav1.Object interface). Since ObjectMeta is embedded, these methods are automatically promoted to ObjectMetaWrapper, making the explicit definitions on lines 57-64 unnecessary.

🔎 Proposed simplification
 // ObjectMetaWrapper wraps metav1.ObjectMeta to implement NamespaceGetter.
 type ObjectMetaWrapper struct {
 	metav1.ObjectMeta
 }
-
-// GetName returns the name.
-func (o *ObjectMetaWrapper) GetName() string {
-	return o.Name
-}
-
-// GetNamespace returns the namespace.
-func (o *ObjectMetaWrapper) GetNamespace() string {
-	return o.Namespace
-}

The embedded ObjectMeta already provides these methods, so the wrapper will satisfy NamespaceGetter without explicit definitions.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19e06f7 and e9cad45.

📒 Files selected for processing (1)
  • pkg/registry/sorting/sort.go
🧰 Additional context used
📓 Path-based instructions (2)
pkg/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Follow controller-runtime patterns and kubebuilder style for Go code in pkg directory

Files:

  • pkg/registry/sorting/sort.go
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Do NOT manually edit vendor/ directory or auto-generated files (zz_generated.*.go)

Files:

  • pkg/registry/sorting/sort.go
🔇 Additional comments (3)
pkg/registry/sorting/sort.go (3)

13-22: Clean interface design with proper composition.

The interface hierarchy is well-designed: NamespaceGetter embedding NameGetter allows the ByNamespacedName function to work with any type that provides both methods while keeping the interfaces minimal.


26-34: LGTM!

The generic constraint and use of strings.Compare is idiomatic. Past review feedback has been addressed.


38-49: LGTM!

The implementation efficiently compares namespace first with early return, avoiding string concatenation allocations. Past review feedback has been addressed.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
lllamnyp
lllamnyp previously approved these changes Dec 26, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 26, 2025
@lllamnyp lllamnyp dismissed their stale review December 26, 2025 10:41

Canceled my own review

@kvaps kvaps added the backport Should change be backported on previus release label Dec 29, 2025
@lllamnyp lllamnyp merged commit a03042e into cozystack:main Dec 29, 2025
26 checks passed
@github-actions
Copy link

Backport failed for release-0.39, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-0.39
git worktree add -d .worktree/backport-1764-to-release-0.39 origin/release-0.39
cd .worktree/backport-1764-to-release-0.39
git switch --create backport-1764-to-release-0.39
git cherry-pick -x 0b16f83eae90b09667db2d9b5621d72609558aec 19e06f7beb59df87ac6e2b8281ef3cef6d072b2d e9cad4507be9e1118dc94b7ff493e036817c10d3 da56c88aa76064ea29177c4bf44db3f1df27e9e4

kvaps pushed a commit that referenced this pull request Jan 8, 2026
## What this PR does

Adds deterministic alphabetical sorting to all registry resource lists:
- TenantNamespace (sorted by name)
- TenantSecret (sorted by namespace/name)
- TenantModule (sorted by namespace/name)
- Application (sorted by namespace/name)

Introduces a new `pkg/registry/sorting` package with generic helper
functions
to avoid code duplication.

Also fixes pre-existing linter errors:
- Unused `helmReleaseGVR` variables
- Non-constant format strings in `klog.Errorf` calls
- Redundant embedded field selectors

### Release note

```release-note
[platform] Registry resource lists are now returned in alphabetical order
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a reusable alphabetical sorting utility and applied consistent
sorting across list endpoints.

* **Bug Fixes**
* Ensured ResourceVersion/UID are sourced correctly for accurate
list/table responses.
* Simplified and improved error logging and table ResourceVersion
handling.
  * Made schema defaulting behavior more consistent.

* **Tests**
* Added unit tests validating alphabetical sorting for multiple resource
types.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
kvaps pushed a commit that referenced this pull request Jan 8, 2026
## What this PR does

Adds deterministic alphabetical sorting to all registry resource lists:
- TenantNamespace (sorted by name)
- TenantSecret (sorted by namespace/name)
- TenantModule (sorted by namespace/name)
- Application (sorted by namespace/name)

Introduces a new `pkg/registry/sorting` package with generic helper
functions
to avoid code duplication.

Also fixes pre-existing linter errors:
- Unused `helmReleaseGVR` variables
- Non-constant format strings in `klog.Errorf` calls
- Redundant embedded field selectors

### Release note

```release-note
[platform] Registry resource lists are now returned in alphabetical order
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a reusable alphabetical sorting utility and applied consistent
sorting across list endpoints.

* **Bug Fixes**
* Ensured ResourceVersion/UID are sourced correctly for accurate
list/table responses.
* Simplified and improved error logging and table ResourceVersion
handling.
  * Made schema defaulting behavior more consistent.

* **Tests**
* Added unit tests validating alphabetical sorting for multiple resource
types.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
kvaps pushed a commit that referenced this pull request Jan 9, 2026
## What this PR does

Adds deterministic alphabetical sorting to all registry resource lists:
- TenantNamespace (sorted by name)
- TenantSecret (sorted by namespace/name)
- TenantModule (sorted by namespace/name)
- Application (sorted by namespace/name)

Introduces a new `pkg/registry/sorting` package with generic helper
functions
to avoid code duplication.

Also fixes pre-existing linter errors:
- Unused `helmReleaseGVR` variables
- Non-constant format strings in `klog.Errorf` calls
- Redundant embedded field selectors

### Release note

```release-note
[platform] Registry resource lists are now returned in alphabetical order
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a reusable alphabetical sorting utility and applied consistent
sorting across list endpoints.

* **Bug Fixes**
* Ensured ResourceVersion/UID are sourced correctly for accurate
list/table responses.
* Simplified and improved error logging and table ResourceVersion
handling.
  * Made schema defaulting behavior more consistent.

* **Tests**
* Added unit tests validating alphabetical sorting for multiple resource
types.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Should change be backported on previus release enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants