feat(k8s): M11 StatefulSet/DaemonSet 详情页 — WorkloadViewPage 重写 + YAML 路由冲突修复

后端:
- routes.go: 为 statefulsets/daemonsets 注册专门 YAML 子路由(Gin radix tree 冲突)
- kubernetes.go: GetResourceYAMLNS/UpdateResourceYAMLNS 添加 URL path fallback

前端:
- WorkloadViewPage.tsx 重写: 修复 kind 提取 bug(useLocation) + 更新策略/选择器/PVC模板/InitContainers
- NamespaceResourcePage.tsx: handleDetail 添加 STS/DS 点击导航

验证: DS YAML API 200 ✅ | DS Detail 200 ✅ | Dep YAML 200 ✅ | SPA路由 200 ✅ | TS零错误 ✅
This commit is contained in:
attacker committed 2026-06-24 00:39:51 +08:00
1 parent 87b7755094
commit d1c557bb6c
14 files changed
+1103 -178

No files matched your search

+48
View File
@@ -339,3 +339,51 @@ cd frontend && npm run build 2>&1 | tail -3
- [x] Service Tab selector 双路径兼容(spec.selector.matchLabels || selector)
- [x] TypeScript 零编译错误 + Vite 构建成功
- [x] 前端 bundle 已更新
---
## M11: StatefulSet/DaemonSet 详情页
### 验证用例
```bash
# U1: 登录获取 Token
TOKEN=$(curl -s http://127.0.0.1:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}' | jq -r '.data.token')
# U2: DaemonSet YAML API(路由冲突修复验证)
curl -s "http://127.0.0.1:8080/api/v1/kubernetes/prod-cluster/namespace/kube-system/daemonsets/calico-node/yaml" \
-H "Authorization: Bearer *** | head -3
# 期望: apiVersion: apps/v1 / kind: DaemonSet / metadata:
# U3: DaemonSet Detail API
curl -s "http://127.0.0.1:8080/api/v1/kubernetes/prod-cluster/namespace/kube-system/daemonsets/calico-node" \
-H "Authorization: Bearer *** | jq '.data | {name: .metadata.name, desired: .status.desiredNumberScheduled, ready: .status.numberReady}'
# 期望: name="calico-node", desired=2, ready=2
# U4: Deployment YAML 仍正常(generic 路由未受影响)
curl -s "http://127.0.0.1:8080/api/v1/kubernetes/prod-cluster/namespace/devops/deployments/redis/yaml" \
-H "Authorization: Bearer *** | head -1
# 期望: apiVersion: apps/v1
# U5: SPA fallback — workload 路由 200
curl -s -o /dev/null -w "%{http_code}" \
"http://127.0.0.1/kubernetes/prod-cluster/namespace/kube-system/workload/view/DaemonSet/calico-node"
# 期望: 200
# U6: TypeScript + Vite 构建
cd frontend && npx tsc --noEmit && npm run build 2>&1 | tail -3
# 期望: 零错误 + built in Ns
```
### 通过标准
- [x] U2: DS YAML API 返回 200 + apiVersion + kind=DaemonSet(Gin radix tree 路由冲突已修复)
- [x] U3: DS Detail API 返回 name/desired/current/ready/containers
- [x] U4: Deployment YAML API 仍正常(generic `/:resource/:name/yaml` 路由未受影响)
- [x] U5: SPA 路由 view/yaml 两种模式均返回 200
- [x] U6: TypeScript 零编译错误 + Vite 构建成功
- [x] NamespaceResourcePage 点击 STS/DS 行可跳转详情页
- [x] WorkloadViewPage 支持 view/yaml 双模式切换
- [x] WorkloadViewPage kind 从 useLocation 正确提取(DaemonSet 不被误判为 StatefulSet)
- [x] 更新策略/选择器/PVC模板/InitContainers 全部展示