Codebase Review Round 2 — Finding #12
Severity: High
Location: kubernetes.go (1,631 lines)
Problem
The Kubernetes client code implements 5 CRUD methods (Create, Get, Update, Delete, List) for each of 10 CRD types, following an identical pattern each time. This results in ~1,600 lines of nearly identical boilerplate code.
Impact
- Any change to error handling, logging, or retry logic must be replicated across 50 methods
- High risk of inconsistency (some methods may have fixes that others missed)
- New CRD types require copying and modifying 5 methods
Fix
- Extract a generic
crudResource[T] helper using Go generics
- Each CRD type registers once with the generic helper
- Reduces ~1,600 lines to ~200 lines + type registrations
- Example pattern:
func crudResource[T runtime.Object](ctx context.Context, client dynamic.Interface, gvr schema.GroupVersionResource, ...) error
Codebase Review Round 2 — Finding #12
Severity: High
Location:
kubernetes.go(1,631 lines)Problem
The Kubernetes client code implements 5 CRUD methods (Create, Get, Update, Delete, List) for each of 10 CRD types, following an identical pattern each time. This results in ~1,600 lines of nearly identical boilerplate code.
Impact
Fix
crudResource[T]helper using Go generics