Skip to content

Commit ab8a2fb

Browse files
claudeCopilotwikkyk
committed
docs: consolidate agent instructions into AGENTS.md
Replace CLAUDE.md and .github/copilot-instructions.md with a single AGENTS.md as the canonical source of truth for AI coding agent instructions. CLAUDE.md becomes a symlink to AGENTS.md; copilot- instructions.md is removed since copilot reads AGENTS.md natively. Co-Authored-By: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-Authored-By: Vic Kerr <wiktor.kerr@ionos.com>
1 parent 91bea6c commit ab8a2fb

3 files changed

Lines changed: 122 additions & 165 deletions

File tree

.github/copilot-instructions.md

Lines changed: 0 additions & 165 deletions
This file was deleted.

AGENTS.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# AGENTS.md
2+
3+
CAPMOX (Cluster API Provider for Proxmox VE) enables declarative management of Kubernetes clusters on Proxmox VE using the Cluster API provider contract. See `go.mod` for dependency versions.
4+
5+
The storage API version is **v1alpha2** (imported as `infrav1`). v1alpha1 exists only for backward compatibility with automatic conversion to/from v1alpha2.
6+
7+
## Repository Structure
8+
9+
- `api/v1alpha1/` — deprecated CRDs with conversion to v1alpha2
10+
- `api/v1alpha2/` — current storage version CRDs (ProxmoxCluster, ProxmoxMachine, ProxmoxMachineTemplate, ProxmoxClusterTemplate)
11+
- `cmd/main.go` — controller manager entry point
12+
- `internal/controller/` — reconciliation logic
13+
- `internal/webhook/` — validation and defaulting webhooks
14+
- `internal/service/` — VM, scheduler, and task services
15+
- `pkg/` — shared packages (proxmox client, scope, cloudinit, ignition, ipam)
16+
- `config/` — Kustomize configuration for CRDs, RBAC, webhooks
17+
- `hack/` — helper scripts
18+
- `test/e2e/` — end-to-end tests
19+
20+
## Commands
21+
22+
### Build & Test
23+
24+
```bash
25+
make build # Build manager binary
26+
make test # Run unit tests
27+
make test WHAT=./pkg/scope/... # Run tests for specific packages
28+
make lint # Run golangci-lint + kube-api-linter
29+
make lint-fix # Lint with auto-fix
30+
make yamlfmt # Format YAML files
31+
make tidy # go mod tidy
32+
make tilt-up # Start Tilt dev environment in a kind cluster
33+
```
34+
35+
### Code Generation
36+
37+
```bash
38+
make manifests # Regenerate CRDs, RBAC, webhook manifests
39+
make generate # Regenerate DeepCopy methods and conversion functions
40+
make mockgen # Regenerate mocks (configured in .mockery.yaml)
41+
```
42+
43+
### Version Bumping
44+
45+
Several dependencies appear in multiple files — always use these scripts, never edit manually:
46+
47+
```bash
48+
hack/bump-go.sh <version> # Go version in go.mod, Dockerfile, docs
49+
hack/bump-capi.sh <version> <stream> # cluster-api require, replace, metadata.yaml
50+
hack/bump-k8s.sh <version> # k8s.io/* and ENVTEST_K8S_VERSION in Makefile
51+
hack/bump-golangci-lint.sh <version> # golangci-lint in go.mod and .custom-gcl.yaml
52+
```
53+
54+
Each script accepts versions with or without a `v` prefix and runs `go mod tidy` automatically.
55+
56+
### Verification
57+
58+
```bash
59+
make verify # Verify modules and generated files are up to date
60+
make verify-versions # Check version references are consistent across the repo
61+
```
62+
63+
## Architecture
64+
65+
### Reconciliation Flow
66+
67+
Controllers (`internal/controller/`) reconcile two custom resources:
68+
69+
- **ProxmoxCluster** — manages cluster-level infrastructure (control plane endpoint, allowed nodes)
70+
- **ProxmoxMachine** — manages individual VM lifecycle on Proxmox VE
71+
72+
Each controller creates a **Scope** (`pkg/scope/`) bundling the CAPI owner objects, infrastructure CR, Proxmox client, and IPAM helper into a single context object passed through the reconciliation pipeline.
73+
74+
The ProxmoxMachine controller delegates VM operations to services under `internal/service/`:
75+
- `vmservice/` — VM clone, configure, bootstrap (cloud-init or Ignition), IP assignment, power management, deletion
76+
- `scheduler/` — selects which Proxmox node to place a new VM on
77+
- `taskservice/` — tracks async Proxmox task completion and error handling
78+
79+
### Proxmox Client Abstraction
80+
81+
`pkg/proxmox/client.go` defines the `Client` interface for all Proxmox API operations. The production implementation lives in `pkg/proxmox/goproxmox/` (wrapping `go-proxmox`). Tests use a mock at `pkg/proxmox/proxmoxtest/`.
82+
83+
### API Versions and Conversion
84+
85+
- `api/v1alpha2/` — current storage version
86+
- `api/v1alpha1/` — deprecated; conversion implemented in `*_conversion.go` and `zz_generated.conversion.go`
87+
88+
Key v1alpha2 change: unified `NetworkDevices` array replacing v1alpha1's split of `Default` + `AdditionalDevices`.
89+
90+
### Bootstrap & IPAM
91+
92+
`pkg/cloudinit/` and `pkg/ignition/` handle cloud-init and Flatcar Ignition bootstrap data. IP management is via the Cluster API IPAM contract (`pkg/kubernetes/ipam/`).
93+
94+
## Testing
95+
96+
- Unit tests colocated with source files, using envtest; see `Makefile` for `ENVTEST_K8S_VERSION`
97+
- First `make test` run builds envtest binaries — setup output is not a test failure
98+
- `testify` for assertions, `gomega`/`ginkgo` for BDD-style tests
99+
- Proxmox client mocks generated via `make mockgen` (`.mockery.yaml`)
100+
- E2E tests in `test/e2e/` require a live Proxmox VE instance; controlled by PR labels
101+
102+
## Rules
103+
104+
**Always:**
105+
- Run `make manifests generate mockgen` after modifying API types
106+
- If conversion behavior changes, update `api/v1alpha1/*_conversion.go`
107+
- Run `make lint verify test` before committing
108+
- Use `hack/bump-*.sh` scripts when changing Go, cluster-api, k8s.io, or golangci-lint versions
109+
- Run `make verify-versions` after any version bump
110+
111+
⚠️ **Ask before:**
112+
- Changing v1alpha1 conversion functions (affects backward compatibility)
113+
- Removing or renaming fields in v1alpha2 API types
114+
115+
🚫 **Never:**
116+
- Edit generated files manually — see `sonar-project.properties` `sonar.exclusions` for the full list of generated file patterns
117+
- Edit version-tracked dependencies without the corresponding `hack/bump-*.sh` script
118+
119+
## Environment
120+
121+
See `envfile.example` for development config. Key vars: `PROXMOX_URL`, `PROXMOX_TOKEN`, `PROXMOX_SECRET`, `CAPMOX_LOGLEVEL`.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

0 commit comments

Comments
 (0)