feat: implement podtemplate details endpoint for workspace overlay#1119
feat: implement podtemplate details endpoint for workspace overlay#1119Snehadas2005 wants to merge 1 commit into
podtemplate details endpoint for workspace overlay#1119Conversation
podtemplate details endpoint for workspace overlay
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
af21305 to
4398ca0
Compare
christian-heusel
left a comment
There was a problem hiding this comment.
Thanks a lot for your contribution, I have left you a few review comments below! 🤗
Also did you use AI in any capacity while creating this contribution? I see that your commit does not carry any Assisted-By: <...> / Co-authored-by: <...> tags, so I wanted to make sure that you're aware of the Kubeflow AI Policy. 🤗 🤖
There was a problem hiding this comment.
You'll also need to generate the new relevant swagger files for this endpoint:
$ make -C workspaces/backend/ swag
| type WorkspaceDetailVolume struct { | ||
| PVCName string `json:"pvcName"` | ||
| MountPath string `json:"mountPath"` | ||
| ReadOnly bool `json:"readOnly"` | ||
| } | ||
|
|
||
| type WorkspaceDetailSecret struct { | ||
| SecretName string `json:"secretName"` | ||
| MountPath string `json:"mountPath"` | ||
| DefaultMode int32 `json:"defaultMode,omitempty"` | ||
| } |
There was a problem hiding this comment.
We already have models for those datatypes that we could potentially reuse for these implementations instead of defining new types inline.
There was a problem hiding this comment.
Please do not introduce a new testing framework and reuse the pre-existing infrastructure around gomega
| readOnly := false | ||
| if v.ReadOnly != nil { | ||
| readOnly = *v.ReadOnly | ||
| } |
There was a problem hiding this comment.
We usually use ptr.Deref(volume.ReadOnly, false) for something like this:
| readOnly := false | |
| if v.ReadOnly != nil { | |
| readOnly = *v.ReadOnly | |
| } | |
| readOnly := ptr.Deref(volume.ReadOnly, false) |
| WorkspacePodTemplatePath = WorkspacesByNamePath + "/podtemplate" | ||
| WorkspacePodTemplateDetailsPath = WorkspacePodTemplatePath + "/details" |
There was a problem hiding this comment.
This is a unused exported variable, you can just fold those two declarations into one.
| type WorkspaceDetailVolumes struct { | ||
| Home *WorkspaceDetailVolume `json:"home"` | ||
| Data []WorkspaceDetailVolume `json:"data"` | ||
| Secrets []WorkspaceDetailSecret `json:"secrets"` |
There was a problem hiding this comment.
This is not consistent with the Secrets API contract, the other one uses omitempty.
PodSecretInfointypes.gohasomitemptyon the slice.WorkspaceDetailSecret.DataandWorkspaceDetailSecret.Secrets(inWorkspaceDetailVolumes) omit this tag, which means the JSON response always includes"data": []and"secrets": []even when empty, unlike the rest of the API.
| // secret volumes — DefaultMode is int32 (not *int32), use directly | ||
| secretVolumes := make([]WorkspaceDetailSecret, len(ws.Spec.PodTemplate.Volumes.Secrets)) | ||
| for i, s := range ws.Spec.PodTemplate.Volumes.Secrets { | ||
| secretVolumes[i] = WorkspaceDetailSecret{ | ||
| SecretName: s.SecretName, | ||
| MountPath: s.MountPath, | ||
| DefaultMode: s.DefaultMode, // int32 directly, no dereference needed | ||
| } | ||
| } |
There was a problem hiding this comment.
The comments around int32 don't make sense to me, why did you add them? 😅
1ee8a36 to
78eb914
Compare
3d38c1b to
eee1f2a
Compare
Signed-off-by: Sneha Das <154408198+Snehadas2005@users.noreply.github.com>
eee1f2a to
2fc9aac
Compare
|
Hi @christian-heusel! Thank you for your feedback. I have addressed your comments and refactored the branch into a clean commit. Key updates include:
Ready for your review! 🤗 |
Description
This PR implements a dedicated details endpoint (
GET /api/v1/workspaces/{namespace}/{name}/podtemplate/details) for the workspace details overlay. This decouples the frontend overlay layout from the generic workspace list endpoint, allowing richer data to be fetched efficiently on-demand.Key Changes:
api/constants/paths.go.types_details.goandfuncs_details.go(including conditionalnullmapping for paused workspaces).WorkspaceRepositorywith aGetWorkspaceDetailsmethod fetching both the core Workspace CR and its associatedWorkspaceKind.GetWorkspaceDetailsHandlerwith strict RBAC authentication (requireAuth) and namespace/name path verification.Related Issue
Closes #1029
Verification Results
go fmt ./...andgo vet ./...successfully (no syntax/static analysis errors).AI Policy Compliance
Assisted-by: Gemini gemini@google.com
Co-authored-by: Claude claude@anthropic.com
Note: AI assistance was utilized specifically to debug Windows-vs-Linux environment line-ending constraints in the auto-generated Swagger schema pipeline, as well as to accelerate the test-suite refactoring from traditional tables to the native Ginkgo/Gomega syntax structure.