You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4,66 +4,192 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## Project Overview
6
6
7
-
The Operation Cache Controller is a Kubernetes operator built with kubebuilder framework that manages operations and caches the outcome of those operations. It provisions resources, pre-provisions resources for future use (caching), and manages the lifecycle of resources and cache.
7
+
The Operation Cache Controller is a Kubernetes operator built with kubebuilder v4 framework that manages operations and caches the outcome of those operations. It provisions resources, pre-provisions resources for future use (caching), and manages the lifecycle of resources and cache.
8
8
9
9
## Architecture
10
10
11
-
The controller manages four main Custom Resource Definitions (CRDs):
11
+
The controller manages four main Custom Resource Definitions (CRDs) in the `controller.azure.github.com` API group:
12
12
13
-
1.**Requirement** - User-defined specifications for required applications and their configurations
13
+
1.**Requirement** - User-defined specifications for required applications with optional caching
14
14
2.**Operation** - Represents the deployment operation based on requirements
15
15
3.**AppDeployment** - Manages provision and teardown jobs for actual resource deployment
16
16
4.**Cache** - Stores pre-provisioned resources with cache duration and auto-count features
17
17
18
+
### Controller Architecture Pattern
19
+
20
+
The project follows a **handler-based reconciliation pattern** with clear separation of concerns:
-`internal/handler/` - Business logic handlers for each CRD type with mockable interfaces
89
+
-`internal/utils/controller/` - Controller helper utilities for CRDs
90
+
-`internal/utils/reconciler/` - Common reconciliation patterns and operation sequencing
91
+
-`internal/utils/rand/` - Random string generation utilities
92
+
-`internal/utils/ptr/` - Pointer helper utilities
93
+
-`internal/log/` - Logging constants and structured logging keys
56
94
-`config/` - Kubernetes manifests and kustomization files
57
-
-`doc/arch/` - Architecture documentation with detailed diagrams
58
-
59
-
## Testing Requirements
60
-
61
-
- Unit tests must be written for new functionality
62
-
- Integration tests validate controller behavior with Kubernetes API
63
-
- E2E tests require a running Kind cluster
64
-
- All tests must pass before submitting changes
65
-
- Coverage reports are generated in `cover.out`
95
+
-`test/e2e/` - End-to-end tests using sigs.k8s.io/e2e-framework
96
+
-`test/integration/` - Integration tests using envtest
97
+
-`test/utils/` - Common test utilities and resource builders
98
+
-`doc/arch/` - Architecture documentation with detailed diagrams (6 files)
99
+
100
+
## Development Environment Requirements
101
+
102
+
-**Go**: v1.24.0+ (as specified in go.mod and Dockerfile)
103
+
-**Docker**: For building container images
104
+
-**Kind**: For running E2E tests locally
105
+
-**Tools**: controller-gen v0.17.2, kustomize v5.6.0, golangci-lint v1.63.4 (auto-installed via Makefile)
106
+
107
+
## Testing Strategy
108
+
109
+
### Test Structure
110
+
-**Unit Tests**: 22 test files using Ginkgo v2 + Gomega framework
111
+
-**Integration Tests**: Use envtest for lightweight K8s API server testing
112
+
-**E2E Tests**: Require Kind cluster, test full deployment lifecycle in `operation-cache-controller-system` namespace
113
+
-**Mock Generation**: Uses go.uber.org/mock with `//go:generate mockgen` directives
114
+
115
+
### Mock Interfaces
116
+
All handler interfaces are mocked for testing:
117
+
-`internal/handler/mocks/mock_requirement.go`
118
+
-`internal/handler/mocks/mock_operation.go`
119
+
-`internal/handler/mocks/mock_cache.go`
120
+
-`internal/handler/mocks/mock_appdeployment.go`
121
+
122
+
### Testing Patterns
123
+
- Controllers use envtest suite in `internal/controller/suite_test.go`
124
+
- Handlers are unit tested with mocked Kubernetes clients
125
+
- Coverage reports generated in `cover.out`
66
126
67
127
## Linting Configuration
68
128
69
-
The project uses golangci-lint with custom configuration in `.golangci.yml`. Key enabled linters include errcheck, gofmt, goimports, govet, staticcheck, and others. Some linters are disabled for specific paths (api/ and internal/ directories have relaxed line length requirements).
129
+
The project uses golangci-lint with custom configuration in `.golangci.yml`. Key enabled linters include:
130
+
-**Error handling**: errcheck, staticcheck, govet
131
+
-**Code quality**: gocyclo, dupl, goconst, revive
132
+
-**Style**: gofmt, goimports, misspell
133
+
-**Performance**: prealloc, ineffassign
134
+
-**Testing**: ginkgolinter
135
+
-**Go 1.22+**: copyloopvar
136
+
137
+
Some linters are disabled for specific paths (api/ and internal/ have relaxed line length requirements).
138
+
139
+
## Important Constants and Patterns
140
+
141
+
### Labels and Annotations
142
+
-`operation-cache-controller.azure.github.com/cache-key` - Cache key label for grouping
0 commit comments