Instructions for AI coding agents. For project overview, see README.md. For contribution guidelines, see CONTRIBUTING.md.
| Directory | Purpose |
|---|---|
api/v1beta1/ |
CRD types (Metal3Cluster, Metal3Machine, Metal3Data, etc.) - separate Go module |
controllers/ |
Reconciliation logic |
baremetal/ |
BareMetalHost integration logic |
internal/webhooks/ |
Validation/defaulting webhooks |
config/ |
Kustomize manifests (CRDs, RBAC, webhooks) - auto-generated by make generate, rarely edit directly |
hack/ |
CI scripts (prefer Make targets locally) |
test/e2e/ |
E2E test suite (central for Metal3 ecosystem) |
CI is managed by Prow. Run these locally before submitting PRs:
Make targets:
| Command | Purpose |
|---|---|
make test |
Full verification (generate + lint + unit) |
make generate |
Regenerate code (DeepCopy, CRDs, RBAC, mocks) |
make unit |
Unit tests (requires envtest - do not use go test directly) |
make lint |
Go linting via golangci-lint (all modules) |
make verify-boilerplate |
Check license headers |
make modules |
Verify go.mod is tidy |
Hack scripts (auto-containerized, match CI exactly):
| Script | Purpose |
|---|---|
./hack/shellcheck.sh |
Shell script linting (shellcheck) |
./hack/markdownlint.sh |
Markdown linting (config: .markdownlint-cli2.yaml) |
./hack/manifestlint.sh |
Kubernetes manifest validation (kubeconform) |
- Go: Linting rules in
.golangci.yaml, license headers inhack/boilerplate/ - Shell: Use
set -o errexit -o nounset -o pipefail - Markdown: 3-space indent for lists (
.markdownlint-cli2.yaml)
- Edit
api/v1beta1/*_types.go - Run
make generate - Update webhooks in
internal/webhooks/if validation changes - Run
make test
CAPM3 is the central E2E test hub for the Metal3 ecosystem (validates CAPM3, IPAM, BMO, Ironic).
| Command | Purpose |
|---|---|
make test-e2e |
Run E2E tests (requires metal3-dev-env) |
GINKGO_FOCUS="basic" ./scripts/ci-e2e.sh |
Run specific scenario |
Key files:
test/e2e/config/e2e_conf.yaml- Provider versions and test configtest/e2e/data/infrastructure-metal3/- Cluster templates per versionscripts/ci-e2e.sh- Main orchestration script
When reviewing pull requests:
- Security - Hardcoded secrets, unpinned dependencies, missing input validation
- Test coverage - New functionality should have tests
- Consistency - Match existing patterns in the codebase
- Breaking changes - Flag API/behavior changes affecting users
Focus on: controllers/, baremetal/, api/, internal/webhooks/.
- Run
make unitto verify baseline - Check patterns in similar existing files
- Make minimal, surgical edits
- Run
make generateafter API changes - Run
make testbefore committing - Add tests for new functionality
- Pin external dependencies by SHA (containers, GitHub Actions, binaries)
- No hardcoded credentials
- Validate all inputs