|
| 1 | +# odh-cli Development Guidelines |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +kubectl plugin for ODH (Open Data Hub) and RHOAI (Red Hat OpenShift AI). The CLI validates cluster configuration, assesses upgrade readiness, and backs up workloads. |
| 6 | + |
| 7 | +## Architecture |
| 8 | + |
| 9 | +The project follows a standard Go CLI structure with Cobra commands: |
| 10 | + |
| 11 | +```text |
| 12 | +cmd/ - Command definitions (Cobra wrappers) |
| 13 | +pkg/ - Business logic, lint checks, utilities |
| 14 | +internal/ - Internal version information |
| 15 | +docs/ - Development documentation |
| 16 | +``` |
| 17 | + |
| 18 | +Commands use a four-phase lifecycle: AddFlags -> Complete -> Validate -> Run. |
| 19 | +All commands use `Command` struct with `NewCommand()` constructor. |
| 20 | + |
| 21 | +## Build and Run |
| 22 | + |
| 23 | +```bash |
| 24 | +make build # Build the binary |
| 25 | +make run # Run the CLI |
| 26 | +make fmt # Format code (NEVER use gci/gofmt directly) |
| 27 | +make lint # Run linter (NEVER use golangci-lint directly) |
| 28 | +make lint/fix # Auto-fix lint issues (try this FIRST) |
| 29 | +make test # Run tests |
| 30 | +make check # Run all quality gates (lint) |
| 31 | +make tidy # Tidy dependencies |
| 32 | +make clean # Clean build artifacts |
| 33 | +``` |
| 34 | + |
| 35 | +CRITICAL: Always use `make` commands for formatting and linting. Never invoke `gci`, `gofmt`, or `golangci-lint` directly. Direct `go test` is acceptable for targeted test runs. |
| 36 | + |
| 37 | +## Test Guidelines |
| 38 | + |
| 39 | +- Use vanilla Gomega (not Ginkgo) with dot imports |
| 40 | +- Use `t.Run()` subtests and `t.Context()` (Go 1.24+) |
| 41 | +- All test data must be package-level constants, never inline |
| 42 | +- Use `HaveField`/`MatchFields` for struct assertions |
| 43 | +- Mocks must use testify/mock in `pkg/util/test/mocks/` |
| 44 | +- Use fake clients from `sigs.k8s.io/controller-runtime/pkg/client/fake` |
| 45 | + |
| 46 | +## Debug and Troubleshooting |
| 47 | + |
| 48 | +- Run `make lint/fix` first for any lint issues before manual debug |
| 49 | +- Use `make check` after every implementation change |
| 50 | +- For test failures: `go test -v ./pkg/<package> -run TestName` |
| 51 | +- Check `.golangci.yml` for linter configuration |
| 52 | + |
| 53 | +## CRITICAL: Required Reading for All Agents |
| 54 | + |
| 55 | +**Before starting ANY work on this project, agents MUST read the following documents:** |
| 56 | + |
| 57 | +### Core Guidelines |
| 58 | +- @docs/agent.md |
| 59 | +- @docs/development.md (navigation hub - read this first) |
| 60 | +- @docs/design.md |
| 61 | + |
| 62 | +### Setup and Workflow |
| 63 | +- @docs/setup.md |
| 64 | +- @docs/quality.md |
| 65 | +- @docs/code-review.md |
| 66 | + |
| 67 | +### Coding Standards |
| 68 | +- @docs/coding/conventions.md |
| 69 | +- @docs/coding/patterns.md |
| 70 | +- @docs/coding/formatting.md |
| 71 | + |
| 72 | +### Testing and Extensibility |
| 73 | +- @docs/testing.md |
| 74 | +- @docs/extensibility.md |
| 75 | + |
| 76 | +### Lint Command (when working on lint features) |
| 77 | +- @docs/lint/architecture.md |
| 78 | +- @docs/lint/writing-checks.md |
| 79 | + |
| 80 | +These documents contain critical requirements that MUST be followed. |
| 81 | +Failure to read and follow these guidelines will result in code that does not meet project standards. |
0 commit comments