Skip to content

Fix undefined types error in k8s client#69

Merged
JoshuaAFerguson merged 5 commits into
mainfrom
claude/fix-k8s-types-error-01B5tuSGZ9WyhPpaX27CsHsp
Nov 17, 2025
Merged

Fix undefined types error in k8s client#69
JoshuaAFerguson merged 5 commits into
mainfrom
claude/fix-k8s-types-error-01B5tuSGZ9WyhPpaX27CsHsp

Conversation

@JoshuaAFerguson

Copy link
Copy Markdown
Member

No description provided.

Add missing 'k8s.io/apimachinery/pkg/types' import required for
types.StrategicMergePatchType in PatchNode function.

Fixes compilation error: undefined: types
Fixed multiple compilation errors:

nodes.go:
- Added missing 'resource' import from k8s.io/apimachinery/pkg/api/resource
- Removed unused 'metav1' and 'types' imports
- Fixed newQuantity() to return resource.Quantity instead of corev1.Quantity
- Fixed resource.Quantity.Add() calls by getting value, modifying, then reassigning to map

stubs.go:
- Fixed iteration over NodeList to use nodes.Items instead of nodes directly
- Fixed len() calls on PodList to use pods.Items instead of pods
- Fixed len() calls on NodeList to use nodes.Items instead of nodes

Resolves compilation errors with undefined types and invalid pointer method calls.
Both /admin/users and /admin/groups pages were missing the Layout component
wrapper that provides the admin sidebar navigation. This caused the sidebar
to disappear when navigating to these pages.

Changes:
- Added Layout import to Users.tsx and Groups.tsx
- Wrapped Container content in Layout component
- Maintains existing WebSocketErrorBoundary wrapper structure

Fixes sidebar navigation visibility on admin Users and Groups pages.
Added stub implementations for compliance endpoints that return empty data
when the streamspace-compliance plugin is not installed. This prevents 404
errors on the Compliance admin page while clearly indicating that the full
functionality requires the plugin.

Changes:
- Added compliance stub handlers in api/internal/api/stubs.go:
  - ListComplianceFrameworks (returns empty frameworks array)
  - CreateComplianceFramework (returns 501 with plugin installation message)
  - ListCompliancePolicies (returns empty policies array)
  - CreateCompliancePolicy (returns 501 with plugin installation message)
  - ListViolations (returns empty violations array)
  - RecordViolation (returns 501 with plugin installation message)
  - ResolveViolation (returns 501 with plugin installation message)
  - GetComplianceDashboard (returns zero metrics)

- Uncommented compliance routes in api/cmd/main.go:
  - Added /compliance/dashboard endpoint
  - Enabled all compliance CRUD endpoints under /compliance/* routes
  - Added documentation noting these are stubs until plugin is installed

Benefits:
- No more 404 errors in browser console on Compliance page
- Clear indication when compliance features require plugin installation
- Graceful degradation when plugin is not available
- Plugin can override stubs when installed

Resolves compliance page 404 errors for frameworks, policies, violations, and dashboard.
Fixed TypeError on Nodes admin page where totalCapacity was undefined.
The issue was that corev1.ResourceList was being directly serialized to
JSON which didn't match the expected frontend interface.

Changes:
- Created ClusterStatsResources struct with proper JSON-friendly format:
  - cpu: string (e.g., "4.0" for 4 cores)
  - memory: string (e.g., "8.0Gi")
  - pods: int (e.g., 110)

- Updated ClusterStats struct to use ClusterStatsResources pointers
  instead of corev1.ResourceList for totalCapacity and totalAllocatable

- Rewrote calculateClusterStats to:
  - Aggregate resources using temporary Quantity variables
  - Format resources into human-readable strings
  - Return properly structured ClusterStatsResources

- Added helper functions:
  - formatCPU: converts milliCPU to cores string (e.g., "4.0")
  - formatMemory: converts bytes to human-readable format (Ki/Mi/Gi/Ti)

Frontend now receives proper JSON structure:
{
  "totalNodes": 3,
  "readyNodes": 3,
  "notReadyNodes": 0,
  "totalCapacity": {
    "cpu": "12.0",
    "memory": "24.0Gi",
    "pods": 330
  },
  "totalAllocatable": {...}
}

Resolves Nodes page crash: 'can't access property "cpu", j.totalCapacity is undefined'
@JoshuaAFerguson JoshuaAFerguson merged commit bb93f61 into main Nov 17, 2025
9 of 23 checks passed
@JoshuaAFerguson JoshuaAFerguson deleted the claude/fix-k8s-types-error-01B5tuSGZ9WyhPpaX27CsHsp branch November 17, 2025 22:47
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.

2 participants