@@ -2,51 +2,71 @@ You are an experienced, pragmatic software engineering AI agent. Do not over-eng
22
33## Project Overview
44
5- ` coder-k8s ` is a Go-based Kubernetes operator scaffold for managing a custom resource named ` CoderControlPlane ` (` coder.com/v1alpha1 ` ). The current codebase focuses on baseline wiring: CRD types, scheme registration, controller startup, and a placeholder reconciliation loop .
5+ ` coder-k8s ` is a Go-based Kubernetes control-plane project with two app modes: a controller-runtime operator for ` CoderControlPlane ` (` coder.com/v1alpha1 ` ) and an aggregated API server for ` CoderWorkspace ` / ` CoderTemplate ` ( ` aggregation.coder.com/v1alpha1 ` ) .
66
77** Tech stack**
8- - Go ` 1.25.6 ` (` go.mod ` )
9- - Kubernetes libraries: ` controller-runtime ` , ` client-go ` , ` apimachinery ` , ` code-generator `
8+ - Go ` 1.25.7 ` (` go.mod ` )
9+ - Kubernetes libraries: ` controller-runtime ` , ` client-go ` , ` apimachinery ` , ` apiserver ` , ` code-generator `
1010- Vendored dependencies committed under ` vendor/ `
11- - Tooling: ` make ` , Bash scripts in ` hack/ ` , GitHub Actions, GoReleaser, optional Nix dev shell (` flake.nix ` )
11+ - Tooling: ` make ` , ` golangci-lint ` / ` gofumpt ` , Bash scripts in ` hack/ ` and ` scripts /` , GitHub Actions, GoReleaser, optional Nix dev shell (` flake.nix ` )
1212
1313## Reference
1414
1515### Key files
16- - ` main.go ` : manager bootstrap, scheme registration, health/readiness endpoints, controller wiring.
17- - ` main_test.go ` : baseline tests for scheme registration and defensive nil-check behavior.
18- - ` api/v1alpha1/codercontrolplane_types.go ` : CRD spec/status and list types.
16+ - ` main.go ` : process entrypoint; initializes logging and exits on application failure.
17+ - ` app_dispatch.go ` : ` --app ` mode dispatch between ` controller ` and ` aggregated-apiserver ` .
18+ - ` main_test.go ` : dispatch and defensive nil-check coverage.
19+ - ` internal/app/controllerapp/controllerapp.go ` : controller mode bootstrap (scheme, manager, health/readiness checks).
20+ - ` internal/app/apiserverapp/apiserverapp.go ` : aggregated API server bootstrap and API group installation.
21+ - ` api/v1alpha1/codercontrolplane_types.go ` : CRD spec/status and list types for ` CoderControlPlane ` .
22+ - ` api/aggregation/v1alpha1/types.go ` : aggregated API types for ` CoderWorkspace ` and ` CoderTemplate ` .
1923- ` internal/controller/codercontrolplane_controller.go ` : reconciler and ` SetupWithManager ` logic.
24+ - ` internal/aggregated/storage/workspace.go ` + ` template.go ` : hardcoded in-memory aggregated API storage.
25+ - ` hack/update-manifests.sh ` : CRD/RBAC generation entrypoint.
2026- ` hack/update-codegen.sh ` : deepcopy codegen entrypoint.
21- - ` Makefile ` : canonical build/test/vendor/codegen commands.
22- - ` .github/workflows/ci.yaml ` : CI checks, workflow linting, and ` :main ` container publish.
27+ - ` Makefile ` : canonical build/test/lint/vendor/codegen/manifests commands.
28+ - ` .golangci.yml ` : lint and formatting rules (including ` gofumpt ` ).
29+ - ` .github/workflows/ci.yaml ` and ` .github/workflows/release.yaml ` : CI and release pipelines.
30+ - ` .goreleaser.yaml ` and ` Dockerfile.goreleaser ` : release packaging and container build configuration.
2331
2432### Important directories
25- - ` api/v1alpha1/ ` : API group/version types and generated deepcopy code.
26- - ` internal/controller/ ` : reconciliation logic.
27- - ` internal/deps/ ` : blank imports to keep baseline Kubernetes tool deps in ` go.mod ` /` vendor ` .
28- - ` hack/ ` : maintenance scripts.
33+ - ` api/v1alpha1/ ` : CRD API group/version types and generated deepcopy code.
34+ - ` api/aggregation/v1alpha1/ ` : aggregated API group/version types and generated deepcopy code.
35+ - ` internal/app/ ` : application-mode bootstrap packages (` controllerapp ` , ` apiserverapp ` ).
36+ - ` internal/controller/ ` : controller reconciliation logic and envtest coverage.
37+ - ` internal/aggregated/ ` : aggregated API server storage implementation.
38+ - ` internal/deps/ ` : blank imports to keep Kubernetes tool deps pinned in ` go.mod ` /` vendor ` .
39+ - ` config/ ` : generated CRDs, RBAC, and sample manifests.
40+ - ` deploy/ ` : deployment manifests for controller and aggregated API server components.
41+ - ` hack/ ` : maintenance scripts (codegen/manifests).
42+ - ` scripts/ ` : PR workflow automation and review/check helpers.
2943- ` .github/workflows/ ` : CI and release automation.
3044- ` vendor/ ` : checked-in module dependencies (required by project workflow).
3145
3246### Architecture notes
33- - ` main ` registers core Kubernetes + project schemes, constructs a controller-runtime manager, and starts it.
34- - Reconciliation is intentionally minimal: fetch resource, validate identity assumptions, then no-op with TODO markers.
47+ - ` main ` delegates to ` run(...) ` , which requires ` --app=<controller|aggregated-apiserver> ` .
48+ - ` controller ` mode registers core Kubernetes + ` coder.com/v1alpha1 ` schemes, starts the controller-runtime manager, and wires health/readiness probes.
49+ - ` aggregated-apiserver ` mode builds a generic API server for ` aggregation.coder.com/v1alpha1 ` and installs ` coderworkspaces ` /` codertemplates ` storage.
3550- Defensive checks are intentional (` assertion failed: ... ` ) and used to fail fast during development.
3651
3752## Essential Commands
3853
3954Run from repository root.
4055
4156- ** Build:** ` make build `
42- - ** Format (apply):** ` find . -type f -name '*.go' -not -path './vendor/*' -print0 | xargs -0 gofmt -w `
43- - ** Format (check):** ` find . -type f -name '*.go' -not -path './vendor/*' -print0 | xargs -0 gofmt -l `
44- - ** Lint (workflows):** ` go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.10 `
4557- ** Test:** ` make test `
46- - ** Clean:** ` go clean -cache -testcache && rm -f ./coder-k8s && rm -rf ./dist `
47- - ** Development run:** ` GOFLAGS=-mod=vendor go run . ` (requires Kubernetes config via your env, e.g. ` KUBECONFIG ` )
58+ - ** Integration tests (controller envtest):** ` make test-integration `
59+ - ** Lint + format checks:** ` make lint `
60+ - ** Format (apply):** ` GOFLAGS=-mod=vendor golangci-lint fmt `
61+ - ** Format (check):** ` GOFLAGS=-mod=vendor golangci-lint fmt --diff `
62+ - ** Vulnerability scan:** ` make vuln `
63+ - ** Lint (workflows):** ` go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.10 `
64+ - ** Development run (controller mode):** ` GOFLAGS=-mod=vendor go run . --app=controller ` (requires Kubernetes config via your env, e.g. ` KUBECONFIG ` )
65+ - ** Development run (aggregated API mode):** ` GOFLAGS=-mod=vendor go run . --app=aggregated-apiserver `
4866- ** Vendor consistency:** ` make verify-vendor `
67+ - ** Manifest generation:** ` make manifests ` (or ` bash ./hack/update-manifests.sh ` )
4968- ** Code generation:** ` make codegen ` (or ` bash ./hack/update-codegen.sh ` )
69+ - ** Clean:** ` go clean -cache -testcache && rm -f ./coder-k8s && rm -rf ./dist `
5070- ** Shell scripts:** ` find . -type f -name '*.sh' -not -path './vendor/*' `
5171
5272## Patterns
@@ -55,10 +75,10 @@ Run from repository root.
5575 ** Don’t** silently ignore these paths or convert them to soft failures.
5676- ** Do** keep vendoring in sync when dependencies change (` go mod tidy ` , ` go mod vendor ` , then verify diff).
5777 ** Don’t** submit dependency changes without updating ` vendor/ ` .
58- - ** Do** regenerate deepcopy code after API type changes (` make codegen ` ).
59- ** Don’t** hand-edit ` api/v1alpha1/ zz_generated.deepcopy.go` .
60- - ** Do** keep controller and API changes paired with tests in ` main_test.go ` or focused package tests.
61- ** Don’t** add reconciliation behavior without coverage for critical assumptions.
78+ - ** Do** regenerate generated artifacts after API changes (` make codegen ` , ` make manifests ` ).
79+ ** Don’t** hand-edit generated files like ` zz_generated.deepcopy.go ` or CRD/RBAC manifests .
80+ - ** Do** keep controller, aggregated API server, and storage changes paired with focused tests ( ` main_test.go ` , ` internal/controller/*_test.go ` , and package tests under ` internal/app/ ` / ` internal/aggregated/ ` ) .
81+ ** Don’t** add behavior without coverage for critical assumptions.
6282
6383## Anti-patterns
6484
@@ -68,7 +88,8 @@ Run from repository root.
6888
6989## Code Style
7090
71- - Follow idiomatic Go and keep code ` gofmt ` -formatted.
91+ - Follow idiomatic Go and the [ Uber Go Style Guide] ( https://github.com/uber-go/guide/blob/master/style.md ) as a baseline; project-specific rules in this file take precedence.
92+ - Keep code ` gofumpt ` -formatted (enforced via ` golangci-lint fmt ` ).
7293- Keep comments concise and purposeful (package docs, exported type/function docs).
7394- Match existing error style: contextual wrapping + explicit assertion messages for impossible conditions.
7495
@@ -78,8 +99,9 @@ Run from repository root.
78991 . Run ` make test ` .
791002 . Run ` make build ` .
801013 . Run ` make verify-vendor ` .
81- 4 . If API types changed, run ` make codegen ` and include generated updates.
82- 5 . If ` .github/workflows/* ` changed, run ` go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.10 ` .
102+ 4 . Run ` make lint ` (or explain why it was skipped).
103+ 5 . If API types changed, run ` make codegen ` and ` make manifests ` , then include generated updates.
104+ 6 . If ` .github/workflows/* ` changed, run ` go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.10 ` .
83105
84106### Commit messages
85107- Match repository history style: short imperative summary, optionally prefixed by type (e.g., ` chore: ... ` ).
@@ -102,7 +124,7 @@ Run from repository root.
102124
103125When a PR exists, you MUST remain in this loop until the PR is fully ready:
1041261 . Push your latest fixes.
105- 2 . Run local validation (` make verify-vendor ` , ` make test ` , ` make build ` ).
127+ 2 . Run local validation (` make verify-vendor ` , ` make test ` , ` make build ` , ` make lint ` ).
1061283 . Request review with ` @codex review ` .
1071294 . Run ` ./scripts/wait_pr_ready.sh <pr_number> ` (it polls Codex + required checks concurrently and fails fast).
1081305 . If Codex leaves comments, address them, resolve threads with ` ./scripts/resolve_pr_comment.sh <thread_id> ` , push, and repeat.
0 commit comments