Skip to content

Commit 903c9bd

Browse files
StringKeclaude
andcommitted
docs: add CRD creation checklist to prevent missing kustomization entries
- Add "添加新 CRD 检查清单" section with step-by-step guide - Include verification script to check for missing CRD entries - Update CRD list to include CloudflareDomain (22 total) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ee8e73f commit 903c9bd

1 file changed

Lines changed: 56 additions & 1 deletion

File tree

‎CLAUDE.md‎

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
- **Group**: `networking.cloudflare-operator.io`
2121
- **版本**: v1alpha1 (deprecated), v1alpha2 (storage version)
2222

23-
### 已实现的 CRD (21个)
23+
### 已实现的 CRD (22个)
2424

2525
| 类别 | CRD | 作用域 | 状态 |
2626
|------|-----|--------|------|
2727
| **凭证** | CloudflareCredentials | Cluster | ✅ 完成 |
28+
| **域名** | CloudflareDomain | Cluster | ✅ 完成 (v0.19.0+) |
2829
| **网络层** | Tunnel | Namespaced | ✅ 完成 |
2930
| | ClusterTunnel | Cluster | ✅ 完成 |
3031
| | VirtualNetwork | Cluster | ✅ 完成 |
@@ -316,6 +317,60 @@ make test-e2e # Kind 集群 E2E 测试
316317

317318
---
318319

320+
## 添加新 CRD 检查清单 ⚠️
321+
322+
**重要**: 添加新 CRD 时必须完成以下所有步骤,否则 Release 构建会遗漏 CRD!
323+
324+
### 必须步骤
325+
326+
1. **创建类型定义**
327+
```bash
328+
# 创建 api/v1alpha2/myresource_types.go
329+
```
330+
331+
2. **生成代码**
332+
```bash
333+
make manifests generate
334+
```
335+
336+
3. **🔴 添加到 kustomization.yaml** (容易遗忘!)
337+
```bash
338+
# 编辑 config/crd/kustomization.yaml,在 resources 中添加:
339+
- bases/networking.cloudflare-operator.io_myresources.yaml
340+
```
341+
342+
4. **创建控制器**
343+
```bash
344+
# 创建 internal/controller/myresource/controller.go
345+
```
346+
347+
5. **注册控制器到 main.go**
348+
```go
349+
if err = (&myresource.Reconciler{...}).SetupWithManager(mgr); err != nil {
350+
// ...
351+
}
352+
```
353+
354+
6. **验证构建输出**
355+
```bash
356+
make build-installer VERSION=x.x.x
357+
grep "myresources" dist/cloudflare-operator.crds.yaml # 必须有输出
358+
```
359+
360+
### 验证脚本
361+
362+
```bash
363+
# 检查所有 CRD 是否都在 kustomization 中
364+
for crd in config/crd/bases/*.yaml; do
365+
name=$(basename "$crd")
366+
if ! grep -q "$name" config/crd/kustomization.yaml; then
367+
echo "⚠️ Missing: $name"
368+
fi
369+
done
370+
```
371+
372+
---
373+
319374
## 核心辅助函数
320375

321376
### status.go

0 commit comments

Comments
 (0)