-
Notifications
You must be signed in to change notification settings - Fork 119
[cozystack-api] fix type for ApplicationList #1290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant REST
participant Storage
Client->>REST: List()
REST->>Storage: Query HelmReleases
Storage-->>REST: Return HelmRelease list
REST->>REST: Convert HelmReleases to unstructured Applications
REST->>REST: Build unstructured ApplicationList with metadata
REST-->>Client: Return unstructured ApplicationList
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @kvaps, 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 addresses a type issue in the cozystack-api
by modifying the List
method for Application
resources. The core change involves transitioning the return type from a strongly-typed Go struct to a more flexible unstructured.Unstructured
object, which is a standard practice for representing dynamic Kubernetes API resources. This ensures proper serialization and compatibility when serving ApplicationList
objects.
Highlights
- API Response Type Change: The
List
method within thepkg/registry/apps/application/rest.go
file has been updated to return an*unstructured.Unstructured
object instead of a specific*appsv1alpha1.ApplicationList
Go struct. This change aligns the API's list response with a more generic and flexible Kubernetes object representation. - Dynamic List Construction: The
ApplicationList
is now constructed dynamically as amap[string]interface{}
. This map explicitly defines theapiVersion
,kind
(derived fromr.kindName + "List"
),metadata
(includingResourceVersion
), and theitems
array, before being wrapped into anunstructured.Unstructured
object for return.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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 or fill out our survey to provide feedback.
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
-
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. ↩
There was a problem hiding this 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/apps/application/rest.go (1)
377-385
: Consider using GVK from REST struct for consistency.The unstructured list construction looks correct, but consider using the REST struct's GVK instead of hardcoding the apiVersion for better maintainability.
appList := map[string]interface{}{ - "apiVersion": "apps.cozystack.io/v1alpha1", + "apiVersion": r.gvk.GroupVersion().String(), "kind": r.kindName + "List", "metadata": metav1.ListMeta{ ResourceVersion: hrList.GetResourceVersion(), }, "items": items, }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/registry/apps/application/rest.go
(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: lllamnyp
PR: cozystack/cozystack#1130
File: hack/e2e-apps/kubernetes.bats:101-101
Timestamp: 2025-07-11T06:11:25.438Z
Learning: In cozystack, the plural form for the Kubernetes custom resource is `kuberneteses.apps.cozystack.io`, not `kubernetes.apps.cozystack.io`. This is defined in the API schema even though it's not grammatically perfect.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
🔇 Additional comments (3)
pkg/registry/apps/application/rest.go (3)
325-326
: LGTM: Clean refactor to unstructured list construction.The change from typed
ApplicationList
to an unstructured slice approach is well-implemented. The logic for collecting items remains intact.
380-380
: Verify kind construction follows Kubernetes conventions.The
r.kindName + "List"
construction for the list kind appears correct and follows standard Kubernetes API conventions for list resources.
387-388
: LGTM: Consistent logging and return type updates.The logging update to use
len(items)
and return type change tounstructured.Unstructured
are consistent with the refactored implementation.
There was a problem hiding this 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 fixes the return type of the List
function for Application
resources, making it consistent with other REST methods by returning an unstructured.Unstructured
object. The review focuses on ensuring the list items are correctly converted to unstructured objects and that the ConvertToTable
function is updated to handle unstructured lists, which is necessary for kubectl get
to work correctly.
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Successfully created backport PR for |
Signed-off-by: Andrei Kvapil kvapss@gmail.com
What this PR does
was showing:
now it shows:
Release note
Summary by CodeRabbit