Thank you for your interest in contributing to the Cloudflare Operator! This document provides guidelines and information for contributors.
感谢你对 Cloudflare Operator 的贡献兴趣!本文档为贡献者提供指南和信息。
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Pull Request Process
- Coding Standards
- Testing
Please be respectful and constructive in all interactions. We welcome contributors from all backgrounds and experience levels.
请在所有互动中保持尊重和建设性。我们欢迎来自各种背景和经验水平的贡献者。
- Go 1.24+
- Docker
- kubectl
- A Kubernetes cluster (minikube, kind, or remote cluster)
- Cloudflare account for testing
# Fork the repository on GitHub, then:
git clone https://github.com/<your-username>/cloudflare-operator.git
cd cloudflare-operator
git remote add upstream https://github.com/StringKe/cloudflare-operator.git# Install Go dependencies
go mod download
# Install development tools
make tools# Build the operator binary
make build
# Build Docker image
make docker-build IMG=cloudflare-operator:dev# Install CRDs to cluster
make install
# Run the operator locally (outside cluster)
make run
# Or run with delve debugger
make debugUse descriptive branch names: 使用描述性的分支名称:
feat/add-gateway-rule-support- New features / 新功能fix/tunnel-connection-retry- Bug fixes / Bug 修复docs/update-crd-reference- Documentation / 文档refactor/cleanup-controller- Refactoring / 重构
- Define types in
api/v1alpha2/<resource>_types.go - Run
make manifests generate - Create controller in
internal/controller/<resource>/controller.go - Add to
cmd/main.go - Add tests
- Add examples to
examples/ - Update documentation
- Update types in
api/v1alpha2/ - Run
make manifests generate - Update controller logic if needed
- Update tests
- Update documentation
# Format code
make fmt
# Run linter
make lint
# Run tests
make test
# Verify CRD generation
make manifests generate
git diff --exit-code-
Title: Use Conventional Commits
feat: add support for GatewayRulefix: resolve tunnel reconnection issuedocs: update installation guide
-
Description: Include:
- What changes were made
- Why the changes are needed
- How to test the changes
- Related issues (e.g.,
Fixes #123)
-
Tests: Add or update tests for your changes
-
Documentation: Update relevant documentation
- CI checks must pass
- At least one maintainer approval required
- Address all review comments
- Squash commits before merge (if requested)
Follow the Effective Go guidelines and project conventions in CLAUDE.md.
遵循 Effective Go 指南和 CLAUDE.md 中的项目约定。
// ✅ Use ConflictRetry for status updates
err := controller.UpdateStatusWithConflictRetry(ctx, r.Client, obj, func() {
obj.Status.State = "active"
})
// ✅ Use meta.SetStatusCondition for conditions
meta.SetStatusCondition(&status.Conditions, metav1.Condition{
Type: "Ready",
Status: metav1.ConditionTrue,
Reason: "Reconciled",
ObservedGeneration: obj.Generation,
})
// ✅ Sanitize error messages in events
r.Recorder.Event(obj, corev1.EventTypeWarning, "Failed",
cf.SanitizeErrorMessage(err))
// ✅ Check NotFound before delete errors
if err := r.cfAPI.Delete(id); err != nil {
if !cf.IsNotFoundError(err) {
return err
}
}- Always check and handle errors
- Use
errors.Join()to aggregate multiple errors - Provide context in error messages
- Never expose sensitive information in errors or events
# Run all tests
make test
# Run specific test
go test ./internal/controller/... -run TestTunnelReconciler
# Run with coverage
make test-coverage# Run E2E tests (requires kind cluster)
make test-e2evar _ = Describe("TunnelController", func() {
Context("When creating a Tunnel", func() {
It("Should create cloudflared deployment", func() {
// Test implementation
})
})
})| Change Type | Files to Update |
|---|---|
| CRD changes | docs/en/api-reference/, docs/zh/api-reference/ |
| New feature | README.md, README_zh.md, docs/*/ |
| Examples | examples/, config/samples/ |
| API changes | CHANGELOG.md |
- Use bilingual format (English and Chinese) where applicable
- Include code examples
- Keep examples up-to-date with actual CRD specs
- Open an issue for bugs or feature requests
- Join discussions in GitHub Discussions
- Tag maintainers in PR comments if needed
Thank you for contributing! / 感谢你的贡献!